// --------------------------------------------------------------------------- #include #pragma hdrstop #include "VecDraw.h" #include "Vector_F.h" #include "PenManager.h" #include "FullView.h" // #include "Draw_F.h" #include "Palette.h" #include "Math.h" #include "DXF.h" #include "MainMenu.h" #include "MainImage.h" #include "ConvertToSVG.h" #include "StatusProgress.h" #include "SVG2Vector.h" // for SVG - by maxleo21c(06.06.17) #include #include "Define.h" #include "Math.h" #include "LogData.h" #include "Main.h" #include "Exception.h" // HotKey - by monkman (2010.07.06) #include "LogData.h" #include "SVG2VectorByTinyXML.h" #include "Define.h" #include "DXFLoader.h" #include "Combination.h" // sorry.... for ÀÛ¾÷Áö½Ã¼­ - by monkman (2010.12.24) #include "CombiResult.h" // sorry.... for ÀÛ¾÷Áö½Ã¼­ - by monkman (2010.12.24) #include "Crypt.h" using namespace TTinyXML; using namespace TPVECTOR2D; // --------------------------------------------------------------------------- #define MAX_UNDO 200 #define DXF_ERR -1 // --------------------------------------------------------------------------- #define SQR(A) (A)*(A) #define MAX(X,Y) ((X) >= (Y) ? (X) : (Y)) #define MIN(X,Y) ((X) >= (Y) ? (Y) : (X)) #define DEL(X) if(X != NULL) { delete X; X = NULL; } // --------------------------------------------------------------------------- #define IDS_MESSAGE001 StringTable[0] #define IDS_MESSAGE002 StringTable[1] #define IDS_MESSAGE003 StringTable[2] #define IDS_MESSAGE004 StringTable[3] #define IDS_MESSAGE005 StringTable[4] #define IDS_MESSAGE006 StringTable[5] #define IDS_MESSAGE007 StringTable[6] #define IDS_MESSAGE008 StringTable[7] #define IDS_MESSAGE009 StringTable[8] #define IDS_MESSAGE010 StringTable[9] #define IDS_MESSAGE011 StringTable[10] #define IDS_MESSAGE012 StringTable[11] //TEXT´Â ¸ðƼºê ¼³Á¤À» ÇÒ ¼ö ¾ø½À´Ï´Ù. #define IDS_MESSAGE013 StringTable[12] //SyleÀúÀåÀº º¤ÅÍ ¶óÀθ¸ °¡´ÉÇÕ´Ï´Ù. #define IDS_MESSAGE014 StringTable[13] //Á¡ÀÇ °³¼ö°¡ ¸¹¾Æ µÎ ¿ÀºêÁ§Æ®°¡ ¿¬°áÀÌ µÇÁö ¾Ê½À´Ï´Ù. Á¡À» »èÁ¦Çϼ¼¿ä. // --------------------------------------------------------------------------- #pragma package(smart_init) // --------------------------------------------------------------------------- TVecDraw *VecDraw; __fastcall TVecDraw::TVecDraw(TComponent* Owner) { hWnd = ((TWinControl*)Owner)->Handle; StringTable.Create(DirectoryItem, Language, "VecDraw"); DataCode = T_TILE; CopyList = new TList; TransList1 = new TList; TransList2 = new TList; bZKey = false; bJKeyState = false; bJoinState = false; // by embakum mousedown = 0; pstore = new TList; pdstore = new TList; mdown = false; isFirst = true; // by embakum ¸ðƼºê ¹Ýº¹ 2009.02.10 tempChildList = new TList; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ĵ¹ö½º¿¡ µ¶¸³ÀûÀ̾î¾ß ÇÏ´Â VecDrawÀÇ º¯¼ö¸¦ MainImageFormÀ¸·Î À̵¿ - by monkman (2005.03.08) // Pointer (*) °¡ ºÙÀº º¯¼öµéÀº ´ëºÎºÐ MainImageFormÀ¸·Î À̵¿µÈ º¯¼öÀÌ´Ù // bFirst = true; // bFstLine = true; // bSelected = false; // bProportion = false; // bRotation = false; // bClosedState= false; // bUndosw = true; // bMergeMode = false; // bExtend = false; // bLocked = false; // bPatternMode= false; // PatternStep = 0; // bFirst = NULL; // bFstLine = NULL; // bSelected = NULL; // bClosedState = NULL; // bProportion = NULL; // // bOutline Ãß°¡ (2008. 01. 11 Annualring) // // bOutline = NULL; // // bUndosw = NULL; // bMergeMode = NULL; // // bRepeatMode = NULL; // bExtend = NULL; // bLocked = NULL; // bRotation = NULL; // bPatternMode = NULL; // bSelectedVectorMove = NULL; // selected object°¡ moveÁßÀÎÁö ¾Æ´ÑÁö shin // bVectorMove = NULL; // ¼Óµµ °³¼± - Vector À̵¿ ½Ã - by monkman (2005.07.13) // bFontChange = NULL; // step = NULL; // PatternStep = NULL; NVector = NULL; // ¹ÝÀü °Å¿ï ±â´É °ü·Ã Ãß°¡- by monkman(2005.04.01) // bVectorReflectionMode = NULL; // ReflectionVH = NULL; // ReflectionVIndex = NULL; // ReflectionHIndex = NULL; // ReflectFirstIndex = NULL; // bReflectionGuideLineLock = NULL; // // ¹ÝÀü °Å¿ï °ü·Ã Ãß°¡ - by monkman(2005.06.10) // SelectedList = new TList; // BackUpList = new TList; // ReflectionList = new TList; // ZigZag ±â´É °ü·Ã Ãß°¡- by monkman(2005.04.08) ZigZagBackUpList = NULL; SpreadStep = 0; SpreadGap = 40; PropPoints = NULL; // PropPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ÇßÀ¸¹Ç·Î ÃʱâÈ­ - by monkman (2011.04.14) // ¼Óµµ °³¼± - FullView¸¦ ºü¸£°Ô ±×·ÁÁÖ±â À§ÇÑ ºñÆ®¸Ê - by monkman (2005.07.20) FullViewBitmap = NULL; FullViewBitmapMask = NULL; CurrentTextBoxData = NULL; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- bZKey = false; bShiftState = false; bAltState = false; bPointModeState = false; bVectorStyle = false; bStyle = false; PathColor = clAqua; nSelPos = 0; ptNumber = -1; TextAngle = 0; SubBitmap = NULL; SourceBitmap = NULL; PatternPastAngle = 0; PatternPastWidth = 100; PatternPastHeight = 100; OSVERSIONINFO osvi; osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&osvi); osVERSION = osvi.dwPlatformId; // For Text Processing in Vector by maxleo21c (2004.10.19) IndexOfLine = 0; // Word Index (OffSet) IndexOfWord = 0; // Line Index (OffSet) CurrentTextBox = -1; // ÃʱâÈ­ shin CaretH = 0; CaretW = 0; // ±ÛÀÚÀÇ Å©±â xCaretPoz = 0; yCaretPoz = 0; // ÇöÀç Caret ½ÇÁ¦ À§Ä¡ BeReadyEdit = false; ExistSelected = false; BeModified = false; // for new font BeTextBoxCreated = false; // for new font EndLine = 0; bInSel = false; ListOfSelectedWord = new TList; gdp::GdiplusStartup(&gdp_token_, &gdp::GdiplusStartupInput(), NULL); // bIsPrint = false; // by siuaa 080414 nMaxMotiveLength = 0; SelectedWordData = 0; // ======= Combination¿¡ »ç¿ëÇÏ´Â µ¥ÀÌÅÍ Man_Upper.Clear(); Man_Lower.Clear(); Woman_Upper.Clear(); Woman_Lower.Clear(); Child_Upper.Clear(); Child_Lower.Clear(); Baby_Upper.Clear(); Baby_Lower.Clear(); Man_Upper << TP_COAT << TP_JACKET << TP_JUMPER << TP_KNIT << TP_SHIRTS << TP_TOP << TP_VEST; Man_Lower << TP_PANTS; Woman_Upper << TP_ONEPIECE << TP_BLOUSE << TP_COAT << TP_JACKET << TP_JUMPER << TP_KNIT << TP_SHIRTS << TP_TOP << TP_VEST; Woman_Lower << TP_PANTS << TP_SKIRT; // DSChild¿¡ TP_JACKET, TP_TOP, TP_KNIT, TP_BLOUSE Ãß°¡ - by monkman (2004.07.03) Child_Upper << TP_CAPE << TP_COAT << TP_JUMPER << TP_SHIRTS << TP_ONEPIECE << TP_VEST << TP_JACKET << TP_TOP << TP_KNIT << TP_BLOUSE; Child_Lower << TP_PANTS << TP_SKIRT; Baby_Upper << TP_CAPE << TP_ROMPERS << TP_SHIRTS << TP_ONEPIECE; Baby_Lower << TP_PANTS << TP_SKIRT; SilhouetteCount = 1; SleeveCount = 1; CollarCount = 1; UpperMaterialCount = 1; PantsCount = 1; BeltCount = 1; LowerMaterialCount = 1; SilhouetteName[0] = "None"; SleeveName[0] = "None"; CollarName[0] = "None"; UpperMaterialName[0] = "None"; PantsName[0] = "None"; BeltName[0] = "None"; LowerMaterialName[0] = "None"; for (int i = 1; i < 127; i++) { SilhouetteName[i] = ""; SleeveName[i] = ""; CollarName[i] = ""; UpperMaterialName[i] = ""; PantsName[i] = ""; BeltName[i] = ""; LowerMaterialName[i] = ""; } PasteObjRange.left = 0; PasteObjRange.right = 0; PasteObjRange.top = 0; PasteObjRange.bottom = 0; #ifdef WORKSHEET // NoneÀº ¹«Á¶°Ç µé¾î°£´Ù Man_Coat_Sil << 0; Man_Coat_Sle << 0; Man_Coat_Col << 0; Man_Coat_Mat << 0; Man_Jacket_Sil << 0; Man_Jacket_Sle << 0; Man_Jacket_Col << 0; Man_Jacket_Mat << 0; Man_Jumper_Sil << 0; Man_Jumper_Sle << 0; Man_Jumper_Col << 0; Man_Jumper_Mat << 0; Man_Knit_Sil << 0; Man_Knit_Sle << 0; Man_Knit_Col << 0; Man_Knit_Mat << 0; Man_Shirts_Sil << 0; Man_Shirts_Sle << 0; Man_Shirts_Col << 0; Man_Shirts_Mat << 0; Man_Top_Sil << 0; Man_Top_Sle << 0; Man_Top_Col << 0; Man_Top_Mat << 0; Man_Vest_Sil << 0; Man_Vest_Sle << 0; Man_Vest_Col << 0; Man_Vest_Mat << 0; Man_Pants_Sil << 0; Man_Pants_Belt << 0; Man_Pants_Mat << 0; Woman_Coat_Sil << 0; Woman_Coat_Sle << 0; Woman_Coat_Col << 0; Woman_Coat_Mat << 0; Woman_Jacket_Sil << 0; Woman_Jacket_Sle << 0; Woman_Jacket_Col << 0; Woman_Jacket_Mat << 0; Woman_Jumper_Sil << 0; Woman_Jumper_Sle << 0; Woman_Jumper_Col << 0; Woman_Jumper_Mat << 0; Woman_Knit_Sil << 0; Woman_Knit_Sle << 0; Woman_Knit_Col << 0; Woman_Knit_Mat << 0; Woman_Shirts_Sil << 0; Woman_Shirts_Sle << 0; Woman_Shirts_Col << 0; Woman_Shirts_Mat << 0; Woman_Top_Sil << 0; Woman_Top_Sle << 0; Woman_Top_Col << 0; Woman_Top_Mat << 0; Woman_Vest_Sil << 0; Woman_Vest_Sle << 0; Woman_Vest_Col << 0; Woman_Vest_Mat << 0; Woman_OnePiece_Sil << 0; Woman_OnePiece_Sle << 0; Woman_OnePiece_Col << 0; Woman_OnePiece_Mat << 0; Woman_Blouse_Sil << 0; Woman_Blouse_Sle << 0; Woman_Blouse_Col << 0; Woman_Blouse_Mat << 0; Woman_Pants_Sil << 0; Woman_Pants_Belt << 0; Woman_Pants_Mat << 0; Woman_Skirt_Sil << 0; Woman_Skirt_Belt << 0; Woman_Skirt_Mat << 0; Child_Coat_Sil << 0; Child_Coat_Sle << 0; Child_Coat_Col << 0; Child_Coat_Mat << 0; Child_Jacket_Sil << 0; Child_Jacket_Sle << 0; Child_Jacket_Col << 0; Child_Jacket_Mat << 0; Child_Jumper_Sil << 0; Child_Jumper_Sle << 0; Child_Jumper_Col << 0; Child_Jumper_Mat << 0; Child_Knit_Sil << 0; Child_Knit_Sle << 0; Child_Knit_Col << 0; Child_Knit_Mat << 0; Child_Shirts_Sil << 0; Child_Shirts_Sle << 0; Child_Shirts_Col << 0; Child_Shirts_Mat << 0; Child_Top_Sil << 0; Child_Top_Sle << 0; Child_Top_Col << 0; Child_Top_Mat << 0; Child_Vest_Sil << 0; Child_Vest_Sle << 0; Child_Vest_Col << 0; Child_Vest_Mat << 0; Child_OnePiece_Sil << 0; Child_OnePiece_Sle << 0; Child_OnePiece_Col << 0; Child_OnePiece_Mat << 0; Child_Blouse_Sil << 0; Child_Blouse_Sle << 0; Child_Blouse_Col << 0; Child_Blouse_Mat << 0; Child_Cape_Sil << 0; Child_Cape_Sle << 0; Child_Cape_Col << 0; Child_Cape_Mat << 0; Child_Pants_Sil << 0; Child_Pants_Belt << 0; Child_Pants_Mat << 0; Child_Skirt_Sil << 0; Child_Skirt_Belt << 0; Child_Skirt_Mat << 0; Baby_Shirts_Sil << 0; Baby_Shirts_Sle << 0; Baby_Shirts_Col << 0; Baby_Shirts_Mat << 0; Baby_OnePiece_Sil << 0; Baby_OnePiece_Sle << 0; Baby_OnePiece_Col << 0; Baby_OnePiece_Mat << 0; Baby_Cape_Sil << 0; Baby_Cape_Sle << 0; Baby_Cape_Col << 0; Baby_Cape_Mat << 0; Baby_Rompers_Sil << 0; Baby_Rompers_Sle << 0; Baby_Rompers_Col << 0; Baby_Rompers_Mat << 0; Baby_Pants_Sil << 0; Baby_Pants_Belt << 0; Baby_Pants_Mat << 0; Baby_Skirt_Sil << 0; Baby_Skirt_Belt << 0; Baby_Skirt_Mat << 0; memset(Man_Coat_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Man_Jacket_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Man_Jumper_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Man_Knit_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Man_Shirts_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Man_Top_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Man_Vest_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Man_Pants_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Woman_Coat_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Woman_Jacket_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Woman_Jumper_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Woman_Knit_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Woman_Shirts_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Woman_Top_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Woman_Vest_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Woman_OnePiece_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Woman_Blouse_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Woman_Pants_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Woman_Skirt_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Child_Coat_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Child_Jacket_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Child_Jumper_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Child_Knit_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Child_Shirts_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Child_Top_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Child_Vest_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Child_OnePiece_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Child_Blouse_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Child_Cape_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Child_Pants_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Child_Skirt_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Baby_Shirts_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Baby_OnePiece_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Baby_Cape_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Baby_Rompers_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Baby_Pants_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Baby_Skirt_Cell_Order, 0, sizeof(BYTE) * CELL_COUNT); memset(Man_Coat_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Man_Jacket_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Man_Jumper_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Man_Knit_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Man_Shirts_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Man_Top_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Man_Vest_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Man_Pants_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Woman_Coat_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Woman_Jacket_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Woman_Jumper_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Woman_Knit_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Woman_Shirts_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Woman_Top_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Woman_Vest_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Woman_OnePiece_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Woman_Blouse_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Woman_Pants_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Woman_Skirt_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Child_Coat_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Child_Jacket_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Child_Jumper_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Child_Knit_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Child_Shirts_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Child_Top_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Child_Vest_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Child_OnePiece_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Child_Blouse_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Child_Cape_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Child_Pants_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Child_Skirt_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Baby_Shirts_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Baby_OnePiece_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Baby_Cape_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Baby_Rompers_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Baby_Pants_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); memset(Baby_Skirt_Cell_Visible, 0, sizeof(bool) * CELL_COUNT); #endif } // --------------------------------------------------------------------------- __fastcall TVecDraw::~TVecDraw() { BEGIN_LOG(""); TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) for (int i = 0; i < CopyList->Count; i++) { data = (TVecData*)CopyList->Items[i]; if (data) { if (data->ParentTextBox) { delete data->ParentTextBox; data->ParentTextBox = NULL; } delete data; } data = NULL; } CopyList->Clear(); // ÇѲ¨¹ø¿¡ Áö¿ì´Â °ÍÀ¸·Î ¼öÁ¤ - by monkman (2009.03.31) for (int i = 0; i < TransList1->Count; i++) { data = (TVecData*)TransList1->Items[i]; if (data) delete data; data = NULL; } TransList1->Clear(); for (int i = 0; i < TransList2->Count; i++) { data = (TVecData*)TransList2->Items[i]; if (data) delete data; data = NULL; } TransList2->Clear(); // for (int i = 0; i < SelectedList->Count; i++) { // data = (TVecData*)SelectedList->Items[i]; // if (data) // delete data; // data = NULL; // } // SelectedList->Clear(); // for (int i = 0; i < BackUpList->Count; i++) { // data = (TVecData*)BackUpList->Items[i]; // if (data) // delete data; // data = NULL; // } // BackUpList->Clear(); // for (int i = 0; i < ReflectionList->Count; i++) { // data = (TVecData*)ReflectionList->Items[i]; // if (data) // delete data; // data = NULL; // } // ReflectionList->Clear(); // by embakum InitData(); delete pstore; delete pdstore; // by embakum ¸ðƼºê ¹Ýº¹ 20090217 for (int i = 0; i < tempChildList->Count; i++) { data = (TVecData*)tempChildList->Items[i]; if (data) delete data; data = NULL; } tempChildList->Clear(); delete tempChildList; delete CopyList; delete TransList1; delete TransList2; // delete SelectedList; // delete BackUpList; // delete ReflectionList; if (SubBitmap) { delete SubBitmap; SubBitmap = NULL; } if (SourceBitmap) { delete SourceBitmap; SourceBitmap = NULL; } // PropPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ÇßÀ¸¹Ç·Î ÃʱâÈ­ - by monkman (2011.04.14) if (PropPoints) delete[]PropPoints; PropPoints = NULL; // ¼Óµµ °³¼± - FullView¸¦ ºü¸£°Ô ±×·ÁÁÖ±â À§ÇÑ ºñÆ®¸Ê - by monkman (2005.07.20) if (FullViewBitmap) { delete FullViewBitmap; FullViewBitmap = NULL; } if (FullViewBitmapMask) { delete FullViewBitmapMask; FullViewBitmapMask = NULL; } TSWordData *tsWordData; // for Selected Word in TextBox by maxleo21c (04.10.19) for (int i = 0; i < ListOfSelectedWord->Count; i++) { // ¿¡·¯¼öÁ¤ - by monkman (2009.04.01) tsWordData = (TSWordData*)ListOfSelectedWord->Items[i]; if (tsWordData) delete tsWordData; tsWordData = NULL; } delete ListOfSelectedWord; if (CurrentTextBoxData){ delete CurrentTextBoxData; CurrentTextBoxData = NULL; } gdp::GdiplusShutdown(gdp_token_); // ======= Combination¿¡ »ç¿ëÇÏ´Â µ¥ÀÌÅÍ Man_Upper.Clear(); Man_Lower.Clear(); Woman_Upper.Clear(); Woman_Lower.Clear(); Child_Upper.Clear(); Child_Lower.Clear(); Baby_Upper.Clear(); Baby_Lower.Clear(); SilhouetteCount = 0; SleeveCount = 0; CollarCount = 0; UpperMaterialCount = 0; PantsCount = 0; BeltCount = 0; LowerMaterialCount = 0; for (int i = 0; i < 127; i++) { SilhouetteName[i] = ""; SleeveName[i] = ""; CollarName[i] = ""; UpperMaterialName[i] = ""; PantsName[i] = ""; BeltName[i] = ""; LowerMaterialName[i] = ""; } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::MappingVariable(TNVector *SrcVector) { // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ĵ¹ö½º¿¡ µ¶¸³ÀûÀ̾î¾ß ÇÏ´Â VecDrawÀÇ º¯¼ö¸¦ MainImageFormÀ¸·Î À̵¿ - by monkman (2005.03.08) // MainImageForm¿¡ ÀÖ´Â Vector º¯¼öµé°ú ¿¬°á ½ÃÄÑÁØ´Ù NVector = SrcVector; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } //--------------------------------------------------------------------------- void __fastcall TVecDraw::InitVariable(TNVector *SrcVector) { // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ĵ¹ö½º¿¡ µ¶¸³ÀûÀ̾î¾ß ÇÏ´Â VecDrawÀÇ º¯¼ö¸¦ MainImageFormÀ¸·Î À̵¿ - by monkman (2005.03.08) // º¯¼ö¸¦ ÃʱâÈ­ ÇÑ´Ù NVector->Init(); // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } //--------------------------------------------------------------------------- /* void __fastcall TVecDraw::MappingMainImageVariable(TMainImageForm *mif) { // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ĵ¹ö½º¿¡ µ¶¸³ÀûÀ̾î¾ß ÇÏ´Â VecDrawÀÇ º¯¼ö¸¦ MainImageFormÀ¸·Î À̵¿ - by monkman (2005.03.08) // MainImageForm¿¡ ÀÖ´Â Vector º¯¼öµé°ú ¿¬°á ½ÃÄÑÁØ´Ù if (mif) { bFirst = &(mif->bFirst); bFstLine = &(mif->bFstLine); bFirstMove = &(mif->bFirstMove); bSelected = &(mif->bSelected); bClosedState = &(mif->bClosedState); bProportion = &(NVector->bProportion); // bOutline Ãß°¡ (2008. 01. 11 Annualring) // bOutline = &(mif->bOutline); bUndosw = &(mif->bUndosw); bMergeMode = &(mif->bMergeMode); bExtend = &(mif->bExtend); bExtendFirst = &(mif->bExtendFirst); bLocked = &(mif->bLocked); bRotation = &(mif->bRotation); bPatternMode = &(mif->bPatternMode); bSelectedVectorMove = &(mif->bSelectedVectorMove); bVectorMove = &(mif->bVectorMove); bCancelAntialiasing = &(mif->bCancelAntialiasing); bFontChange = &(mif->bFontChange); step = &(mif->step); PatternStep = &(mif->PatternStep); // ¹ÝÀü °Å¿ï ±â´É °ü·Ã Ãß°¡- by monkman(2005.04.01) bVectorReflectionMode = &(mif->bVectorReflectionMode); ReflectionVH = &(mif->ReflectionVH); ReflectionVIndex = &(mif->ReflectionVIndex); ReflectionHIndex = &(mif->ReflectionHIndex); ReflectFirstIndex = &(mif->ReflectFirstIndex); bReflectionGuideLineLock = &(mif->bReflectionGuideLineLock); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } // --------------------------------------------------------------------------- void __fastcall TVecDraw::InitMainImageVariable(TMainImageForm *mif) { // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ĵ¹ö½º¿¡ µ¶¸³ÀûÀ̾î¾ß ÇÏ´Â VecDrawÀÇ º¯¼ö¸¦ MainImageFormÀ¸·Î À̵¿ - by monkman (2005.03.08) // º¯¼ö¸¦ ÃʱâÈ­ ÇÑ´Ù if (mif) { *bFirst = true; *bFstLine = true; *bSelected = false; *bClosedState = false; *bProportion = false; // bOutline Ãß°¡ (2008. 01. 11 Annualring) // *bOutline = false; *bUndosw = false; *bMergeMode = false; *bExtend = false; *bLocked = false; *bRotation = false; *bPatternMode = false; *bSelectedVectorMove = false; *bVectorMove = false; *bCancelAntialiasing = false; *bFontChange = false; *step = 0; *PatternStep = 0; *bVectorReflectionMode = false; *ReflectionVH = 0; *ReflectionVIndex = -1; *ReflectionHIndex = -1; *ReflectFirstIndex = true; *bReflectionGuideLineLock = false; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } // --------------------------------------------------------------------------- */ // --------------------------------------------------------------------------- ///////////// Class of TVUndoData // --------------------------------------------------------------------------- __fastcall TVUndoData::TVUndoData(int inst) { Instance = inst; bFirst = true; ChildList = NULL; } // --------------------------------------------------------------------------- __fastcall TVUndoData::~TVUndoData() { if (ChildList) DeleteChildList(); } // --------------------------------------------------------------------------- bool __fastcall TVUndoData::Equal(int inst) { return Instance == inst; } // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- /////////////////// Draw ZigZag // --------------------------------------------------------------------------- __fastcall TPointList::TPointList() { // TPointList »ý¼ºÀÚ CurrentIndex = 0; PointList = new TList; } // --------------------------------------------------------------------------- __fastcall TPointList::~TPointList() { // double * value; LengthPOINT * value; while (PointList->Count) { value = (LengthPOINT*)PointList->Last(); PointList->Remove(value); delete value; value = NULL; } delete PointList; PointList = NULL; } // --------------------------------------------------------------------------- void __fastcall TPointList::Add(int n, double d, double px, double py, double tx, double ty, double nx, double ny) { LengthPOINT * value = new LengthPOINT; value->SegmentNum = n; value->t = d; value->px = px; value->py = py; value->tx = tx; value->ty = ty; value->nx = nx; value->ny = ny; PointList->Add(value); } // --------------------------------------------------------------------------- void __fastcall TPointList::Clear() { PointList->Clear(); } // --------------------------------------------------------------------------- bool __fastcall TPointList::IsFirst() { return CurrentIndex == 0; } // --------------------------------------------------------------------------- void __fastcall TPointList::First() { CurrentIndex = 0; } // --------------------------------------------------------------------------- void __fastcall TPointList::Next() { CurrentIndex++; } // --------------------------------------------------------------------------- bool __fastcall TPointList::IsDone() { return !(CurrentIndex < PointList->Count); } // --------------------------------------------------------------------------- double __fastcall TPointList::CurrentDouble() { BEGIN_LOG(""); LengthPOINT * Temp = (LengthPOINT*)PointList->Items[CurrentIndex]; END_LOG; return Temp->t; } // --------------------------------------------------------------------------- LengthPOINT * __fastcall TPointList::CurrentPt() { BEGIN_LOG(""); LengthPOINT *retValue = NULL; retValue = (LengthPOINT*)PointList->Items[CurrentIndex]; END_LOG; return retValue; } // --------------------------------------------------------------------------- LengthPOINT * __fastcall TPointList::NextPt() { BEGIN_LOG(""); LengthPOINT *retValue = NULL; retValue = (LengthPOINT*)PointList->Items[CurrentIndex++]; END_LOG; return retValue; } // --------------------------------------------------------------------------- // todo: TVecMotive Stitch // --------------------------------------------------------------------------- /// TVecMotive»ý¼ºÇÔ¼ö /** TVecMotiveÀÇ ¼Ó¼ºµéÀ» ÃʱâÈ­ ½ÃÄÑÁÜ. */ __fastcall TVecMotive::TVecMotive() { Bitmap = new TTexpiaBitmap; // width: 30, height: 30 Bitmap->Create(50, 50, 24); Bitmap->FillRect(TRect(0, 0, 50, 50), clWhite); MotiveList = new TList; First.x = MaxInt; First.y = MaxInt; Second.x = 0; Second.y = 0; } // --------------------------------------------------------------------------- /// TVecMotive¼Ò¸êÇÔ¼ö /** TVecMotive¸¦ »èÁ¦ÇÔ. */ __fastcall TVecMotive::~TVecMotive() { BEGIN_LOG(""); TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) if (MotiveList) { for (int i = 0; i < MotiveList->Count; i++) { data = (TVecData*)MotiveList->Items[i]; if (data) delete data; data = NULL; } MotiveList->Clear(); delete MotiveList; } if (Bitmap) delete Bitmap; Bitmap = NULL; END_LOG; } // --------------------------------------------------------------------------- /// TVecMotiveÀúÀåÇÔ¼ö /** TVecMotive¸¦ ÀúÀåÇÔ. Bitmap°ú MotiveListÀÇ Vector, Á¡(First,Second)À» ÀúÀåÇÔ. */ bool __fastcall TVecMotive::SaveToFile(HANDLE fh, int version) { BEGIN_LOG(""); DWORD dwWrite; bool bReturn = true; bReturn = Bitmap->SaveToTexpiaFile(fh, cmZLib); if (!bReturn) goto fail; if (!WriteFile(fh, &First, sizeof(POINT), &dwWrite, NULL)) { bReturn = false; goto fail; } if (!WriteFile(fh, &Second, sizeof(POINT), &dwWrite, NULL)) { bReturn = false; goto fail; } // bReturn = VecDraw->SaveToFile(fh, MotiveList, 5); bReturn = VecDraw->SaveToFile(fh, MotiveList, 16, TextileFileVersion, MainImageForm->Number); // 5->16 END_LOG; fail: return bReturn; } // --------------------------------------------------------------------------- /// TVecMotive¸¦ LoadÇÏ´Â ÇÔ¼ö /** TVecMotive¸¦ LoadÇÔ. Bitmap°ú MotiveListÀÇ Vector, Á¡(First,Second)À» ºÒ·¯¿È. */ bool __fastcall TVecMotive::LoadFromFile(HANDLE fh, int version) { BEGIN_LOG(""); DWORD dwRead; bool bReturn = true, isVector; bReturn = Bitmap->LoadFromTexpiaFile(fh, cmZLib); if (!bReturn) goto fail; if (!ReadFile(fh, &First, sizeof(POINT), &dwRead, NULL)) { bReturn = false; goto fail; } if (!ReadFile(fh, &Second, sizeof(POINT), &dwRead, NULL)) { bReturn = false; goto fail; } if (!ReadFile(fh, &isVector, sizeof(bool), &dwRead, NULL)) goto fail; bReturn = VecDraw->LoadFromFile(fh, MotiveList); END_LOG; fail: return bReturn; } // --------------------------------------------------------------------------- /// TVecMotive¿¡ TVecData¸¦ Ãß°¡ÇÏ´Â ÇÔ¼ö /** ÇØ´ç Vector¸¦ º¹»çÇÏ¿©, TVecMotiveÀÇ MotiveList¿¡ Ãß°¡Çϰí, First, Second¸¦ ´Ù½Ã °è»êÇØÁÜ. */ void __fastcall TVecMotive::AddVecData(TVecData *Item) { TVecData *data = new TVecData(MainImageForm->Number); data->Copy(Item); MotiveList->Add(data); First.x = First.x > data->First.x ? data->First.x : First.x; First.y = First.y > data->First.y ? data->First.y : First.y; Second.x = Second.x < data->Second.x ? data->Second.x : Second.x; Second.y = Second.y < data->Second.y ? data->Second.y : Second.y; } // --------------------------------------------------------------------------- /// TVecMotive ÀÇ Image¸¦ ¸¸µå´Â ÇÔ¼ö /** TVecMotiveÀÇ MotiveList¿¡ ¼ÓÇÏ´Â TVecDataÀÇ Bounding Rect¸¦ Àâ¾Æ¼­ vectorµéÀ» bitmap¿¡ ÀúÀåÇÔ. (TVecMotiveList_F¿¡¼­ º¸¿©Áö´Â bitmapÀÌ´Ù.) */ void __fastcall TVecMotive::MakeIconImage() { BEGIN_LOG(""); HDC dc = Bitmap->CreateDC(); int w = Second.x - First.x; int h = Second.y - First.y; int gap; if (w >= h) { gap = w - h; First.x = First.x - w / 2; Second.x = Second.x + w / 2; First.y = First.y - h / 2 - gap; Second.y = Second.y + h / 2 + gap; } else { gap = h - w; First.x = First.x - w / 2 - gap; Second.x = Second.x + w / 2 + gap; First.y = First.y - h / 2; Second.y = Second.y + h / 2; } TRect src = TRect(First.x, First.y, Second.x, Second.y); VecDraw->TagDraw(dc, Bitmap->Width, Bitmap->Height, src, 1, MotiveList); Bitmap->DeleteDC(dc); END_LOG; } // --------------------------------------------------------------------------- // todo: TBezierPointList // --------------------------------------------------------------------------- __fastcall TBezierPointList::TBezierPointList() { CurrentIndex = 0; Data = NULL; InputBezierPointList = new TList; ResultBezierPointList = new TList; } // --------------------------------------------------------------------------- __fastcall TBezierPointList::~TBezierPointList() { BEGIN_LOG(""); TPointList *tempPointList = NULL; if (InputBezierPointList) { for (int i = 0; i < InputBezierPointList->Count; i++) { tempPointList = (TPointList*)InputBezierPointList->Items[i]; if (tempPointList) delete tempPointList; tempPointList = NULL; } InputBezierPointList->Clear(); delete InputBezierPointList; InputBezierPointList = NULL; } if (ResultBezierPointList) { for (int i = 0; i < ResultBezierPointList->Count; i++) { tempPointList = (TPointList*)ResultBezierPointList->Items[i]; if (tempPointList) delete tempPointList; tempPointList = NULL; } ResultBezierPointList->Clear(); delete ResultBezierPointList; ResultBezierPointList = NULL; } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TBezierPointList::Init(TVecData *data) { double First, Second, Third; double Divisor; double value; Clear(); Data = data; pTemp = Data->pList; for (int i = 0; i < Data->nCount; i++) { First = GetLength(&pTemp[i * 3], &pTemp[i * 3 + 1]); Second = GetLength(&pTemp[i * 3 + 1], &pTemp[i * 3 + 2]); Third = GetLength(&pTemp[i * 3 + 2], &pTemp[i * 3 + 3]); /* Divisor = (First+Second+Third)*10; for(int j=0;j<=30;j++) { switch(j/10) { case 0: InputAdd(i,First*j/Divisor); break; case 1: InputAdd(i,(First*10+Second*(j%10))/Divisor); break; case 2: InputAdd(i,(First*10+Second*10+Third*(j%10))/Divisor); break; case 3: InputAdd(i,1.0); break; } } */ // --> by linuxjun for CurvedVectorText ´ÜÀ§¸¦ 40À¸·Î ¿Ã¸² Divisor = (First + Second + Third) * 40; if (Divisor == 0) Divisor = 1; // division by zero ó¸® - by monkman (2012.01.16) for (int j = 0; j <= 120; j++) { switch(j / 40) { case 0: // InputBezierPointList->Add(i,First*j/Divisor); InputAdd(i, First * j / Divisor); break; case 1: // InputBezierPointList->Add(i,(First*10+Second*(j%10))/Divisor); InputAdd(i, (First * 40 + Second * (j % 40)) / Divisor); break; case 2: // InputBezierPointList->Add(i,(First*10+Second*10+Third*(j%10))/Divisor); InputAdd(i, (First * 40 + Second * 40 + Third * (j % 40)) / Divisor); break; case 3: // InputBezierPointList->Add(i,(First*10+Second*10+Third*(j%10))/Divisor); InputAdd(i, 1.0); break; } } // <-- by linuxjun for CurvedVectorText ´ÜÀ§¸¦ 40À¸·Î ¿Ã¸² } } // --------------------------------------------------------------------------- double __fastcall TBezierPointList::GetPartialLength(LengthPOINT *sp, LengthPOINT *ep) { double x, y; x = sp->px - ep->px; y = sp->py - ep->py; // --> by linuxjun for CurvedVectorText if (IsNan(x) || IsNan(x) || IsNan(y) || IsNan(y)) { return 0; } try { return sqrt(x * x + y * y); } catch(...) { return 0; } // <-- by linuxjun for CurvedVectorText } // --------------------------------------------------------------------------- // LengthList¿¡´Â double Çü Pointer List¸¦ ³Ñ°ÜÁÖ±æ ¹Ù¶÷ TList * __fastcall TBezierPointList::Calculate(TVecData *data, TList* LengthList) { BEGIN_LOG(""); int i; double * pvalue; double SumLen = 0; double PartLen = 0; double ThresholdLen = 0; double temp; Init(data); TList *retList = NULL; i = 0; if (i < LengthList->Count) { pvalue = (double*)LengthList->Items[i++]; ThresholdLen += *pvalue; } else { retList = ReturnBezierPointList(); END_LOG; return retList; } // ÃʱâÈ­ InFirst(); CurrentPt = InCurrentPt(); if (CurrentPt == NULL) { retList = ReturnBezierPointList(); // ¿¡·¯Çڵ鸵 END_LOG; return retList; } InNext(); for (; !InIsDone(); InNext()) { // Áö±Ý±îÁöÀÇ ±æÀ̰¡ Threshold¸¦ ³Ñ¾î°¡Áö ¾ÊÀ¸¸é ´Ù½Ã ´õÇÔ. PrevPt = CurrentPt; CurrentPt = InCurrentPt(); if (CurrentPt == NULL) { retList = ReturnBezierPointList(); // ¿¡·¯Çڵ鸵 END_LOG; return retList; } PartLen = GetPartialLength(PrevPt, CurrentPt); SumLen += PartLen; if (SumLen < ThresholdLen) continue; if (PartLen <= 0) continue; // ¿¡·¯ Çڵ鸵À» À§ÇÔ. while (SumLen >= ThresholdLen) { // --->°á°ú Á¡ Ãß°¡ÇØÁÖ´Â ºÎºÐ if (PrevPt->SegmentNum == CurrentPt->SegmentNum) { ResultAdd(CurrentPt->SegmentNum, PrevPt->t + (CurrentPt->t - PrevPt->t) * (PartLen - (SumLen - ThresholdLen)) / PartLen); } else { temp = PrevPt->t + (1.0 + CurrentPt->t - PrevPt->t) * (PartLen - (SumLen - ThresholdLen)) / PartLen; if (temp >= 1.0) { ResultAdd(CurrentPt->SegmentNum, temp - 1.0); } else { ResultAdd(PrevPt->SegmentNum, temp); } } // <---°á°ú Á¡ Ãß°¡ÇØÁÖ´Â ºÎºÐ if (i < LengthList->Count) { pvalue = (double*)LengthList->Items[i++]; ThresholdLen += *pvalue; } else { retList = ReturnBezierPointList(); END_LOG; return retList; } } } retList = ReturnBezierPointList(); END_LOG; return retList; } // --------------------------------------------------------------------------- TList * __fastcall TBezierPointList::Calculate(TVecData *data, double interval) { BEGIN_LOG(""); int i; double * pvalue; double SumLen = 0; double PartLen = 0; double ThresholdLen = 0; double temp; Init(data); TList *retList = NULL; i = 0; /* if(iCount) { pvalue = (double *)LengthList->Items[i++]; ThresholdLen += *pvalue; }else{ return ReturnBezierPointList(); } */ ThresholdLen += interval; // ÃʱâÈ­ InFirst(); CurrentPt = InCurrentPt(); if (CurrentPt == NULL) { retList = ReturnBezierPointList(); // ¿¡·¯Çڵ鸵 END_LOG; return retList; } InNext(); for (; !InIsDone(); InNext()) { // Áö±Ý±îÁöÀÇ ±æÀ̰¡ Threshold¸¦ ³Ñ¾î°¡Áö ¾ÊÀ¸¸é ´Ù½Ã ´õÇÔ. PrevPt = CurrentPt; CurrentPt = InCurrentPt(); if (CurrentPt == NULL) { retList = ReturnBezierPointList(); // ¿¡·¯Çڵ鸵 END_LOG; return retList; } PartLen = GetPartialLength(PrevPt, CurrentPt); SumLen += PartLen; if (SumLen < ThresholdLen) continue; if (PartLen <= 0) continue; // ¿¡·¯ Çڵ鸵À» À§ÇÔ. while (SumLen >= ThresholdLen) { // --->°á°ú Á¡ Ãß°¡ÇØÁÖ´Â ºÎºÐ if (PrevPt->SegmentNum == CurrentPt->SegmentNum) { ResultAdd(CurrentPt->SegmentNum, PrevPt->t + (CurrentPt->t - PrevPt->t) * (PartLen - (SumLen - ThresholdLen)) / PartLen); } else { temp = PrevPt->t + (1.0 + CurrentPt->t - PrevPt->t) * (PartLen - (SumLen - ThresholdLen)) / PartLen; if (temp >= 1.0) { ResultAdd(CurrentPt->SegmentNum, temp - 1.0); } else { ResultAdd(PrevPt->SegmentNum, temp); } } // <---°á°ú Á¡ Ãß°¡ÇØÁÖ´Â ºÎºÐ /* if(iCount) { pvalue = (double *)LengthList->Items[i++]; ThresholdLen += *pvalue; }else{ return ReturnBezierPointList(); } */ ThresholdLen += interval; } } retList = ReturnBezierPointList(); END_LOG; return retList; } // --------------------------------------------------------------------------- TList * __fastcall TBezierPointList::Calculate(TVecData *data, int nCount) { BEGIN_LOG(""); int i; double * pvalue; double SumLen = 0; double PartLen = 0; double ThresholdLen = 0; int ThresholdNum = 0; double TotalLen = 0; double temp; Init(data); TList *retList = NULL; i = 0; /* if(iCount) { pvalue = (double *)LengthList->Items[i++]; ThresholdLen += *pvalue; }else{ return ReturnBezierPointList(); } */ TotalLen = GetCurveLength(); if (TotalLen <= 0) { END_LOG; return NULL; } ThresholdNum++; ThresholdLen = ThresholdNum * TotalLen / nCount; // ÃʱâÈ­ InFirst(); CurrentPt = InCurrentPt(); if (CurrentPt == NULL) { retList = ReturnBezierPointList(); // ¿¡·¯Çڵ鸵 END_LOG; return retList; } InNext(); for (; !InIsDone(); InNext()) { // Áö±Ý±îÁöÀÇ ±æÀ̰¡ Threshold¸¦ ³Ñ¾î°¡Áö ¾ÊÀ¸¸é ´Ù½Ã ´õÇÔ. PrevPt = CurrentPt; CurrentPt = InCurrentPt(); if (CurrentPt == NULL) { retList = ReturnBezierPointList(); // ¿¡·¯Çڵ鸵 END_LOG; return retList; } PartLen = GetPartialLength(PrevPt, CurrentPt); SumLen += PartLen; if (SumLen < ThresholdLen) continue; if (PartLen <= 0) continue; // ¿¡·¯ Çڵ鸵À» À§ÇÔ. while (SumLen >= ThresholdLen) { // --->°á°ú Á¡ Ãß°¡ÇØÁÖ´Â ºÎºÐ if (PrevPt->SegmentNum == CurrentPt->SegmentNum) { ResultAdd(CurrentPt->SegmentNum, PrevPt->t + (CurrentPt->t - PrevPt->t) * (PartLen - (SumLen - ThresholdLen)) / PartLen); } else { temp = PrevPt->t + (1.0 + CurrentPt->t - PrevPt->t) * (PartLen - (SumLen - ThresholdLen)) / PartLen; if (temp >= 1.0) { ResultAdd(CurrentPt->SegmentNum, temp - 1.0); } else { ResultAdd(PrevPt->SegmentNum, temp); } } // <---°á°ú Á¡ Ãß°¡ÇØÁÖ´Â ºÎºÐ /* if(iCount) { pvalue = (double *)LengthList->Items[i++]; ThresholdLen += *pvalue; }else{ return ReturnBezierPointList(); } */ ThresholdNum++; if (ThresholdNum == nCount) { ThresholdLen = TotalLen; } else { ThresholdLen = ThresholdNum * TotalLen / nCount; } } } retList = ReturnBezierPointList(); END_LOG; return retList; } // --------------------------------------------------------------------------- double __fastcall TBezierPointList::GetCurveLength() { BEGIN_LOG(""); int i; double * pvalue; double SumLen = 0; double PartLen = 0; double ThresholdLen = 0; double temp; // Init(data); i = 0; // ÃʱâÈ­ InFirst(); CurrentPt = InCurrentPt(); if (CurrentPt == NULL) { END_LOG; return 0.0; // ¿¡·¯Çڵ鸵 } InNext(); for (; !InIsDone(); InNext()) { // Áö±Ý±îÁöÀÇ ±æÀ̰¡ Threshold¸¦ ³Ñ¾î°¡Áö ¾ÊÀ¸¸é ´Ù½Ã ´õÇÔ. PrevPt = CurrentPt; CurrentPt = InCurrentPt(); if (CurrentPt == NULL) { END_LOG; return SumLen; // ¿¡·¯Çڵ鸵 } PartLen = GetPartialLength(PrevPt, CurrentPt); SumLen += PartLen; // if(PartLen<=0)continue; //¿¡·¯ Çڵ鸵À» À§ÇÔ. } END_LOG; return SumLen; } // --------------------------------------------------------------------------- TList * __fastcall TBezierPointList::ReturnBezierPointList() { return ResultBezierPointList; /* LengthPOINT * TempLenPt; DPOINT * TempDPt; TList * ResultList = new TList; for(ReFirst();!ReIsDone();ReNext()) { TempLenPt = ReCurrentPt(); if(TempLenPt==NULL)return ResultList; TempDPt = new DPOINT; ResultList->Add(TempDPt); } return ResultList; */ } // --------------------------------------------------------------------------- double __fastcall TBezierPointList::GetPointPX(int n, double d) { double x0, x1, x2, x3; double result; x0 = pTemp[n * 3].x; x1 = pTemp[n * 3 + 1].x; x2 = pTemp[n * 3 + 2].x; x3 = pTemp[n * 3 + 3].x; result = (1 - d) * (1 - d) * (1 - d) * x0 + 3 * (1 - d) * (1 - d) * d * x1 + 3 * (1 - d) * d * d * x2 + d * d * d * x3; return result; } // --------------------------------------------------------------------------- double __fastcall TBezierPointList::GetPointPY(int n, double d) { double y0, y1, y2, y3; double result; y0 = pTemp[n * 3].y; y1 = pTemp[n * 3 + 1].y; y2 = pTemp[n * 3 + 2].y; y3 = pTemp[n * 3 + 3].y; result = (1 - d) * (1 - d) * (1 - d) * y0 + 3 * (1 - d) * (1 - d) * d * y1 + 3 * (1 - d) * d * d * y2 + d * d * d * y3; return result; } // --------------------------------------------------------------------------- double __fastcall TBezierPointList::GetPointTX(int n, double d) { double x0, x1, x2, x3; double y0, y1, y2, y3; double result; double resultx; double resulty; x0 = pTemp[n * 3].x; x1 = pTemp[n * 3 + 1].x; x2 = pTemp[n * 3 + 2].x; x3 = pTemp[n * 3 + 3].x; y0 = pTemp[n * 3].y; y1 = pTemp[n * 3 + 1].y; y2 = pTemp[n * 3 + 2].y; y3 = pTemp[n * 3 + 3].y; // Differentiation resultx = -3 * (1 - d) * (1 - d) * x0 + 3 * (3 * d - 1) * (d - 1) * x1 - 3 * d * (3 * d - 2) * x2 + 3 * d * d * x3; resulty = -3 * (1 - d) * (1 - d) * y0 + 3 * (3 * d - 1) * (d - 1) * y1 - 3 * d * (3 * d - 2) * y2 + 3 * d * d * y3; double Len = sqrt((resultx * resultx) + (resulty * resulty)); // for normalize // -->by linuxjun for CurvedVectorText if (Len > 0) { result = resultx / Len; return result; } else { if (d <= 0.0001) { return GetPointTX(n, 0.0001); } else if (d >= 0.9999) { return GetPointTX(n, 0.9999); } else { return GetPointTX(n, d - 0.00001); } } // <--by linuxjun for CurvedVectorText } // --------------------------------------------------------------------------- double __fastcall TBezierPointList::GetPointTY(int n, double d) { double x0, x1, x2, x3; double y0, y1, y2, y3; double result; double resultx; double resulty; x0 = pTemp[n * 3].x; x1 = pTemp[n * 3 + 1].x; x2 = pTemp[n * 3 + 2].x; x3 = pTemp[n * 3 + 3].x; y0 = pTemp[n * 3].y; y1 = pTemp[n * 3 + 1].y; y2 = pTemp[n * 3 + 2].y; y3 = pTemp[n * 3 + 3].y; // Differentiation resultx = -3 * (1 - d) * (1 - d) * x0 + 3 * (3 * d - 1) * (d - 1) * x1 - 3 * d * (3 * d - 2) * x2 + 3 * d * d * x3; resulty = -3 * (1 - d) * (1 - d) * y0 + 3 * (3 * d - 1) * (d - 1) * y1 - 3 * d * (3 * d - 2) * y2 + 3 * d * d * y3; double Len = sqrt((resultx * resultx) + (resulty * resulty)); // for normalize // -->by linuxjun for CurvedVectorText if (Len > 0) { result = resulty / Len; return result; } else { if (d <= 0.0001) { return GetPointTY(n, 0.0001); } else if (d >= 0.9999) { return GetPointTY(n, 0.9999); } else { return GetPointTY(n, d - 0.00001); } } // <--by linuxjun for CurvedVectorText } // --------------------------------------------------------------------------- double __fastcall TBezierPointList::GetPointNX(int n, double d) { return -GetPointTY(n, d); } // --------------------------------------------------------------------------- double __fastcall TBezierPointList::GetPointNY(int n, double d) { return GetPointTX(n, d); } // --------------------------------------------------------------------------- double __fastcall TBezierPointList::GetLength(DPOINT *p1, DPOINT *p2) { long double x, y, nValue; x = p1->x - p2->x; y = p1->y - p2->y; nValue = x * x + y * y; // sqrt domain Error ¼öÁ¤ - by monkman (2009.04.28) if (nValue >= 0) { return sqrt(nValue); } else { return -sqrt(-nValue); } } // --------------------------------------------------------------------------- void __fastcall TBezierPointList::InputAdd(int n, double d) { TPointList *tempPointList; DPOINT *temp; while (n >= InputBezierPointList->Count) { InputBezierPointList->Add(new TPointList()); } tempPointList = (TPointList*)InputBezierPointList->Items[n]; tempPointList->Add(n, d, GetPointPX(n, d), GetPointPY(n, d), 0, 0, 0, 0); } // --------------------------------------------------------------------------- void __fastcall TBezierPointList::ResultAdd(int n, double d) { BEGIN_LOG(""); TPointList *tempPointList; DPOINT *temp; while (n >= ResultBezierPointList->Count) { ResultBezierPointList->Add(new TPointList()); } tempPointList = (TPointList*)ResultBezierPointList->Items[n]; tempPointList->Add(n, d, GetPointPX(n, d), GetPointPY(n, d), GetPointTX(n, d), GetPointTY(n, d), GetPointNX(n, d), GetPointNY(n, d)); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TBezierPointList::Clear() { BEGIN_LOG(""); TPointList * Temp; while (InputBezierPointList->Count) { Temp = (TPointList*)InputBezierPointList->Last(); InputBezierPointList->Remove(Temp); delete Temp; Temp = NULL; } while (ResultBezierPointList->Count) { Temp = (TPointList*)ResultBezierPointList->Last(); ResultBezierPointList->Remove(Temp); delete Temp; Temp = NULL; } CurrentIndex = 0; // InputBezierPointList->Clear(); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TBezierPointList::InFirst() { BEGIN_LOG(""); TPointList *tempPointList; for (int i = 0; i < InputBezierPointList->Count; i++) { tempPointList = (TPointList*)InputBezierPointList->Items[i]; tempPointList->First(); } CurrentIndex = 0; END_LOG; } // --------------------------------------------------------------------------- void __fastcall TBezierPointList::InNext() { BEGIN_LOG(""); TPointList *tempPointList; if (CurrentIndex < InputBezierPointList->Count) { tempPointList = (TPointList*)InputBezierPointList->Items[CurrentIndex]; tempPointList->Next(); if (tempPointList->IsDone()) { CurrentIndex++; if (CurrentIndex < InputBezierPointList->Count) { tempPointList = (TPointList*)InputBezierPointList->Items[CurrentIndex]; tempPointList->First(); } else { CurrentIndex--; } } } END_LOG; } // --------------------------------------------------------------------------- bool __fastcall TBezierPointList::InIsDone() { BEGIN_LOG(""); TPointList *tempPointList; if (CurrentIndex == InputBezierPointList->Count - 1) { tempPointList = (TPointList*)InputBezierPointList->Items[CurrentIndex]; END_LOG; return tempPointList->IsDone(); } END_LOG; return false; } // --------------------------------------------------------------------------- double __fastcall TBezierPointList::InCurrentItem() { BEGIN_LOG(""); TPointList *tempPointList; double retValue = 0.0; if (CurrentIndex < InputBezierPointList->Count) { tempPointList = (TPointList*)InputBezierPointList->Items[CurrentIndex]; retValue = ((LengthPOINT*)tempPointList->CurrentPt())->t; END_LOG; return retValue; } END_LOG; return 1.0; } // --------------------------------------------------------------------------- LengthPOINT * __fastcall TBezierPointList::InCurrentPt() { BEGIN_LOG(""); TPointList *tempPointList; LengthPOINT *retValue = NULL; if (CurrentIndex < InputBezierPointList->Count) { tempPointList = (TPointList*)InputBezierPointList->Items[CurrentIndex]; retValue = tempPointList->CurrentPt(); END_LOG; return retValue; } END_LOG; return NULL; // tempPointList = (TPointList *)InputBezierPointList->Last(); // return tempPointList->Last(); } // --------------------------------------------------------------------------- void __fastcall TBezierPointList::ReFirst() { BEGIN_LOG(""); TPointList *tempPointList; for (int i = 0; i < ResultBezierPointList->Count; i++) { tempPointList = (TPointList*)ResultBezierPointList->Items[i]; tempPointList->First(); } ResultCurrentIndex = 0; END_LOG; } // --------------------------------------------------------------------------- void __fastcall TBezierPointList::ReNext() { BEGIN_LOG(""); TPointList *tempPointList; if (ResultCurrentIndex < ResultBezierPointList->Count) { tempPointList = (TPointList*) ResultBezierPointList->Items[ResultCurrentIndex]; tempPointList->Next(); if (tempPointList->IsDone()) { ResultCurrentIndex++; if (ResultCurrentIndex < ResultBezierPointList->Count) { tempPointList = (TPointList*) ResultBezierPointList->Items[ResultCurrentIndex]; tempPointList->First(); } else { ResultCurrentIndex--; } } } END_LOG; } // --------------------------------------------------------------------------- bool __fastcall TBezierPointList::ReIsDone() { BEGIN_LOG(""); TPointList *tempPointList; bool retValue = false; if (ResultCurrentIndex == ResultBezierPointList->Count - 1) { tempPointList = (TPointList*) ResultBezierPointList->Items[ResultCurrentIndex]; retValue = tempPointList->IsDone(); END_LOG; return retValue; } END_LOG; return false; } // --------------------------------------------------------------------------- double __fastcall TBezierPointList::ReCurrentItem() { BEGIN_LOG(""); TPointList *tempPointList; bool retValue = false; if (ResultCurrentIndex < ResultBezierPointList->Count) { tempPointList = (TPointList*) ResultBezierPointList->Items[ResultCurrentIndex]; retValue = tempPointList->CurrentDouble(); END_LOG; return retValue; } END_LOG; return 1.0; } // --------------------------------------------------------------------------- LengthPOINT * __fastcall TBezierPointList::ReCurrentPt() { BEGIN_LOG(""); TPointList *tempPointList; LengthPOINT *retValue = NULL; if (ResultCurrentIndex < ResultBezierPointList->Count) { tempPointList = (TPointList*) ResultBezierPointList->Items[ResultCurrentIndex]; retValue = tempPointList->CurrentPt(); END_LOG; return retValue; } END_LOG; return NULL; // tempPointList = (TPointList *)ResultBezierPointList->Last(); // return tempPointList->Last(); } // --------------------------------------------------------------------------- double __fastcall GetLength(POINT *p1, POINT *p2) { int x, y; x = p1->x - p2->x; y = p1->y - p2->y; return sqrt(x * x + y * y); } // --------------------------------------------------------------------------- double __fastcall GetSpeed(POINT *p1, POINT *p2) { int x, y; x = p1->x - p2->x; y = p1->y - p2->y; return 3 * sqrt(x * x + y * y); } // --------------------------------------------------------------------------- double __fastcall GetElapsedValue(POINT *pTemp, int Interval) { return 0.0; } // --------------------------------------------------------------------------- double __fastcall GetControlPTLength(POINT *pTemp, int i) { double Sum = 0; Sum += GetLength(&pTemp[i * 3], &pTemp[i * 3 + 1]); Sum += GetLength(&pTemp[i * 3 + 1], &pTemp[i * 3 + 2]); Sum += GetLength(&pTemp[i * 3 + 2], &pTemp[i * 3 + 3]); return Sum; } // --------------------------------------------------------------------------- DPOINT __fastcall TVecDraw::FindingPointOnBezier(DPOINT *pt, double t) { if (t <= 0.0) t = 0.001; if (t >= 1.0) t = 0.999; DPOINT result; result.x = (1 - t) * (1 - t) * (1 - t) * pt[0].x + 3 * t * (t - 1) * (t - 1) * pt[1].x - 3 * t * t * (t - 1) * pt[2].x + t * t * t * pt[3].x; result.y = (1 - t) * (1 - t) * (1 - t) * pt[0].y + 3 * t * (t - 1) * (t - 1) * pt[1].y - 3 * t * t * (t - 1) * pt[2].y + t * t * t * pt[3].y; return result; } // --------------------------------------------------------------------------- double __fastcall TVecDraw::FindCurveTangent(DPOINT *pt, double t) // by embakum ¸ðƼºê ¹Ýº¹ 2009.02.10 { if (t <= 0.0) t = 0.001; if (t >= 1.0) t = 0.999; DPOINT result, temp_p; // ¹ÌºÐ °á°ú temp_p.x = -3 * (1 - t) * (1 - t) * pt[0].x + 3 * (3 * t - 1) * (t - 1) * pt[1].x - 3 * t * (3 * t - 2) * pt[2].x + 3 * t * t * pt[3].x; temp_p.y = -3 * (1 - t) * (1 - t) * pt[0].y + 3 * (3 * t - 1) * (t - 1) * pt[1].y - 3 * t * (3 * t - 2) * pt[2].y + 3 * t * t * pt[3].y; return ArcTan2(temp_p.y, temp_p.x); } // --------------------------------------------------------------------------- DPOINT __fastcall TVecDraw::FindingNormalOnBezier(DPOINT *pt, double t, double dSize, bool odd) { if (t <= 0.0) t = 0.001; if (t >= 1.0) t = 0.999; DPOINT result, temp_p; // ¹ÌºÐ °á°ú temp_p.x = -3 * (1 - t) * (1 - t) * pt[0].x + 3 * (3 * t - 1) * (t - 1) * pt[1].x - 3 * t * (3 * t - 2) * pt[2].x + 3 * t * t * pt[3].x; temp_p.y = -3 * (1 - t) * (1 - t) * pt[0].y + 3 * (3 * t - 1) * (t - 1) * pt[1].y - 3 * t * (3 * t - 2) * pt[2].y + 3 * t * t * pt[3].y; double e = sqrt((temp_p.x * temp_p.x) + (temp_p.y * temp_p.y)); // for normalize temp_p.x = temp_p.x * dSize / e; temp_p.y = temp_p.y * dSize / e; // ¿ø À§Ä¡ result.x = (1 - t) * (1 - t) * (1 - t) * pt[0].x + 3 * t * (t - 1) * (t - 1) * pt[1].x - 3 * t * t * (t - 1) * pt[2].x + t * t * t * pt[3].x; result.y = (1 - t) * (1 - t) * (1 - t) * pt[0].y + 3 * t * (t - 1) * (t - 1) * pt[1].y - 3 * t * t * (t - 1) * pt[2].y + t * t * t * pt[3].y; if (odd) { result.x += temp_p.y; result.y -= temp_p.x; } else { result.x -= temp_p.y; result.y += temp_p.x; } return result; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::ConvertZigZag(TVecData *tData, double dSize, int nSegment, int nType, double dCtlptLen) { BEGIN_LOG(""); double dInterval; TPointList *tempPointList; TBezierPointList * BezierPointList = new TBezierPointList(); // »ý¼º TList * ResultBezierPointList = NULL; DPOINT firstPoint, onPoint, normalPoint, tempCurpt, tempOldpt; DPOINT controlpt_tan, fir_controlpt_tan; DPOINT *pTempList; DPOINT temppt; int count = 1; double x, y, control_Len; bool odd; double tempOld_len; DPOINT tempOld_tan; double st, ed; tempOld_tan.x = 0; tempOld_tan.y = 0; tempOld_len = 0; fir_controlpt_tan.x = 0; fir_controlpt_tan.y = 0; controlpt_tan.x = 0; controlpt_tan.y = 0; if (!tData->bClosed) nSegment++; else if ((tData->bClosed) && (nSegment % 2 == 1)) nSegment++; // ´ÝÈù ¿ÀºêÁ§Æ®¿¡¼­´Â ½ÃÀÛÁ¡°ú À§Ä¡ ¸Âµµ·Ï ¦¼ö°³·Î ¸ÂÃã. // ´ÝÈù ¿ÀºêÁ§Æ®´Â ù Á¡À» µû·Î ³Ö¾îÁÖÁö ¾Ê¾Æµµ »ó°ü¾øÁö¸¸ // ¿­¸° ¿ÀºêÁ§Æ®ÀÇ °æ¿ì ù Á¡ÀÌ ÇÊ¿äÇÔ. // ù Á¡Àº ResultBezierPointList¿¡ Æ÷ÇÔµÇÁö ¾ÊÀ¸¹Ç·Î ³Ö¾îÁØ´Ù. switch(nType) { case 0: // Smooth : ÄÁÆ®·Ñ Æ÷ÀÎÆ®ÀÇ À§Ä¡ °è»ê ÇÊ¿ä ResultBezierPointList = BezierPointList->Calculate(tData, nSegment); if (!ResultBezierPointList) goto fail; pTempList = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * (nSegment * 3 + 1)); firstPoint = FindingNormalOnBezier(&tData->pList[0], 0, dSize, 0); pTempList[0].x = firstPoint.x; pTempList[0].y = firstPoint.y; pTempList[1].x = firstPoint.x; pTempList[1].y = firstPoint.y; for (int i = 0; i < ResultBezierPointList->Count; i++) { tempPointList = (TPointList*)ResultBezierPointList->Items[i]; for (tempPointList->First(); !tempPointList->IsDone(); tempPointList->Next()) { dInterval = tempPointList->CurrentDouble(); // BezierCurve À§ÀÇ Á¡À§Ä¡ // onPoint = FindingPointOnBezier(&tData->pList[i*3], dInterval); // ãÀº Á¡ÀÇ NormalÀÇ À§Ä¡ (ãÀº Á¡Àº ResultBezierPointList¾È¿¡ ÀÖÀ½) normalPoint = FindingNormalOnBezier(&tData->pList[i * 3], dInterval, dSize, count % 2); controlpt_tan.x = tempPointList->CurrentPt()->tx; controlpt_tan.y = tempPointList->CurrentPt()->ty; tempCurpt.x = tempPointList->CurrentPt()->px; tempCurpt.y = tempPointList->CurrentPt()->py; if (controlpt_tan.x < -1) controlpt_tan.x = tempOld_tan.x; if (controlpt_tan.y < -1) controlpt_tan.y = tempOld_tan.y; if (count == 1) { x = tempCurpt.x - firstPoint.x; // ÀÓ½Ã. ÀÌÀü Á¡ÀÌ ¾øÀ¸¹Ç·Î ÄÁÆ®·Ñ Æ÷ÀÎÆ®ÀÇ ±æÀÌ ¸ÂÁö ¾ÊÀ½. y = tempCurpt.y - firstPoint.y; fir_controlpt_tan.x = controlpt_tan.x; fir_controlpt_tan.y = controlpt_tan.y; } else { x = tempCurpt.x - tempOldpt.x; y = tempCurpt.y - tempOldpt.y; } control_Len = sqrt(x * x + y * y) * dCtlptLen; // ÄÁÆ®·Ñ Æ÷ÀÎÆ®ÀÇ ±æÀÌ if (control_Len == 0) control_Len = tempOld_len; if (count == 2) { pTempList[1].x = pTempList[0].x + fir_controlpt_tan.x * control_Len; pTempList[1].y = pTempList[0].y + fir_controlpt_tan.y * control_Len; pTempList[2].x = pTempList[3].x - fir_controlpt_tan.x * control_Len; pTempList[2].y = pTempList[3].y - fir_controlpt_tan.y * control_Len; } pTempList[count * 3 - 2].x = pTempList[count * 3 - 3] .x + controlpt_tan.x * control_Len; pTempList[count * 3 - 2].y = pTempList[count * 3 - 3] .y + controlpt_tan.y * control_Len; pTempList[count * 3 - 1].x = normalPoint.x - controlpt_tan.x * control_Len; pTempList[count * 3 - 1].y = normalPoint.y - controlpt_tan.y * control_Len; pTempList[count * 3].x = normalPoint.x; pTempList[count * 3].y = normalPoint.y; count++; tempOldpt = tempCurpt; tempOld_tan = controlpt_tan; tempOld_len = control_Len; } } if (tData->bClosed) { // ´ÝÈù ¿ÀºêÁ§Æ®ÀÇ °æ¿ì ³¡Á¡°ú ùÁ¡À» °°°Ô. pTempList[nSegment * 3] = pTempList[0]; if (fabs(pTempList[0].x - pTempList[1].x) > 0) { st = fabs(pTempList[0].y - pTempList[1].y) / fabs (pTempList[0].x - pTempList[1].x); } else st = 0; if (fabs(pTempList[nSegment * 3 - 1].x - pTempList[0].x) > 0) { ed = fabs(pTempList[nSegment * 3 - 1].y - pTempList[0].y) / fabs (pTempList[nSegment * 3 - 1].x - pTempList[0].x); } else ed = 0; if ((ed == 0) || (st >= ed)) { temppt.x = pTempList[0].x - (pTempList[nSegment * 3 - 1].x - pTempList[0].x); // ¿ø ÀÎ °æ¿ì temppt.y = pTempList[0].y - (pTempList[nSegment * 3 - 1].y - pTempList[0].y); pTempList[1] = temppt; } else { temppt.x = pTempList[0].x + (pTempList[0].x - pTempList[1].x); // »ç°¢ÇüÀÎ °æ¿ì temppt.y = pTempList[0].y + (pTempList[0].y - pTempList[1].y); pTempList[nSegment * 3 - 1] = temppt; } } // ½ÇÁ¦Á¡ÀÇ ´ÙÀ½ Á¡(ÄÁÆ®·Ñ Æ÷ÀÎÆ®)À» ½ÇÁ¦Á¡À» ±âÁØÀ¸·Î ÀÌÀüÁ¡(ÄÁÆ®·Ñ Æ÷ÀÎÆ®)°ú ´ëĪÀÌ µÇµµ·Ï. for (int i = 3; i < nSegment * 3; i += 3) { temppt.x = pTempList[i].x - (pTempList[i - 1].x - pTempList[i].x); temppt.y = pTempList[i].y - (pTempList[i - 1].y - pTempList[i].y); pTempList[i + 1] = temppt; } break; case 1: // Corner : ÄÁÆ®·Ñ Æ÷ÀÎÆ®¿Í ½ÇÁ¦Á¡ÀÇ À§Ä¡ °°À½ ResultBezierPointList = BezierPointList->Calculate(tData, nSegment); if (!ResultBezierPointList) goto fail; pTempList = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * (nSegment * 3 + 1)); firstPoint = FindingNormalOnBezier(&tData->pList[0], 0, dSize, 0); pTempList[0].x = firstPoint.x; pTempList[0].y = firstPoint.y; pTempList[1].x = firstPoint.x; pTempList[1].y = firstPoint.y; for (int i = 0; i < ResultBezierPointList->Count; i++) { tempPointList = (TPointList*)ResultBezierPointList->Items[i]; for (tempPointList->First(); !tempPointList->IsDone(); tempPointList->Next()) { dInterval = tempPointList->CurrentDouble(); // BezierCurve À§ÀÇ Á¡À§Ä¡ // onPoint = FindingPointOnBezier(&tData->pList[i*3], dInterval); // ãÀº Á¡ÀÇ NormalÀÇ À§Ä¡ (ãÀº Á¡Àº ResultBezierPointList¾È¿¡ ÀÖÀ½) normalPoint = FindingNormalOnBezier(&tData->pList[i * 3], dInterval, dSize, count % 2); pTempList[count * 3 - 2] = pTempList[count * 3 - 3]; pTempList[count * 3 - 1].x = normalPoint.x; pTempList[count * 3 - 1].y = normalPoint.y; pTempList[count * 3].x = normalPoint.x; pTempList[count * 3].y = normalPoint.y; count++; tempOldpt = tempCurpt; } } if (tData->bClosed) { // ´ÝÈù ¿ÀºêÁ§Æ®ÀÇ °æ¿ì ³¡Á¡°ú ùÁ¡À» °°°Ô. pTempList[nSegment * 3] = pTempList[0]; pTempList[nSegment * 3 - 1] = pTempList[0]; } break; case 2: // flower : ÄÁÆ®·Ñ Æ÷ÀÎÆ®¸¦ ½ÇÁ¦Á¡ÀÇ ¹Ý´ëÂÊ¿¡ À§Ä¡Çϵµ·Ï ÇÔ. ResultBezierPointList = BezierPointList->Calculate(tData, nSegment * 3); if (!ResultBezierPointList) goto fail; pTempList = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * (nSegment * 3 + 1)); firstPoint = FindingNormalOnBezier(&tData->pList[0], 0, dSize, 0); pTempList[0].x = firstPoint.x; pTempList[0].y = firstPoint.y; for (int i = 0; i < ResultBezierPointList->Count; i++) { tempPointList = (TPointList*)ResultBezierPointList->Items[i]; for (tempPointList->First(); !tempPointList->IsDone(); tempPointList->Next()) { dInterval = tempPointList->CurrentDouble(); normalPoint = FindingNormalOnBezier(&tData->pList[i * 3], dInterval, dSize, count % 2); // ãÀº Á¡ÀÇ NormalÀÇ À§Ä¡ pTempList[count] = normalPoint; count++; } } if (tData->bClosed) { pTempList[nSegment * 3] = pTempList[0]; } break; } // tDataÀÇ pList ¾ø¾Ú. if (tData->pList != NULL) { HeapFree(GetProcessHeap(), 0, tData->pList); tData->pList = NULL; } if (tData->pMask != NULL) { HeapFree(GetProcessHeap(), 0, tData->pMask); tData->pMask = NULL; } // »õ·Î pList¸¦ ¸¸µé¾î¼­ pTempList¸¦ ³ÖÀ½. tData->nCount = nSegment; tData->pList = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * (tData->nCount * 3 + 1)); memcpy(tData->pList, pTempList, sizeof(DPOINT) * (tData->nCount * 3 + 1)); tData->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, (tData->nCount * 3 + 1) % 8 == 0 ? (tData->nCount * 3 + 1) / 8 : (tData->nCount * 3 + 1) / 8 + 1); // Point MaskÃʱâÈ­ memset(tData->pMask, 0, (tData->nCount * 3 + 1) % 8 == 0 ? (tData->nCount * 3 + 1) / 8 : (tData->nCount * 3 + 1) / 8 + 1); if (pTempList != NULL) { HeapFree(GetProcessHeap(), 0, pTempList); pTempList = NULL; } delete BezierPointList; BezierPointList = NULL; // ¼Ò¸ê END_LOG; return; fail: delete BezierPointList; BezierPointList = NULL; // ¼Ò¸ê END_LOG; return; } // --------------------------------------------------------------------------- int __fastcall TVecDraw::CheckZigZag() { BEGIN_LOG(""); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ZigZag Line °ü·Ã - ZigZag°¡ °¡´ÉÇÑÁö CheckÇÑ´Ù - by monkman (2005.04.07) TList *DataList = NULL; TVecData *data = NULL; int nSelectedCount = 0; DataList = NVector->DataList; if (!(NVector->bSelected)) goto fail; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->bSelected) continue; if ((data->Kind == V_TEXT || data->Kind == V_TEXTBOX)) goto fail; // ¹®ÀÚÀÏ °æ¿ì´Â ¾ÈµÊ if (data->bClosed && (data->Second.x - data->First.x <= 2 || data->Second.y - data->First.y <= 2)) goto fail; // ¾ÆÁÖ ÀÛÀº ¿ÀºêÁ§Æ®À϶§µµ ¾ÈµÊ nSelectedCount++; } END_LOG; return nSelectedCount; fail: END_LOG; return 0; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } // --------------------------------------------------------------------------- int __fastcall TVecDraw::InitZigZag(int *nClosed) { BEGIN_LOG(""); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ZigZag Line °ü·Ã - ZigZag ÃʱâÈ­ - by monkman (2005.04.07) TList *DataList = NULL; TVecData *data = NULL, *backupdata = NULL; bool sw = true; // by linuxjun for Undo *nClosed = -1; bFirstZigZag = true; OldZigZagRect = Rect(MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height, 0, 0); DataList = NVector->DataList; if (!(NVector->bSelected)) goto fail; // BackUpList¸¦ ºñ¿î´Ù if (ZigZagBackUpList) { VecDataListDelete(ZigZagBackUpList); delete ZigZagBackUpList; ZigZagBackUpList = NULL; } ZigZagBackUpList = new TList; // ¼±ÅÃµÈ Object¸¦ BackUpList¿¡ BackUpÇÑ´Ù for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->bSelected) continue; if ((data->Kind == V_TEXT || data->Kind == V_TEXTBOX)) goto fail; // ¹®ÀÚÀÏ °æ¿ìµµ ¾ÈµÊ if ((backupdata = new TVecData(MainImageForm->Number)) == NULL) goto fail; backupdata->Copy(data); UndoSave(VU_MODIFY, i, sw); // by linuxjun for Undo sw = false; switch(*nClosed) { case -1 : if (!backupdata->bClosed) * nClosed = 0; else *nClosed = 1; break; case 0: if (backupdata->bClosed) * nClosed = 2; break; case 1: if (!backupdata->bClosed) * nClosed = 2; break; } ZigZagBackUpList->Add(backupdata); } END_LOG; return true; fail: END_LOG; return false; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } // --------------------------------------------------------------------------- bool __fastcall TVecDraw::RevertZigZag() { BEGIN_LOG(""); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ZigZag Line °ü·Ã - BackUpÇß´ø Vector·Î µÇµ¹¸² - by monkman (2005.04.07) TList *DataList = NULL; TVecData *data = NULL, *backupdata = NULL; int nBackUpListCount = 0; DataList = NVector->DataList; if (!(NVector->bSelected)) goto fail; if (ZigZagBackUpList == NULL || ZigZagBackUpList->Count <= 0) goto fail; // BackUpList¿¡ BackUpµÈ ¿øº» Object¸¦ ´Ù½Ã DataList·Î º¹»çÇÑ´Ù for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->bSelected) continue; if ((data->Kind == V_TEXT || data->Kind == V_TEXTBOX)) continue; backupdata = (TVecData*)ZigZagBackUpList->Items[nBackUpListCount]; data->Copy(backupdata); if (data->bPatternFill) { // PatternFillÀº °¡Áö°í ÀÖÁö ¾Ê´Â´Ù.. (¼Óµµ ¹®Á¦·Î..) if (data->TBitmap) { delete data->TBitmap; data->TBitmap = NULL; } if (data->TBitmapSource) { delete data->TBitmapSource; data->TBitmapSource = NULL; } if (data->MaskBitmap) { delete data->MaskBitmap; data->MaskBitmap = NULL; } } nBackUpListCount++; } END_LOG; return true; fail: END_LOG; return false; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } // --------------------------------------------------------------------------- void __fastcall TVecDraw::DrawZigZag(double dSize, int nSegment, int nType) { // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ZigZag Line °ü·Ã - by monkman (2005.04.07) TList *DataList = NULL; TVecData *data = NULL; RECT FirstSecondRect = Rect(MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height, 0, 0); // data->First, data->Second¸¦ À§ÇÑ Rect RECT CurrentRect = Rect(MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height, 0, 0); // ÇöÀç ¿µ¿ªÀ» °¡Áö°í ÀÖ´Ù RECT rc = Rect(MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height, 0, 0); // ½ÇÁ¦ ±×·ÁÁö´Â ¿µ¿ªÀ» °¡Áö°í ÀÖ´Ù DataList = NVector->DataList; double dCtlptLen = 0.5; RevertZigZag(); // BackUpÇß´ø Vector·Î µÇµ¹¸² // BackUpList¿¡ BackUpµÈ ¿øº» Object¸¦ ´Ù½Ã DataList·Î º¹»çÇÑ´Ù for (int i = 0; i < DataList->Count; i++) { FirstSecondRect = Rect(MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height, 0, 0); data = (TVecData*)DataList->Items[i]; if (!data->bSelected) continue; if ((data->Kind == V_TEXT || data->Kind == V_TEXTBOX)) continue; ConvertZigZag(data, dSize, nSegment, nType, dCtlptLen); // ¿©±â¼­ ZigZag¸¦ °è»êÇÑ´Ù for (int j = 0; j < data->nCount * 3 + 1; j++) { // data->First, data->Second¿¡ ´Þ¶óÁø ÁÂÇ¥°ªÀ» ±â·ÏÇϱâÀ§ÇØ ±¸ÇÑ´Ù FirstSecondRect.left = min(data->pList[j].x, FirstSecondRect.left); FirstSecondRect.top = min(data->pList[j].y, FirstSecondRect.top); FirstSecondRect.right = max(data->pList[j].x, FirstSecondRect.right); FirstSecondRect.bottom = max(data->pList[j].y, FirstSecondRect.bottom); CurrentRect.left = min(CurrentRect.left, FirstSecondRect.left - (data->PenThick * 2) - 5); // ½ÇÁ¦ ±×·ÁÁö´Â ºÎºÐÀ» °è»ê CurrentRect.top = min(CurrentRect.top, FirstSecondRect.top - (data->PenThick * 2) - 5); CurrentRect.right = max(CurrentRect.right, FirstSecondRect.right + (data->PenThick * 2) + 5); CurrentRect.bottom = max(CurrentRect.bottom, FirstSecondRect.bottom + (data->PenThick * 2) + 5); } data->First.x = FirstSecondRect.left; // data->First, data->Second¿¡ ´Þ¶óÁø ÁÂÇ¥°ªÀ» ±â·ÏÇÑ´Ù data->First.y = FirstSecondRect.top; data->Second.x = FirstSecondRect.right; data->Second.y = FirstSecondRect.bottom; } // ÀÌÀü ¿µ¿ªº¸´Ù ÀÛ¾ÆÁ³´Ù¸é ÀÌÀü °ªÀÇ ¿µ¿ªÀ¸·Î ÇÑ´Ù if (CurrentRect.left > OldZigZagRect.left || CurrentRect.top > OldZigZagRect.top || CurrentRect.right < OldZigZagRect.right || CurrentRect.bottom < OldZigZagRect.bottom) { rc = OldZigZagRect; } else { rc = CurrentRect; } // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - ¹ÝÀü °Å¿ïÀÇ º¤ÅÍ ¿µ¿ªÀ» °°ÀÌ ±¸ÇÑ´Ù - by monkman(2005.03.16) if (NVector->bVectorReflectionMode) { GetRealAndReflectionRect(&rc); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- OldZigZagRect = CurrentRect; // Old °ªÀ¸·Î ¹é¾÷ÇÑ´Ù if (bFirstZigZag) { MainImageForm->iMainImage->Repaint(); bFirstZigZag = false; } else { MainImageForm->iMainImage->RectPaint(rc); } } // --------------------------------------------------------------------------- void __fastcall TVecDraw::ExitZigZag(bool bApply) { // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ZigZag Line °ü·Ã - ZigZag Á¾·á - by monkman (2005.04.07) TList *DataList = NULL; TVecData *data = NULL, *backupdata = NULL; int nBackUpListCount = 0; DataList = NVector->DataList; if (!(NVector->bSelected)) return; if (ZigZagBackUpList->Count <= 0) return; BEGIN_LOG(""); if (bApply) { // ***** ZigZag LineÀ» Àû¿ëÇßÀ» °æ¿ì // PatternFill µÈ data´Â ´Ù½Ã °è»êÇØ¼­ PatternFill ÇØÁØ´Ù for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->bSelected) continue; if ((data->Kind == V_TEXT || data->Kind == V_TEXTBOX)) continue; backupdata = (TVecData*)ZigZagBackUpList->Items[nBackUpListCount]; if (backupdata->bPatternFill) { // PatternFillÀÌ µÈ data°¡ ÀÖ¾ú´Ù¸é ¿©±â¼­ PatternÀ» ÁØ´Ù if (backupdata->TBitmap) { data->TBitmap = backupdata->TBitmap; backupdata->TBitmap = NULL; } if (backupdata->TBitmapSource) { data->TBitmapSource = backupdata->TBitmapSource; backupdata->TBitmapSource = NULL; } if (backupdata->MaskBitmap) { data->MaskBitmap = backupdata->MaskBitmap; backupdata->MaskBitmap = NULL; } MakePatternBitmap(data); // º¯È­µÈ data->pList¿¡ µû¶ó PatternFillÀ» ´Ù½Ã °è»êÇØÁØ´Ù } nBackUpListCount++; } // BackUpList¸¦ ºñ¿î´Ù VecDataListDelete(ZigZagBackUpList); if (ZigZagBackUpList) { delete ZigZagBackUpList; ZigZagBackUpList = NULL; } } else { // ***** ZigZag LineÀ» Àû¿ëÇÏÁö ¾Ê¾ÒÀ» °æ¿ì // BackUpList¿¡ BackUpµÈ ¿øº» Object¸¦ ´Ù½Ã DataList·Î º¹»çÇÑ´Ù // -->by linuxjun for Undo UndoRead(); TPVectorUndo * Undo = (TPVectorUndo*)MainImageForm->VecUndo; Undo->RemoveLast(); // RevertZigZag(); //by linuxjun for Undo ÇÊ¿ä ¾ø¾îÁ®¼­ ÀϺηΠ¸·À½ // <--by linuxjun for Undo // BackUpList¸¦ ºñ¿î´Ù VecDataListDelete(ZigZagBackUpList); if (ZigZagBackUpList) { delete ZigZagBackUpList; ZigZagBackUpList = NULL; } } MainImageForm->iMainImage->Repaint(); // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- END_LOG; } // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- ///////////// Class of TVecDraw // --------------------------------------------------------------------------- #define PAINT_VECTOR \ SetROP2(dcDst, R2_COPYPEN); \ \ switch (data->Kind) { \ case V_LINE: \ graphics.DrawPolygon(&ObjectPen, pPoints, data->nCount+1); \ break; \ \ case V_CURVE: \ if (data->bGradientFill){ \ DrawGradientFill(dcDst, data, pPoints, data->nCount*3+1, FirstX, FirstY, SecondX, SecondY); \ } \ if (data->PenThick) { \ if (data->bClosed && data->PenStyle == P_SOLID) { \ graphics.DrawBeziers(&ObjectPen, pPoints, (data->nCount+1)*3+1); \ } else { \ if (data->PenThick) graphics.DrawBeziers(&ObjectPen, pPoints, data->nCount*3+1); \ } \ } \ if (data->bFill) { \ gFillPath.AddBeziers(pPoints, data->nCount*3+1); \ graphics.FillPath(&ObjectBrush, &gFillPath); \ if (data->PenThick) { \ graphics.DrawPath(&ObjectPen,&gFillPath); \ } \ } \ break; \ \ case V_RECT: \ if (data->bRound) \ RoundRect(dcDst, FirstX, FirstY, SecondX, SecondY, pw, pw); \ else Rectangle(dcDst, FirstX, FirstY, SecondX, SecondY); \ break; \ \ case V_ELLIPSE: \ Ellipse(dcDst, FirstX, FirstY, SecondX, SecondY); \ break; \ \ case V_TEXT: \ Char *tempstr; \ tempstr = (Char *)malloc(data->nCount); \ for (int k = 0; k < data->nCount; k++) tempstr[k] = Char(data->TextString[k+1]);\ SetTextAlign(dcDst, TA_BOTTOM); \ SetTextColor(dcDst, data->Color); \ SetBkMode(dcDst, TRANSPARENT); \ \ font = CreateFontIndirect(&data->Font); \ oldfont = (HFONT)SelectObject(dcDst, font); \ TextOut(dcDst, FirstX, FirstY, tempstr, data->nCount); \ \ SelectObject(dcDst, oldfont); \ DeleteObject(font); \ data->Font.lfHeight = nTemp; \ free(tempstr); \ break; \ \ case V_TEXTBOX: \ if (BeReadyEdit && CurrentTextBox == i) \ DrawEditTextBox(dcDst, data, StartX, StartY, FontZoom, CenterX, CenterY, OffsetX, OffsetY); \ else DrawTextBox(dcDst, data, StartX, StartY, CenterX, CenterY, FontZoom, OffsetX, OffsetY); \ break; \ } \ SetROP2(dcDst, nDrawMode); \ SetPolyFillMode(dcDst, nFillMode); // Ãß°¡ - by monkman (2009.04.10) #define PAINT_VECTOR_MASK \ SetROP2(dcDst, R2_COPYPEN); \ \ switch (data->Kind) { \ case V_LINE: \ graphics.DrawPolygon(&ObjectPen, pPoints, data->nCount+1); \ break; \ \ case V_CURVE: \ if (data->bClosed && data->PenStyle == P_SOLID && data->CapStyle[0] == 0){ \ graphics.DrawBeziers(&ObjectPen, pPoints, (data->nCount+1)*3+1); \ } else { \ graphics.DrawBeziers(&ObjectPen, pPoints, data->nCount*3+1); \ } \ if (data->bGradientFill || data->bFill) { \ gFillPath.AddBeziers(pPoints, data->nCount*3+1); \ graphics.FillPath(&ObjectBrush, &gFillPath); \ graphics.DrawPath(&ObjectPen,&gFillPath); \ } \ \ break; \ \ case V_RECT: \ if (data->bRound) \ RoundRect(dcDst, FirstX, FirstY, SecondX, SecondY, pw, pw); \ else Rectangle(dcDst, FirstX, FirstY, SecondX, SecondY); \ break; \ \ case V_ELLIPSE: \ Ellipse(dcDst, FirstX, FirstY, SecondX, SecondY); \ break; \ \ case V_TEXT: \ Char *tempstr; \ tempstr = (Char *)malloc(data->nCount); \ for (int k = 0; k < data->nCount; k++) tempstr[k] = Char(data->TextString[k+1]);\ SetTextAlign(dcDst, TA_BOTTOM); \ SetTextColor(dcDst, data->Color); \ SetBkMode(dcDst, TRANSPARENT); \ \ font = CreateFontIndirect(&data->Font); \ oldfont = (HFONT)SelectObject(dcDst, font); \ TextOut(dcDst, FirstX, FirstY, tempstr, data->nCount); \ \ SelectObject(dcDst, oldfont); \ DeleteObject(font); \ data->Font.lfHeight = nTemp; \ free(tempstr); \ break; \ \ case V_TEXTBOX: \ if (BeReadyEdit && CurrentTextBox == i) \ DrawEditTextBox(dcDst, data, StartX, StartY, FontZoom, CenterX, CenterY, OffsetX, OffsetY); \ else DrawTextBox(dcDst, data, StartX, StartY, CenterX, CenterY, FontZoom, OffsetX, OffsetY); \ break; \ } \ SetROP2(dcDst, nDrawMode); \ SetPolyFillMode(dcDst, nFillMode); // --------------------------------------------------------------------------- // For LineDraw() GDI+ #define PAINT_LINEDRAW_VECTOR \ SetROP2(dcDst, R2_COPYPEN); \ \ int nReflectionIndex = 0; \ nReflectionIndex = form->NVector->ReflectionVH == 1 ? form->NVector->ReflectionVIndex : form->NVector->ReflectionHIndex;\ \ switch (data->Kind) { \ case V_LINE: \ graphics.DrawPolygon(&ObjectPen, pPoints, data->nCount+1); \ break; \ \ case V_CURVE: \ if (data->bGradientFill){ \ DrawGradientFill(dcDst, data, pPoints, data->nCount*3+1, FirstX, FirstY, SecondX, SecondY \ , form->NVector->ReflectionVH, nReflectionIndex, pRefPoints, R_FirstX, R_FirstY, R_SecondX, R_SecondY); \ } \ if (data->PenThick) { \ if (data->bClosed && data->PenStyle == P_SOLID && data->CapStyle[0] == 0) { \ graphics.DrawBeziers(&ObjectPen, pPoints, (data->nCount+1)*3+1); \ if (form->NVector->bVectorReflectionMode && (form->NVector->ReflectionVH == 1 || form->NVector->ReflectionVH == 2)) { \ graphics.DrawBeziers(&ObjectPen, pRefPoints, (data->nCount+1)*3+1); \ } \ } else { \ graphics.DrawBeziers(&ObjectPen, pPoints, data->nCount*3+1); \ if (form->NVector->bVectorReflectionMode && (form->NVector->ReflectionVH == 1 || form->NVector->ReflectionVH == 2)) { \ graphics.DrawBeziers(&ObjectPen, pRefPoints, data->nCount*3+1); \ } \ } \ } \ if (data->bFill) { \ gFillPath.AddBeziers(pPoints, data->nCount*3+1); \ graphics.FillPath(&ObjectBrush, &gFillPath); \ if (data->PenThick) { \ graphics.DrawPath(&ObjectPen,&gFillPath); \ } \ if (form->NVector->bVectorReflectionMode && (form->NVector->ReflectionVH == 1 || form->NVector->ReflectionVH == 2)) { \ gRefFillPath.AddBeziers(pRefPoints, data->nCount*3+1); \ graphics.FillPath(&ObjectBrush, &gRefFillPath); \ if (data->PenThick) { \ graphics.DrawPath(&ObjectPen,&gRefFillPath); \ } \ } \ } \ break; \ \ case V_RECT: \ if (data->bRound) \ RoundRect(dcDst, FirstX, FirstY, SecondX, SecondY, pw, pw); \ else Rectangle(dcDst, FirstX, FirstY, SecondX, SecondY); \ break; \ \ case V_ELLIPSE: \ Ellipse(dcDst, FirstX, FirstY, SecondX, SecondY); \ break; \ \ case V_TEXT: \ Char *tempstr; \ tempstr = (Char *)malloc(data->nCount); \ for (int k = 0; k < data->nCount; k++) tempstr[k] = Char(data->TextString[k+1]);\ SetTextAlign(dcDst, TA_BOTTOM); \ SetTextColor(dcDst, data->Color); \ SetBkMode(dcDst, TRANSPARENT); \ \ font = CreateFontIndirect(&data->Font); \ oldfont = (HFONT)SelectObject(dcDst, font); \ TextOut(dcDst, FirstX, FirstY, tempstr, data->nCount); \ \ SelectObject(dcDst, oldfont); \ DeleteObject(font); \ data->Font.lfHeight = nTemp; \ free(tempstr); \ break; \ \ case V_TEXTBOX: \ if (BeReadyEdit && CurrentTextBox == i) \ DrawEditTextBox(dcDst, data, StartX, StartY, FontZoom, CenterX, CenterY, OffsetX, OffsetY); \ else DrawTextBox(dcDst, data, StartX, StartY, CenterX, CenterY, FontZoom, OffsetX, OffsetY); \ break; \ } \ SetROP2(dcDst, nDrawMode); \ SetPolyFillMode(dcDst, nFillMode); // --------------------------------------------------------------------------- // Ãß°¡ - by monkman (2009.04.10) #define PAINT_LINEDRAW_VECTOR_MASK \ SetROP2(dcDst, R2_COPYPEN); \ \ switch (data->Kind) { \ case V_LINE: \ graphics.DrawPolygon(&ObjectPen, pPoints, data->nCount+1); \ break; \ \ case V_CURVE: \ if (data->bClosed && data->PenStyle == P_SOLID && data->CapStyle[0] == 0) { \ graphics.DrawBeziers(&ObjectPen, pPoints, (data->nCount+1)*3+1); \ if (form->NVector->bVectorReflectionMode && (form->NVector->ReflectionVH == 1 || form->NVector->ReflectionVH == 2)) { \ graphics.DrawBeziers(&ObjectPen, pRefPoints, (data->nCount+1)*3+1); \ } \ } else { \ graphics.DrawBeziers(&ObjectPen, pPoints, data->nCount*3+1); \ if (form->NVector->bVectorReflectionMode && (form->NVector->ReflectionVH == 1 || form->NVector->ReflectionVH == 2)) { \ graphics.DrawBeziers(&ObjectPen, pRefPoints, data->nCount*3+1); \ } \ } \ if (data->bGradientFill || data->bFill) { \ gFillPath.AddBeziers(pPoints, data->nCount*3+1); \ graphics.FillPath(&ObjectBrush, &gFillPath); \ graphics.DrawPath(&ObjectPen,&gFillPath); \ if (form->NVector->bVectorReflectionMode && (form->NVector->ReflectionVH == 1 || form->NVector->ReflectionVH == 2)) { \ gRefFillPath.AddBeziers(pRefPoints, data->nCount*3+1); \ graphics.FillPath(&ObjectBrush, &gRefFillPath); \ graphics.DrawPath(&ObjectPen,&gRefFillPath); \ } \ } \ \ break; \ \ case V_RECT: \ if (data->bRound) \ RoundRect(dcDst, FirstX, FirstY, SecondX, SecondY, pw, pw); \ else Rectangle(dcDst, FirstX, FirstY, SecondX, SecondY); \ break; \ \ case V_ELLIPSE: \ Ellipse(dcDst, FirstX, FirstY, SecondX, SecondY); \ break; \ \ case V_TEXT: \ Char *tempstr; \ tempstr = (Char *)malloc(data->nCount); \ for (int k = 0; k < data->nCount; k++) tempstr[k] = Char(data->TextString[k+1]);\ SetTextAlign(dcDst, TA_BOTTOM); \ SetTextColor(dcDst, data->Color); \ SetBkMode(dcDst, TRANSPARENT); \ \ font = CreateFontIndirect(&data->Font); \ oldfont = (HFONT)SelectObject(dcDst, font); \ TextOut(dcDst, FirstX, FirstY, tempstr, data->nCount); \ \ SelectObject(dcDst, oldfont); \ DeleteObject(font); \ data->Font.lfHeight = nTemp; \ free(tempstr); \ break; \ \ case V_TEXTBOX: \ if (BeReadyEdit && CurrentTextBox == i) \ DrawEditTextBox(dcDst, data, StartX, StartY, FontZoom, CenterX, CenterY, OffsetX, OffsetY); \ else DrawTextBox(dcDst, data, StartX, StartY, CenterX, CenterY, FontZoom, OffsetX, OffsetY); \ break; \ \ } \ SetROP2(dcDst, nDrawMode); \ SetPolyFillMode(dcDst, nFillMode); // --------------------------------------------------------------------------- // For MoveDraw() GDI #define PAINT_MOVEDRAW_VECTOR \ SetROP2(dcDst, R2_COPYPEN); \ \ int nReflectionIndex = 0; \ nReflectionIndex = form->NVector->ReflectionVH == 1 ? form->NVector->ReflectionVIndex : form->NVector->ReflectionHIndex;\ \ switch (data->Kind) { \ case V_LINE: \ Polyline(dcDst, pPoints, data->nCount +1); \ break; \ \ case V_CURVE: \ if (data->bFill){ \ BeginPath(dcDst); \ MoveToEx(dcDst, pPoints[0].x, pPoints[0].y, NULL); \ PolyBezierTo (dcDst, pPoints+1, data->nCount*3); \ EndPath(dcDst); \ FillPath(dcDst); \ if (data->CapStyle[0] > 0){ \ DrawArrow(dcDst, data, data->nCount*3+1, ZoomIn, ZoomOut, PositionX, PositionY, px, py \ , form); \ } \ else { \ if (data->PenThick) { \ PolyBezier(dcDst, pPoints, (data->nCount+(data->bClosed&&data->PenStyle==P_SOLID))*3+1); \ } \ if (form->NVector->bVectorReflectionMode && (form->NVector->ReflectionVH == 1 || form->NVector->ReflectionVH == 2)) { \ BeginPath(dcDst); \ MoveToEx(dcDst, pRefPoints[0].x, pRefPoints[0].y, NULL); \ PolyBezierTo (dcDst, pRefPoints+1, data->nCount*3); \ EndPath(dcDst); \ FillPath(dcDst); \ if (data->PenThick) { \ PolyBezier(dcDst, pRefPoints, (data->nCount+(data->bClosed&&data->PenStyle==P_SOLID))*3+1); \ } \ } \ } \ } \ else { \ if (data->bGradientFill){ \ DrawGradientFill(dcDst, data, pPoints, data->nCount*3+1, FirstX, FirstY, SecondX, SecondY \ , form->NVector->ReflectionVH, nReflectionIndex, pRefPoints, R_FirstX, R_FirstY, R_SecondX, R_SecondY); \ } \ if (data->CapStyle[0] > 0){ \ DrawArrow(dcDst, data, data->nCount*3+1, ZoomIn, ZoomOut, PositionX, PositionY, px, py \ , form); \ } \ else { \ if (data->PenThick) { \ PolyBezier(dcDst, pPoints, (data->nCount+(data->bClosed&&data->PenStyle==P_SOLID))*3+1); \ if (form->NVector->bVectorReflectionMode && (form->NVector->ReflectionVH == 1 || form->NVector->ReflectionVH == 2)) { \ PolyBezier(dcDst, pRefPoints, (data->nCount+(data->bClosed&&data->PenStyle==P_SOLID))*3+1); \ } \ } \ } \ } \ break; \ \ case V_RECT: \ if (data->bRound) \ RoundRect(dcDst, FirstX, FirstY, SecondX, SecondY, pw, pw); \ else Rectangle(dcDst, FirstX, FirstY, SecondX, SecondY); \ break; \ \ case V_ELLIPSE: \ Ellipse(dcDst, FirstX, FirstY, SecondX, SecondY); \ break; \ \ case V_TEXT: \ Char *tempstr; \ tempstr = (Char *)malloc(data->nCount); \ for (int k = 0; k < data->nCount; k++) tempstr[k] = Char(data->TextString[k+1]);\ SetTextAlign(dcDst, TA_BOTTOM); \ SetTextColor(dcDst, data->Color); \ SetBkMode(dcDst, TRANSPARENT); \ \ font = CreateFontIndirect(&data->Font); \ oldfont = (HFONT)SelectObject(dcDst, font); \ TextOut(dcDst, FirstX, FirstY, tempstr, data->nCount); \ \ SelectObject(dcDst, oldfont); \ DeleteObject(font); \ data->Font.lfHeight = nTemp; \ free(tempstr); \ break; \ \ case V_TEXTBOX: \ if (BeReadyEdit && CurrentTextBox == i) \ DrawEditTextBox(dcDst, data, StartX, StartY, FontZoom, CenterX, CenterY, OffsetX, OffsetY); \ else DrawTextBox(dcDst, data, StartX, StartY, CenterX, CenterY, FontZoom, OffsetX, OffsetY); \ break; \ } \ SetROP2(dcDst, nDrawMode); \ SetPolyFillMode(dcDst, nFillMode); // --------------------------------------------------------------------------- // For FullViewDraw() GDI #define PAINT_FULLVIEW_VECTOR \ SetROP2(dcDst, R2_COPYPEN); \ \ int nReflectionIndex = 0; \ nReflectionIndex = MainImageForm->NVector->ReflectionVH == 1 ? MainImageForm->NVector->ReflectionVIndex : MainImageForm->NVector->ReflectionHIndex;\ \ switch (data->Kind) { \ case V_LINE: \ Polyline(dcDst, pPoints, data->nCount +1); \ break; \ \ case V_CURVE: \ if (data->bFill){ \ BeginPath(dcDst); \ MoveToEx(dcDst, pPoints[0].x, pPoints[0].y, NULL); \ PolyBezierTo (dcDst, pPoints+1, data->nCount*3); \ EndPath(dcDst); \ FillPath(dcDst); \ if (data->PenThick) { \ PolyBezier(dcDst, pPoints, (data->nCount+(data->bClosed&&data->PenStyle==P_SOLID))*3+1); \ } \ if (MainImageForm && MainImageForm->NVector->bVectorReflectionMode && (MainImageForm->NVector->ReflectionVH == 1 || MainImageForm->NVector->ReflectionVH == 2)) { \ BeginPath(dcDst); \ MoveToEx(dcDst, pRefPoints[0].x, pRefPoints[0].y, NULL); \ PolyBezierTo (dcDst, pRefPoints+1, data->nCount*3); \ EndPath(dcDst); \ FillPath(dcDst); \ if (data->PenThick) { \ PolyBezier(dcDst, pRefPoints, (data->nCount+(data->bClosed&&data->PenStyle==P_SOLID))*3+1); \ } \ } \ }else { \ if (data->bGradientFill){ \ DrawGradientFill(dcDst, data, pPoints, data->nCount*3+1, FirstX, FirstY, SecondX, SecondY \ , MainImageForm->NVector->ReflectionVH, nReflectionIndex, pRefPoints, R_FirstX, R_FirstY, R_SecondX, R_SecondY); \ } \ if (data->PenThick) { \ PolyBezier(dcDst, pPoints, (data->nCount+(data->bClosed&&data->PenStyle==P_SOLID))*3+1); \ if (MainImageForm && MainImageForm->NVector->bVectorReflectionMode && (MainImageForm->NVector->ReflectionVH == 1 || MainImageForm->NVector->ReflectionVH == 2)) { \ PolyBezier(dcDst, pRefPoints, (data->nCount+(data->bClosed&&data->PenStyle==P_SOLID))*3+1); \ } \ } \ } \ break; \ \ case V_RECT: \ if (data->bRound) \ RoundRect(dcDst, FirstX, FirstY, SecondX, SecondY, pw, pw); \ else Rectangle(dcDst, FirstX, FirstY, SecondX, SecondY); \ break; \ \ case V_ELLIPSE: \ Ellipse(dcDst, FirstX, FirstY, SecondX, SecondY); \ break; \ \ case V_TEXT: \ Char *tempstr; \ tempstr = (Char *)malloc(data->nCount); \ for (int k = 0; k < data->nCount; k++) tempstr[k] = Char(data->TextString[k+1]);\ SetTextAlign(dcDst, TA_BOTTOM); \ SetTextColor(dcDst, data->Color); \ SetBkMode(dcDst, TRANSPARENT); \ \ font = CreateFontIndirect(&data->Font); \ oldfont = (HFONT)SelectObject(dcDst, font); \ TextOut(dcDst, FirstX, FirstY, tempstr, data->nCount); \ \ SelectObject(dcDst, oldfont); \ DeleteObject(font); \ data->Font.lfHeight = nTemp; \ free(tempstr); \ break; \ \ case V_TEXTBOX: \ if (BeReadyEdit && CurrentTextBox == i) \ DrawEditTextBox(dcDst, data, StartX, StartY, FontZoom, CenterX, CenterY, OffsetX, OffsetY); \ else DrawTextBox(dcDst, data, StartX, StartY, CenterX, CenterY, FontZoom, OffsetX, OffsetY); \ break; \ } \ SetROP2(dcDst, nDrawMode); \ SetPolyFillMode(dcDst, nFillMode); \ //--------------------------------------------------------------------------- // -->by linuxjun for CurvedVectorText #define SET_RECT \ \ data->First.x = MaxInt; data->First.y = MaxInt; \ data->Second.x = 0; data->Second.y = 0; \ if (data->Kind == V_LINE || data->Kind == V_CURVE) { \ for (int i = 0; i < data->nCount*3+1; i++) { \ if (data->pList == NULL) continue; \ 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; \ } \ } else if (data->Kind == V_TEXTBOX && !(data->ListOfAllLine->CurveData)) { \ for (int i = 0; i < 5; i++) { \ data->First.x = min(data->First.x, data->pList[i].x); \ data->First.y = min(data->First.y, data->pList[i].y); \ data->Second.x = max(data->Second.x, data->pList[i].x); \ data->Second.y = max(data->Second.y, data->pList[i].y); \ } \ } \ if (data->ParentTextBox){ \ int Margin; \ try{ \ Margin = data->ParentTextBox->ListOfAllLine->GetLineTextBox(0)->lineHeight*3; \ }catch(...) { \ Margin = 0; \ } \ data->First.x -= Margin; \ data->First.y -= Margin; \ data->Second.x += Margin; \ data->Second.y += Margin; \ } \ if (data->ChildList) { \ TVecData *item = NULL; \ int w, h; \ long minx = MaxInt, miny = MaxInt, maxx = 0, maxy = 0; \ for (int j = 0; j < data->ChildList->Count; j++) { \ item = (TVecData *)data->ChildList->Items[j]; \ minx = min(minx, item->First.x); \ minx = min(minx, item->Second.x); \ maxx = max(maxx, item->First.x); \ maxx = max(maxx, item->Second.x); \ miny = min(miny, item->First.y); \ miny = min(miny, item->Second.y); \ maxy = max(maxy, item->First.y); \ maxy = max(maxy, item->Second.y); \ } \ w = (maxx - minx)/2; h = (maxy - miny)/2; \ w = sqrt(w*w + h*h) + 0.5; \ data->First.x -= w; \ data->First.y -= w; \ data->Second.x += w; \ data->Second.y += w; \ } \ // PatternFillÀ» Çϱâ À§Çؼ­´Â Parent DataÀÇ »øÁ¦ Firtst, Second data°¡ ÇÊ¿äÇÏ´Ù. by david 09.05.01 // MOtive, PathText¿¡ ÀÇÇØ Àç°è»êµÈ °ªÀ¸·Î ó¸®Çϸé PatternFillÀÌ ´Ù¸¥ °÷¿¡ ¹þ¾î³ª 󸮵ȴÙ. // ¼ø¼öÇÑ VecDataÀÇ Rect¸¦ ±¸ÇÏ´Â ºÎºÐÀ¸·Î ó¸® #define SET_RECT_ORIGIN \ \ data->First.x = MaxInt; data->First.y = MaxInt; \ data->Second.x = 0; data->Second.y = 0; \ if (data->Kind == V_LINE || data->Kind == V_CURVE) { \ for (int i = 0; i < data->nCount*3+1; i++) { \ if (data->pList == NULL) continue; \ 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; \ } \ } else if (data->Kind == V_TEXTBOX && !(data->ListOfAllLine->CurveData)) { \ for (int i = 0; i < 5; i++) { \ data->First.x = min(data->First.x, data->pList[i].x); \ data->First.y = min(data->First.y, data->pList[i].y); \ data->Second.x = max(data->Second.x, data->pList[i].x); \ data->Second.y = max(data->Second.y, data->pList[i].y); \ } \ } \ // Line°ú Curve¿¡¼­ First, Second´Â °¢°¢ÀÇ ÃÖ´ë, ÃÖ¼Ò Á¡ÀÌ µé¾î°£´Ù /* #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->pList == NULL) continue; \ 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´Â °¢°¢ÀÇ ÃÖ´ë, ÃÖ¼Ò Á¡ÀÌ µé¾î°£´Ù */ // <--by linuxjun for CurvedVectorText // --------------------------------------------------------------------------- /** // 090811 Áߺ¹ ÁöÁ¤À» À§ÇØ ¼öÁ¤ by david // 00000000 00000000 00000000 00000001 Bit·Î ó¸® * -# Method 00000001(1) : Default * -# Method 00000010(2) : ÇÑ Á¡ÀÌ¶óµµ Area¾È¿¡ Àִ°æ¿ì ÀúÀå * -# Method 00000100(4) : ÇÑ Á¡ÀÌ¶óµµ Area¹Û¿¡ ÀÖÀ¸¸é ÀúÀåÇÏÁö ¾ÊÀ½ * -# Method 00001000(8) : ¼±ÅÃµÈ Object¸¸ ÀúÀåµÊ * -# Method 00010000(16) : Moptive Object ÀúÀåÀ¸·Î ÀÛ¾÷±¸¿ª°ú »ó°ü¾øÀÌ ÀúÀåÇÑ´Ù. * -# Method 00100000(32) : Style Data(Color´Â ºí·¢, ColorFill, Pattern, Gradient Á¦¿Ü Çϰí ÀúÀå) */ #define INRECTMETHOD \ if ((method & 2) && bRange) { \ bool bInRect = false; \ if (data->Kind == V_LINE || data->Kind == V_CURVE) { \ for (int k = 0; k < data->nCount*3+1; k+=3) { \ if (PtInRect(&Src, data->pList[k].P())) bInRect = true; \ } \ }else { \ if (PtInRect(&Src, data->First) || PtInRect(&Src, data->Second) || \ PtInRect(&Src, Point(data->First.x, data->Second.y)) || \ PtInRect(&Src, Point(data->Second.x, data->First.y))) \ bInRect = true; \ } \ if (!bInRect) continue; \ } \ \ if ((method & 4) && bRange) { \ bool bInRect = true; \ if (data->Kind == V_LINE || data->Kind == V_CURVE) { \ for (int k = 0; k < data->nCount*3+1; k+=3) { \ if (!PtInRect(&Src, data->pList[k].P())) bInRect = false; \ } \ }else { \ if (!(PtInRect(&Src, data->First) && PtInRect(&Src, data->Second) && \ PtInRect(&Src, Point(data->First.x, data->Second.y)) && PtInRect(&Src, Point(data->Second.x, data->First.y)))) \ bInRect = false; \ } \ if (!bInRect) continue; \ } \ // ÀÛ¾÷ ±¸¿ª ¾È¿¡ object°¡ ÀÖÀ¸¸é ÁøÇà ¾Æ´Ï¸é continue // Method 2 : ÇÑ Á¡ÀÌ¶óµµ Area¾È¿¡ Àִ°æ¿ì // 3 : ÇÑ Á¡ÀÌ¶óµµ Area¹Û¿¡ ÀÖÀ¸¸é pass // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- /////////////// Object Addition Part // --------------------------------------------------------------------------- void __fastcall TVecDraw::LineAdd(EVecKind EKind, POINT pFst, POINT pScd) { TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) double thick; if (VectorForm->LineType == 2) NVector->bFstLine = true; if (!(NVector->bFstLine)) { data = (TVecData*)DataList->Items[DataList->Count - 1]; CheckFirstLine(); } if (NVector->bFstLine) { if ((data = new TVecData(MainImageForm->Number)) == NULL) goto fail; data->Kind = V_CURVE; data->bRound = !PenManagerForm->Pen->Shape; data->Color = PenManagerForm->PenShape->Pen->Color; // data->PenThick = PenManagerForm->Pen->Thick; // data->PenStyle = P_SOLID; data->Bitmap = NULL; data->bFill = false; data->bSelected = false; // --------> 2005 Vector upgrade Shin 0315 data->PenThick = VectorForm->DrawingThick; data->PenStyle = (EPenStyle)VectorForm->PenStyle; data->CapStyle[0] = VectorForm->CapStyle[0]; data->CapStyle[1] = VectorForm->CapStyle[1]; if (data->ArrowCap){ data->ArrowCap->LineCapWidthScale = VectorForm->LineCapWidthScale; data->ArrowCap->LineCapWidth = VectorForm->LineCapWidth; data->ArrowCap->LineCapHeight = VectorForm->LineCapHeight; data->ArrowCap->LineCapLine = VectorForm->LineCapLine; data->ArrowCap->bFillLineCap = VectorForm->bFillLineCap; data->ArrowCap->bShowArrowBoth = VectorForm->bShowArrowBoth; } thick = data->PenThick; if (data->PenStyle == P_USERSTYLE) { data->DashValues[0] = dashcount; data->DashValues[1] = dset[0] / thick; data->DashValues[2] = dset[1] / thick; data->DashValues[3] = dset[2] / thick; data->DashValues[4] = dset[3] / thick; data->DashValues[5] = dset[4] / thick; data->DashValues[6] = dset[5] / thick; } // Antialiasing ¼³Á¤ : ±×¸±¶§ 20050222 shin if (VectorForm->cbObjAntialiasing->Checked) data->bAntialiasing = true; else data->bAntialiasing = 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); data->pList[1].DPoint(pFst); data->pList[2].DPoint(pScd); data->pList[3].DPoint(pScd); DataList->Add(data); // ======= Undo Test UndoSave(VU_CREATE, DataList->Count - 1); // ======= Undo Test NVector->bFirst = true; NVector->bFstLine = false; } else { // --------> 2005 Vector upgrade Shin 0315 data->CapStyle[0] = VectorForm->CapStyle[0]; data->CapStyle[1] = VectorForm->CapStyle[1]; if (data->ArrowCap){ data->ArrowCap->LineCapWidthScale = VectorForm->LineCapWidthScale; data->ArrowCap->LineCapWidth = VectorForm->LineCapWidth; data->ArrowCap->LineCapHeight = VectorForm->LineCapHeight; data->ArrowCap->LineCapLine = VectorForm->LineCapLine; data->ArrowCap->bFillLineCap = VectorForm->bFillLineCap; data->ArrowCap->bShowArrowBoth = VectorForm->bShowArrowBoth; } data->PenStyle = (EPenStyle)VectorForm->PenStyle; thick = data->PenThick; if (data->PenStyle == P_USERSTYLE) { data->DashValues[0] = dashcount; data->DashValues[1] = dset[0] / thick; data->DashValues[2] = dset[1] / thick; data->DashValues[3] = dset[2] / thick; data->DashValues[4] = dset[3] / thick; data->DashValues[5] = dset[4] / thick; data->DashValues[6] = dset[5] / thick; } // --------------< 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); data->pList[data->nCount * 3 - 1].DPoint(pScd); data->pList[data->nCount * 3].DPoint(pScd); // --------> 2005 Vector upgrade // Color fill ¼³Á¤ 0315 shin if (VectorForm->cbFill->Visible && VectorForm->cbFill->Checked) { data->bFill = true; data->Brush = PenManagerForm->PenShape->Pen->Color; } else data->bFill = false; // ------------------------< } // 2009 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É - 'J'۸¦ ´­·¶À» ¶§ ³¡Á¡ÀÌ ¹ÝÀü ±âÁؼ±¿¡ ´Þ¶ó ºÙµµ·Ï ÇÑ´Ù - by monkman (2009.11.27) if (bJoinState) { if ((NVector->ReflectionVH == 1 && pFst.x == NVector->ReflectionVIndex) || (NVector->ReflectionVH == 2 && pFst.y == NVector->ReflectionHIndex)) { data->bFirstJoin = true; bJoinState = false; // ´Ù½Ã ÃʱâÈ­½ÃÄÑÁØ´Ù } if ((NVector->ReflectionVH == 1 && pScd.x == NVector->ReflectionVIndex) || (NVector->ReflectionVH == 2 && pScd.y == NVector->ReflectionHIndex)) { data->bLastJoin = true; bJoinState = false; // ´Ù½Ã ÃʱâÈ­½ÃÄÑÁØ´Ù } } if (bAltState) { data->bFirstJoin = false; data->bLastJoin = false; bJoinState = false; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- SET_RECT; if (NVector->bClosedState) { data->bClosed = true; NVector->step = 0; NVector->bFstLine = true; MainImageForm->iMainImage->Cursor = crDefault; bJoinState = false; // stepÀÌ 0 À̸é ÃʱâÈ­ ÇØÁØ´Ù - by monkman (2009.11.26) // *bClosedState = false; } NVector->bFirst = true; if (VectorForm->sbSpray->Down && tempChildList && tempChildList->Count) { data = (TVecData*)DataList->Last(); MakeMotiveObject(data); } return; fail: if (data) delete data; data = NULL; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::DiagramAdd(EVecKind EKind, POINT pFst, POINT pScd) { TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) double thick; if ((data = new TVecData(MainImageForm->Number)) == NULL) goto fail; // ================ data->Kind = V_CURVE; data->First = pFst; data->Second = pScd; data->bRound = !PenManagerForm->Pen->Shape; data->Color = PenManagerForm->PenShape->Pen->Color; data->Brush = PenManagerForm->PenShape->Pen->Color; // data->PenThick = PenManagerForm->Pen->Thick; // data->PenStyle = P_SOLID; // --------> 2005 Vector upgrade Shin 0315 data->CapStyle[0] = VectorForm->CapStyle[0]; data->CapStyle[1] = VectorForm->CapStyle[1]; if (data->ArrowCap){ data->ArrowCap->LineCapWidthScale = VectorForm->LineCapWidthScale; data->ArrowCap->LineCapWidth = VectorForm->LineCapWidth; data->ArrowCap->LineCapHeight = VectorForm->LineCapHeight; data->ArrowCap->LineCapLine = VectorForm->LineCapLine; data->ArrowCap->bFillLineCap = VectorForm->bFillLineCap; data->ArrowCap->bShowArrowBoth = VectorForm->bShowArrowBoth; } data->PenThick = VectorForm->DrawingThick; data->PenStyle = (EPenStyle)VectorForm->PenStyle; thick = data->PenThick; if (data->PenStyle == P_USERSTYLE) { data->DashValues[0] = dashcount; data->DashValues[1] = dset[0] / thick; data->DashValues[2] = dset[1] / thick; data->DashValues[3] = dset[2] / thick; data->DashValues[4] = dset[3] / thick; data->DashValues[5] = dset[4] / thick; data->DashValues[6] = dset[5] / thick; } // Color fill ¼³Á¤ if (VectorForm->cbFill->Checked) { data->bFill = true; data->Brush = PenManagerForm->PenShape->Pen->Color; } else data->bFill = false; // Antialiasing ¼³Á¤ : ±×¸±¶§ if (VectorForm->cbObjAntialiasing->Checked) data->bAntialiasing = true; else data->bAntialiasing = 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); memset(data->pMask, 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); if (EKind == V_ELLIPSE) { // Ÿ¿øÀ» º£Áö¿¡¸£·Î º¯È¯ double M = 0.55228474983; int dx = abs(pFst.x - pScd.x) / 2, dy = abs(pFst.y - pScd.y) / 2; double ddx = dx * M, ddy = dy * M; // (¿ø·¡ ¼Ò½º)¹Ý½Ã°è ¹æÇâÀ¸·Î ±×¸°´Ù // data->pList[0].DPoint((pFst.x+pScd.x)/2.0, pFst.y+0.0); // data->pList[1].DPoint((pFst.x+pScd.x)/2-ddx+0.5, pFst.y); // data->pList[2].DPoint(pFst.x, (pFst.y+pScd.y)/2-ddy+0.5); // data->pList[3].DPoint(pFst.x, (pFst.y+pScd.y)/2.0); // data->pList[4].DPoint(pFst.x, (pFst.y+pScd.y)/2+ddy+0.5); // data->pList[5].DPoint((pFst.x+pScd.x)/2-ddx+0.5, pScd.y); // data->pList[6].DPoint((pFst.x+pScd.x)/2, pScd.y+0.0); // data->pList[7].DPoint((pFst.x+pScd.x)/2+ddx+0.5, pScd.y); // data->pList[8].DPoint(pScd.x, (pFst.y+pScd.y)/2+ddy+0.5); // data->pList[9].DPoint(pScd.x+0.0, (pFst.y+pScd.y)/2); // data->pList[10].DPoint(pScd.x, (pFst.y+pScd.y)/2-ddy+0.5); // data->pList[11].DPoint((pFst.x+pScd.x)/2+ddx+0.5, pFst.y); // data->pList[12].DPoint((pFst.x+pScd.x)/2, pFst.y+0.0); // data->bClosed = true; /* // ½Ã°è ¹æÇâÀ¸·Î ±×¸°´Ù (ÆÐ½º¸¦ µû¶ó°¡´Â ¹®ÀÚ ¶§¹®¿¡ º¯°æ) - by monkman (2005.05.06) data->pList[12].DPoint((pFst.x + pScd.x) / 2.0, pFst.y + 0.0); data->pList[11].DPoint((pFst.x + pScd.x) / 2 - ddx - 0.5, pFst.y); data->pList[10].DPoint(pFst.x, (pFst.y + pScd.y) / 2 - ddy + 0.5); data->pList[9].DPoint(pFst.x, (pFst.y + pScd.y) / 2.0); data->pList[8].DPoint(pFst.x, (pFst.y + pScd.y) / 2 + ddy + 0.5); data->pList[7].DPoint((pFst.x + pScd.x) / 2 - ddx + 0.5, pScd.y); data->pList[6].DPoint((pFst.x + pScd.x) / 2, pScd.y + 0.0); data->pList[5].DPoint((pFst.x + pScd.x) / 2 + ddx + 0.5, pScd.y); data->pList[4].DPoint(pScd.x, (pFst.y + pScd.y) / 2 + ddy - 0.5); data->pList[3].DPoint(pScd.x + 0.0, (pFst.y + pScd.y) / 2); data->pList[2].DPoint(pScd.x, (pFst.y + pScd.y) / 2 - ddy - 0.5); data->pList[1].DPoint((pFst.x + pScd.x) / 2 + ddx - 0.5, pFst.y); data->pList[0].DPoint((pFst.x + pScd.x) / 2, pFst.y + 0.0); data->bClosed = true; */ // ½Ã°è ¹æÇâÀ¸·Î ±×¸°´Ù (ÆÐ½º¸¦ µû¶ó°¡´Â ¹®ÀÚ ¶§¹®¿¡ º¯°æ, ÁÂÇ¥¼öÁ¤) - Gaeseong (2017.03.09) data->pList[12].DPoint((pFst.x + pScd.x) / 2.0, pFst.y + 0.0); data->pList[11].DPoint((pFst.x + pScd.x) / 2 - ddx , pFst.y); data->pList[10].DPoint(pFst.x, (pFst.y + pScd.y) / 2 - ddy ); data->pList[9].DPoint(pFst.x, (pFst.y + pScd.y) / 2.0); data->pList[8].DPoint(pFst.x, (pFst.y + pScd.y) / 2 + ddy ); data->pList[7].DPoint((pFst.x + pScd.x) / 2 - ddx , pScd.y); data->pList[6].DPoint((pFst.x + pScd.x) / 2, pScd.y + 0.0); data->pList[5].DPoint((pFst.x + pScd.x) / 2 + ddx , pScd.y); data->pList[4].DPoint(pScd.x, (pFst.y + pScd.y) / 2 + ddy ); data->pList[3].DPoint(pScd.x + 0.0, (pFst.y + pScd.y) / 2); data->pList[2].DPoint(pScd.x, (pFst.y + pScd.y) / 2 - ddy ); data->pList[1].DPoint((pFst.x + pScd.x) / 2 + ddx, pFst.y); data->pList[0].DPoint((pFst.x + pScd.x) / 2, pFst.y + 0.0); data->bClosed = true; } else { // »ç°¢ÇüÀ» º£Áö¿¡¸£·Î º¯È¯ // (¿ø·¡ ¼Ò½º)¹Ý½Ã°è ¹æÇâÀ¸·Î ±×¸°´Ù // data->pList[0].DPoint(pFst.x, pFst.y); // data->pList[1].DPoint(pFst.x, pFst.y); // data->pList[2].DPoint(pFst.x, pScd.y); // data->pList[3].DPoint(pFst.x, pScd.y); // data->pList[4].DPoint(pFst.x, pScd.y); // data->pList[5].DPoint(pScd.x, pScd.y); // data->pList[6].DPoint(pScd.x, pScd.y); // data->pList[7].DPoint(pScd.x, pScd.y); // data->pList[8].DPoint(pScd.x, pFst.y); // data->pList[9].DPoint(pScd.x, pFst.y); // data->pList[10].DPoint(pScd.x, pFst.y); // data->pList[11].DPoint(pFst.x, pFst.y); // data->pList[12].DPoint(pFst.x, pFst.y); // data->bClosed = true; // ½Ã°è ¹æÇâÀ¸·Î ±×¸°´Ù (ÆÐ½º¸¦ µû¶ó°¡´Â ¹®ÀÚ ¶§¹®¿¡ º¯°æ) - by monkman (2005.05.06) data->pList[12].DPoint(pFst.x, pFst.y); data->pList[11].DPoint(pFst.x, pFst.y); data->pList[10].DPoint(pFst.x, pScd.y); data->pList[9].DPoint(pFst.x, pScd.y); data->pList[8].DPoint(pFst.x, pScd.y); data->pList[7].DPoint(pScd.x, pScd.y); data->pList[6].DPoint(pScd.x, pScd.y); data->pList[5].DPoint(pScd.x, pScd.y); data->pList[4].DPoint(pScd.x, pFst.y); data->pList[3].DPoint(pScd.x, pFst.y); data->pList[2].DPoint(pScd.x, pFst.y); data->pList[1].DPoint(pFst.x, pFst.y); data->pList[0].DPoint(pFst.x, pFst.y); data->bClosed = true; } // ==================== DataList->Add(data); // ======= Undo Test UndoSave(VU_CREATE, DataList->Count - 1); // ======= Undo Test NVector->bFirst = true; if (VectorForm->sbSpray->Down && tempChildList && tempChildList->Count) { data = (TVecData*)DataList->Last(); MakeMotiveObject(data); } return; fail: if (data) delete data; data = NULL; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::CurveAdd(POINT pFst, POINT pScd, POINT pTan2) { TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) POINT Temp2, Temp3, Temp4; double thick; if (VectorForm->LineType == 2) NVector->bFstLine = true; if (!(NVector->bFstLine)) { data = (TVecData*)DataList->Items[DataList->Count - 1]; CheckFirstLine(); } pTan = pTan2; // Àӽà ±â¿ï±â ÀúÀå(´ÙÀ½ °î¼±ÀÇ ½ÃÀÛÁ¡ ±â¿ï±â) pTan2.x = pScd.x * 2 - pTan2.x; // IllustraterÀÇ ¹æ½ÄÀ» µû¸£±â À§ÇÔ pTan2.y = pScd.y * 2 - pTan2.y; if (NVector->bFstLine) { if ((data = new TVecData(MainImageForm->Number)) == NULL) goto fail; data->Kind = V_CURVE; data->bRound = !PenManagerForm->Pen->Shape; data->Color = PenManagerForm->PenShape->Pen->Color; // data->PenThick = PenManagerForm->Pen->Thick; // data->PenStyle = P_SOLID; // -----------------> 2005 Vector Upgrade Shin 0315 data->PenThick = VectorForm->DrawingThick; data->PenStyle = (EPenStyle)VectorForm->PenStyle; data->CapStyle[0] = VectorForm->CapStyle[0]; data->CapStyle[1] = VectorForm->CapStyle[1]; if (data->ArrowCap){ data->ArrowCap->LineCapWidthScale = VectorForm->LineCapWidthScale; data->ArrowCap->LineCapWidth = VectorForm->LineCapWidth; data->ArrowCap->LineCapHeight = VectorForm->LineCapHeight; data->ArrowCap->LineCapLine = VectorForm->LineCapLine; data->ArrowCap->bFillLineCap = VectorForm->bFillLineCap; data->ArrowCap->bShowArrowBoth = VectorForm->bShowArrowBoth; } thick = data->PenThick; if (data->PenStyle == P_USERSTYLE) { data->DashValues[0] = dashcount; data->DashValues[1] = dset[0] / thick; data->DashValues[2] = dset[1] / thick; data->DashValues[3] = dset[2] / thick; data->DashValues[4] = dset[3] / thick; data->DashValues[5] = dset[4] / thick; data->DashValues[6] = dset[5] / thick; } // -------------< 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); memset(data->pMask, 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); data->pList[0].DPoint(pFst); data->pList[3].DPoint(pScd); data->pList[1].DPoint(pFst); data->pList[2].DPoint(pTan2); // ------------------> 2005 Vector upgrade Shin 0315 // Color fill ¼³Á¤ 20050225 shin if (VectorForm->cbFill->Checked) { data->bFill = true; data->Brush = PenManagerForm->PenShape->Pen->Color; } else data->bFill = false; // Antialiasing ¼³Á¤ : ±×¸±¶§ 20050222 shin if (VectorForm->cbObjAntialiasing->Checked) data->bAntialiasing = true; else data->bAntialiasing = false; // -----------------------------------< DataList->Add(data); // ======= Undo Test UndoSave(VU_CREATE, DataList->Count - 1); // ======= Undo Test NVector->bFirst = false; NVector->bFstLine = false; } else { // ¿¬¼ÓµÈ °î¼± data->CapStyle[0] = VectorForm->CapStyle[0]; data->CapStyle[1] = VectorForm->CapStyle[1]; if (data->ArrowCap){ data->ArrowCap->LineCapWidthScale = VectorForm->LineCapWidthScale; data->ArrowCap->LineCapWidth = VectorForm->LineCapWidth; data->ArrowCap->LineCapHeight = VectorForm->LineCapHeight; data->ArrowCap->LineCapLine = VectorForm->LineCapLine; data->ArrowCap->bFillLineCap = VectorForm->bFillLineCap; data->ArrowCap->bShowArrowBoth = VectorForm->bShowArrowBoth; } Temp2 = data->pList[data->nCount * 3 - 1].P(); Temp3 = data->pList[data->nCount * 3].P(); if (VectorForm->LineType == 1) { // ±â¿ï±â °øÀ¯ÇÏÁö ¾Ê´Â °î¼± Temp4.x = Temp3.x; Temp4.y = Temp3.y; } else if (VectorForm->LineType == 3) { // ±â¿ï±â À̾îÁö´Â °î¼± Temp4.x = Temp3.x * 2 - Temp2.x; Temp4.y = Temp3.y * 2 - Temp2.y; } // ---------------------> 2005 Vector Upgrade Shin 0315 data->PenStyle = (EPenStyle)VectorForm->PenStyle; thick = data->PenThick; if (data->PenStyle == P_USERSTYLE) { data->DashValues[0] = dashcount; data->DashValues[1] = dset[0] / thick; data->DashValues[2] = dset[1] / thick; data->DashValues[3] = dset[2] / thick; data->DashValues[4] = dset[3] / thick; data->DashValues[5] = dset[4] / thick; data->DashValues[6] = dset[5] / thick; } // -----------------< 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); memset(data->pMask, 0, (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(Temp4); data->pList[data->nCount * 3 - 1].DPoint(pTan2); data->pList[data->nCount * 3].DPoint(pScd); // --------> 2005 Vector upgrade // Color fill ¼³Á¤ if (VectorForm->cbFill->Checked) { data->bFill = true; data->Brush = PenManagerForm->PenShape->Pen->Color; } else data->bFill = false; // --------< } // 2009 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É - 'J'۸¦ ´­·¶À» ¶§ ³¡Á¡ÀÌ ¹ÝÀü ±âÁؼ±¿¡ ´Þ¶ó ºÙµµ·Ï ÇÑ´Ù - by monkman (2009.11.27) if (bJoinState) { if ((NVector->ReflectionVH == 1 && pFst.x == NVector->ReflectionVIndex) || (NVector->ReflectionVH == 2 && pFst.y == NVector->ReflectionHIndex)) { data->bFirstJoin = true; bJoinState = false; // ´Ù½Ã ÃʱâÈ­½ÃÄÑÁØ´Ù } if ((NVector->ReflectionVH == 1 && pScd.x == NVector->ReflectionVIndex) || (NVector->ReflectionVH == 2 && pScd.y == NVector->ReflectionHIndex)) { data->bLastJoin = true; bJoinState = false; // ´Ù½Ã ÃʱâÈ­½ÃÄÑÁØ´Ù } } if (bAltState) { data->bFirstJoin = false; data->bLastJoin = false; bJoinState = false; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- SET_RECT; if (NVector->bClosedState) { data->bClosed = true; NVector->step = 0; NVector->bFstLine = true; MainImageForm->iMainImage->Cursor = crDefault; bJoinState = false; // stepÀÌ 0 À̸é ÃʱâÈ­ ÇØÁØ´Ù - by monkman (2009.11.26) } NVector->bFirst = true; if (VectorForm->sbSpray->Down && tempChildList && tempChildList->Count) { data = (TVecData*)DataList->Last(); MakeMotiveObject(data); } return; fail: if (data) delete data; data = NULL; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::ExtendObject(EVecKind EKind, POINT pFst, POINT pScd, POINT pTan2) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) POINT Temp2, Temp3, Temp4; POINT *pPoints = NULL; // temp[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) data = (TVecData*)DataList->Items[Index]; if (VectorForm->LineType == 2) NVector->bFstLine = true; if (!(NVector->bFstLine)) { if (CheckFirstLine()) { // Á¶°ÇÀÌ ´Ù¸¥°æ¿ì objectºÐ¸®Çعö¸°´Ù NVector->bExtend = false; if (EKind == V_LINE) { LineAdd(V_LINE, pFst, pScd); } else if (EKind == V_CURVE) { CurveAdd(pFst, pScd, pTan2); } END_LOG; return; } } if (NVector->bFstLine) { // ù¹ø¸¸ undo save UndoSave(VU_MODIFY, Index); NVector->bFstLine = false; } if (NVector->bExtendFirst) { // ùÁ¡À» ¿¬ÀåÇÏ´Â °æ¿ì´Â ùÁ¡À» ¸¶Áö¸·Á¡À¸·Î ¹Ù²Ù°í ¿¬°áÇÑ´Ù pPoints = new POINT[data->nCount * 3 + 1]; if (pPoints) { for (int i = 0; i < data->nCount * 3 + 1; i++) pPoints[i] = data->pList[i].P(); for (int i = 0; i < data->nCount * 3 + 1; i++) data->pList[i].DPoint(pPoints[data->nCount * 3 - i]); NVector->bExtendFirst = false; delete[]pPoints; pPoints = NULL; } } if (EKind == V_LINE) { 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); memset(data->pMask, 0, (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); data->pList[data->nCount * 3 - 1].DPoint(pScd); data->pList[data->nCount * 3].DPoint(pScd); // data->PenThick = PenManagerForm->Pen->Thick; data->PenThick = VectorForm->DrawingThick; // 2005 Vector Upgrade Shin 0315 data->bRound = !PenManagerForm->Pen->Shape; data->Color = PenManagerForm->PenShape->Pen->Color; } else if (EKind == V_CURVE) { pTan = pTan2; // Àӽà ±â¿ï±â ÀúÀå(´ÙÀ½ °î¼±ÀÇ ½ÃÀÛÁ¡ ±â¿ï±â) pTan2.x = pScd.x * 2 - pTan2.x; // IllustraterÀÇ ¹æ½ÄÀ» µû¸£±â À§ÇÔ pTan2.y = pScd.y * 2 - pTan2.y; Temp2 = data->pList[data->nCount * 3 - 1].P(); Temp3 = data->pList[data->nCount * 3].P(); if (VectorForm->LineType == 1) { // ±â¿ï±â °øÀ¯ÇÏÁö ¾Ê´Â °î¼± Temp4.x = Temp3.x; Temp4.y = Temp3.y; } else if (VectorForm->LineType == 2) { // ²÷¾îÁø¼± Temp4.x = Temp3.x; Temp4.y = Temp3.y; } else if (VectorForm->LineType == 3) { // ±â¿ï±â À̾îÁö´Â °î¼± Temp4.x = Temp3.x * 2 - Temp2.x; Temp4.y = Temp3.y * 2 - Temp2.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); memset(data->pMask, 0, (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(Temp4); data->pList[data->nCount * 3 - 1].DPoint(pTan2); data->pList[data->nCount * 3].DPoint(pScd); // data->PenThick = PenManagerForm->Pen->Thick; data->PenThick = VectorForm->DrawingThick; // 2005 Vector upgrade data->bRound = !PenManagerForm->Pen->Shape; data->Color = PenManagerForm->PenShape->Pen->Color; } SET_RECT; if (NVector->bClosedState) { data->bClosed = true; NVector->step = 0; NVector->bFstLine = true; MainImageForm->iMainImage->Cursor = crDefault; bJoinState = false; // stepÀÌ 0 À̸é ÃʱâÈ­ ÇØÁØ´Ù - by monkman (2009.11.26) } NVector->bFirst = true; // º¯È­µÈ data->pList¿¡ µû¶ó PatternFillÀ» ´Ù½Ã °è»êÇØÁØ´Ù - by monkman (2005.08.03) if (data->bPatternFill) { MakePatternBitmap(data); } pPoints = NULL; END_LOG; return; fail: if (pPoints) delete[]pPoints; pPoints = NULL; if (data) delete data; data = NULL; END_LOG; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::TextAdd(POINT pFst, String Text, bool bFirstText) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) 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""; if (bFirstText) { if ((data = new TVecData(MainImageForm->Number)) == NULL) goto fail; data->Kind = V_TEXT; data->First = pFst; data->Color = PenManagerForm->PenShape->Pen->Color; data->nCount = Text.Length(); _tcscpy(data->Font.lfFaceName, FontType.c_str()); data->Font.lfHeight = Image->Canvas->Font->Size; data->Font.lfItalic = Image->Canvas->Font->Style.Contains(fsItalic); data->Font.lfUnderline = Image->Canvas->Font->Style.Contains(fsUnderline); if (Image->Canvas->Font->Style.Contains(fsBold)) data->Font.lfWeight = FW_BOLD; else data->Font.lfWeight = FW_NORMAL; data->Font.lfStrikeOut = Image->Canvas->Font->Style.Contains(fsStrikeOut); data->Font.lfEscapement = TextAngle; data->TextString = Text; // widthsum = Image->Canvas->TextWidth(Text) * 0.75; 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); DataList->Add(data); // ======= Undo Test UndoSave(VU_CREATE, DataList->Count - 1); // ======= Undo Test NVector->bFirst = true; } else { height = data->Font.lfHeight; angle = 2 * M_PI * data->Font.lfEscapement / 10 / 360; data->nCount = Text.Length(); 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; data->Second.x = data->First.x + widthsum * cos(angle) - height * sin (angle); data->Second.y = data->First.y - widthsum * sin(angle) - height * cos (angle); rc.top = min(data->First.y, data->Second.y) - data->Font.lfHeight; rc.bottom = max(data->First.y, data->Second.y) + data->Font.lfHeight; rc.left = min(data->First.x, data->Second.x) - data->Font.lfHeight; rc.right = max(data->First.x, data->Second.x) + data->Font.lfHeight; Image->RectPaint(rc); } END_LOG; return; fail: if (data) delete data; data = NULL; END_LOG; } // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- /////////////// Drawing Part // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- void __fastcall TVecDraw::LineDraw(HDC dcDst, int px, int py, int vw, int vh, TMainImageForm *form) { TList *DataList = form->V_DATA; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) HPEN hOldPen = NULL, hPen = NULL; HBRUSH hOldBrush = NULL, hBrush = NULL; LOGBRUSH logbrush; int nDrawMode, nFillMode, nTemp, nPenStyle; RGBQUAD rgb; HFONT font = NULL, oldfont = NULL; Graphics::TBitmap *TempBitmap = NULL; int ZoomIn = form->iMainImage->ZoomIn; int ZoomOut = form->iMainImage->ZoomOut; int PositionX = form->sbHorz->Position; int PositionY = form->sbVert->Position; int FirstX, FirstY, SecondX, SecondY; int R_FirstX, R_FirstY, R_SecondX, R_SecondY; // Gradient ¹ÝÀü °Å¿ï - by monkman (2009.04.15) int nReflectionIndex; // Gradient ¹ÝÀü °Å¿ï - by monkman (2009.04.15) int PositionX2, PositionY2; // Gradient ¹ÝÀü °Å¿ï - by monkman (2009.05.06) double CenterX, CenterY, FontZoom = 1.0; int OffsetX, OffsetY; // by linuxjun for CurvedVectorText int StartX, StartY; int pw; int tx, ty, tfx, tfy; float* dashValues = NULL; RECT ScreenCanvasRect; RECT VectorRect; gdp::Graphics graphics(dcDst); // using GDI+ gdp::PointF *pPoints = NULL; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) gdp::PointF *pRefPoints = NULL; int ReflectionIndex = -1; if (form->NVector->bVectorReflectionMode && ((form->NVector->ReflectionVH == 1 && form->NVector->ReflectionVIndex >= 0) || (form->NVector->ReflectionVH == 2 && form->NVector->ReflectionHIndex >= 0))) { // ¼öÁ÷ ±âÁؼ± if (form->NVector->ReflectionVH == 1) ReflectionIndex = (form->NVector->ReflectionVIndex - PositionX) * ZoomIn / ZoomOut; // ¼öÆò ±âÁؼ± if (form->NVector->ReflectionVH == 2) ReflectionIndex = (form->NVector->ReflectionHIndex - PositionY) * ZoomIn / ZoomOut; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¼Óµµ °³¼± - ÇöÀç º¸¿©Áö´Â ĵ¹ö½ºÀÇ ¿µ¿ªÀ» ±¸ÇÑ´Ù - by monkman (2005.07.12) ScreenCanvasRect.left = 0; ScreenCanvasRect.top = 0; ScreenCanvasRect.right = form->iMainImage->Width; ScreenCanvasRect.bottom = form->iMainImage->Height; // if (form->bRotation) DrawRotationLine(dcDst, px, py); //by linuxjun for CurvedVectorText for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; // ¿ø·¡´Â ¾Æ·¡ ¼Ò½º°¡ ÁÖ¼®Ã³¸® µÇ¾î ÀÖ¾úÀ½.. // ´Ù¸¥ ĵ¹ö½º±îÁö °°ÀÌ ¾÷µ¥ÀÌÆ®µÇ¹Ç·Î ÁÖ¼®Ã³¸® - by monkman (2004.10.05) if (!data->Equal(form->Number)) continue; if (data->bSelected) { if (form->NVector->bProportion) { ProportionTransform(data); // È®´ëÃà¼Ò½Ã¿¡´Â Á¡µéÀÇ TransformÀÌ °¡ÇØÁü SET_RECT; } if (form->NVector->bMergeMode){ // Gradient¿ë Position °è»ê - by monkman (2009.05.06) PositionX2 = (-MergeX - PositionX); PositionY2 = (-MergeY - PositionY); PositionX -= MergeX; PositionY -= MergeY; } } else { PositionX2 = -PositionX; PositionY2 = -PositionY; } // if (form->NVector->bProportion && data->bSelected /* && !data->bMotive */ ) { // ProportionTransform(data); // È®´ëÃà¼Ò½Ã¿¡´Â Á¡µéÀÇ TransformÀÌ °¡ÇØÁü // SET_RECT; // } // // if (form->NVector->bMergeMode && data->bSelected) { // Merge Mode¿¡¼­ ¼±ÅÃµÈ ¿ÀºêÁ§Æ®ÀÇ ¸¶¿ì½º À̵¿¿¡ µû¸¥ ÁÂÇ¥ º¯°æ // // Gradient¿ë Position °è»ê - by monkman (2009.05.06) // PositionX2 = (-MergeX - PositionX); // PositionY2 = (-MergeY - PositionY); // PositionX -= MergeX; // PositionY -= MergeY; // } // else { // PositionX2 = -PositionX; // PositionY2 = -PositionY; // } FirstX = (data->First.x - PositionX) * ZoomIn / ZoomOut - px; FirstY = (data->First.y - PositionY) * ZoomIn / ZoomOut - py; SecondX = (data->Second.x - PositionX) * ZoomIn / ZoomOut - px; SecondY = (data->Second.y - PositionY) * ZoomIn / ZoomOut - py; // Gradient ¹ÝÀü °Å¿ï - by monkman (2009.04.15) if (form->NVector->bVectorReflectionMode && form->NVector->ReflectionVH > 0) { nReflectionIndex = form->NVector->ReflectionVH == 1 ? form->NVector->ReflectionVIndex : form->NVector->ReflectionHIndex; if (form->NVector->ReflectionVH == 1) { R_FirstX = (nReflectionIndex * 2 - data->Second.x + PositionX2) * ZoomIn / ZoomOut - px; R_FirstY = FirstY; R_SecondX = (nReflectionIndex * 2 - data->First.x + PositionX2) * ZoomIn / ZoomOut - px; R_SecondY = SecondY; } else if (form->NVector->ReflectionVH == 2) { R_FirstX = FirstX; R_FirstY = (nReflectionIndex * 2 - data->Second.y + PositionY2) * ZoomIn / ZoomOut - py; R_SecondX = SecondX; R_SecondY = (nReflectionIndex * 2 - data->First.y + PositionY2) * ZoomIn / ZoomOut - py; } } // ¼Óµµ °³¼± - CurveDataÀÇ ¿µ¿ªÀ» ±¸ÇÑ´Ù - by monkman (2005.07.12) if (data->Kind == V_TEXTBOX) { if (data->ListOfAllLine && data->ListOfAllLine->CurveData) { TVecData *CurveData; CurveData = data->ListOfAllLine->CurveData; int Margin; try { Margin = data->ListOfAllLine->GetLineTextBox(0)->lineHeight * 3; } catch(...) { Margin = 0; } VectorRect.left = ((CurveData->First.x - Margin) - PositionX) * ZoomIn / ZoomOut - px; VectorRect.right = ((CurveData->Second.x + Margin) - PositionX) * ZoomIn / ZoomOut - px; VectorRect.top = ((CurveData->First.y - Margin) - PositionY) * ZoomIn / ZoomOut - py; VectorRect.bottom = ((CurveData->Second.y + Margin) - PositionY) * ZoomIn / ZoomOut - py; } else { VectorRect.left = FirstX; VectorRect.right = SecondX; VectorRect.top = FirstY; VectorRect.bottom = SecondY; for (int i = 0; i < 5; i++) { VectorRect.left = min(VectorRect.left, (data->pList[i].x - PositionX) * ZoomIn / ZoomOut - px); VectorRect.right = max(VectorRect.right, (data->pList[i].x - PositionX) * ZoomIn / ZoomOut - px); VectorRect.top = min(VectorRect.top, (data->pList[i].y - PositionY) * ZoomIn / ZoomOut - py); VectorRect.bottom = max(VectorRect.bottom, (data->pList[i].y - PositionY) * ZoomIn / ZoomOut - py); } } } else { if (data->ChildList) { int add = data->childwidth > data->childheight ? data->childwidth : data->childheight; if (add > 0) add /= 2; VectorRect.left = FirstX - add; VectorRect.right = SecondX + add; VectorRect.top = FirstY - add; VectorRect.bottom = SecondY + add; // ¹ÝÀü °Å¿ï ¸ðµå¿¡¼­ ¹ÝÀüÂÊ¿¡ º¸¿©Áö´Â ¿µ¿ªµµ ±×¸®°Ô Çϱâ À§ÇØ - by monkman (2012.01.18) if (form->NVector->bVectorReflectionMode && form->NVector->ReflectionVH > 0) { VectorRect.left = min(FirstX - add, R_FirstX - add); VectorRect.right = max(SecondX + add, R_SecondX + add); VectorRect.top = min(FirstY - add, R_FirstY - add); VectorRect.bottom = max(SecondY + add, R_SecondY + add); } } else { VectorRect.left = FirstX; VectorRect.right = SecondX; VectorRect.top = FirstY; VectorRect.bottom = SecondY; // ¹ÝÀü °Å¿ï ¸ðµå¿¡¼­ ¹ÝÀüÂÊ¿¡ º¸¿©Áö´Â ¿µ¿ªµµ ±×¸®°Ô Çϱâ À§ÇØ - by monkman (2012.01.18) if (form->NVector->bVectorReflectionMode && form->NVector->ReflectionVH > 0) { VectorRect.left = min(FirstX, R_FirstX); VectorRect.right = max(SecondX, R_SecondX); VectorRect.top = min(FirstY, R_FirstY); VectorRect.bottom = max(SecondY, R_SecondY); } } } if (!NVector) return; // ¼Óµµ °³¼± - ¿µ¿ª¾È¿¡ µé¾î¿Â º¤Å͸¸ ±×¸°´Ù - by monkman (2005.07.08) if ((NVector->bMergeMode) || !((VectorRect.left < ScreenCanvasRect.left && VectorRect.right < ScreenCanvasRect.left) || (VectorRect.top < ScreenCanvasRect.top && VectorRect.bottom < ScreenCanvasRect.top) || (VectorRect.left > ScreenCanvasRect.right && VectorRect.right > ScreenCanvasRect.right) || (VectorRect.top > ScreenCanvasRect.bottom && VectorRect.bottom > ScreenCanvasRect.bottom))) { // object¸¶´Ù antialiasing¼³Á¤ if (data->bAntialiasing && !(form->NVector->bSelectedVectorMove)) graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); else graphics.SetSmoothingMode(gdp::SmoothingModeNone); gdp::Color penColor(GetRValue(data->Color), GetGValue(data->Color), GetBValue(data->Color)); gdp::Color FillColor(GetRValue(data->Brush), GetGValue(data->Brush), GetBValue(data->Brush)); gdp::Pen ObjectPen(penColor, data->PenThick * ZoomIn / ZoomOut); gdp::SolidBrush ObjectBrush(FillColor); gdp::GraphicsPath gFillPath; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) gdp::GraphicsPath gRefFillPath; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- pw = data->PenThick / 2; if (data->Kind == V_TEXTBOX) { pPoints = new gdp::PointF[5]; } else { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new gdp::PointF[(data->nCount + 1) * 3 + 1]; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (form->NVector->bVectorReflectionMode && (form->NVector->ReflectionVH == 1 || form->NVector->ReflectionVH == 2)) pRefPoints = new gdp::PointF[(data->nCount + 1) * 3 + 1]; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } else { pPoints = new gdp::PointF[data->nCount * 3 + 1]; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (form->NVector->bVectorReflectionMode && (form->NVector->ReflectionVH == 1 || form->NVector->ReflectionVH == 2)) pRefPoints = new gdp::PointF[data->nCount * 3 + 1]; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } } if (data->Kind == V_CURVE || data->Kind == V_LINE) { if (form->NVector->bVectorReflectionMode) { for (int i = 0; i < data->nCount * 3 + 1; i++) { pPoints[i].X = (data->pList[i].x - PositionX) * ZoomIn / ZoomOut - px; pPoints[i].Y = (data->pList[i].y - PositionY) * ZoomIn / ZoomOut - py; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (form->NVector->ReflectionVH == 1) { pRefPoints[i].X = ReflectionIndex * 2 - (data->pList[i].x - PositionX) * ZoomIn / ZoomOut - px; pRefPoints[i].Y = (data->pList[i].y - PositionY) * ZoomIn / ZoomOut - py; } else if (form->NVector->ReflectionVH == 2) { pRefPoints[i].X = (data->pList[i].x - PositionX) * ZoomIn / ZoomOut - px; pRefPoints[i].Y = ReflectionIndex * 2 - (data->pList[i].y - PositionY) * ZoomIn / ZoomOut - py; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } } else { for (int i = 0; i < data->nCount * 3 + 1; i++) { pPoints[i].X = (data->pList[i].x - PositionX) * ZoomIn / ZoomOut - px; pPoints[i].Y = (data->pList[i].y - PositionY) * ZoomIn / ZoomOut - py; } } } if (data->Kind == V_TEXTBOX) { StartX = (data->StartPoint.x - PositionX) * ZoomIn / ZoomOut - px; StartY = (data->StartPoint.y - PositionY) * ZoomIn / ZoomOut - py; CenterX = (data->CenterPoint.x - PositionX) * ZoomIn / ZoomOut - px; CenterY = (data->CenterPoint.y - PositionY) * ZoomIn / ZoomOut - py; OffsetX = PositionX; OffsetY = PositionY; // by linuxjun for CurvedVectorText FontZoom = (double)ZoomIn / ZoomOut; for (int i = 0; i < 5; i++) { pPoints[i].X = (data->pList[i].x - PositionX) * ZoomIn / ZoomOut - px; pPoints[i].Y = (data->pList[i].y - PositionY) * ZoomIn / ZoomOut - py; } if (form->NVector->bMergeMode && data->bSelected) { CenterX = (FirstX + SecondX) / 2; CenterY = (FirstY + SecondY) / 2; } } if (form->NVector->bMergeMode && data->bSelected) { // µÇµ¹¸®±â PositionX += MergeX; PositionY += MergeY; } //////// Closed Path last point and for nicer close if (data->bClosed && data->PenStyle == P_SOLID) { pPoints[data->nCount * 3] = pPoints[0]; pPoints[data->nCount * 3 + 1] = pPoints[1]; pPoints[data->nCount * 3 + 2] = pPoints[2]; pPoints[data->nCount * 3 + 3] = pPoints[3]; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (form->NVector->bVectorReflectionMode && (form->NVector->ReflectionVH == 1 || form->NVector->ReflectionVH == 2)) { pRefPoints[data->nCount * 3] = pRefPoints[0]; pRefPoints[data->nCount * 3 + 1] = pRefPoints[1]; pRefPoints[data->nCount * 3 + 2] = pRefPoints[2]; pRefPoints[data->nCount * 3 + 3] = pRefPoints[3]; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } //////// nDrawMode = GetROP2(dcDst); nFillMode = GetPolyFillMode(dcDst); if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { // Text´Â Pen°ú Brush°¡ ÇÊ¿ä ¾ø´Ù logbrush.lbStyle = BS_SOLID; logbrush.lbColor = data->Brush; logbrush.lbHatch = 0; if (data->bPatternFill && !data->bModified && ! (form->NVector->bProportion && data->bSelected)) { // PatternFill À϶§ /* SetBrushOrgEx(dcDst, FirstX, FirstY, NULL); if (double(ZoomIn)/double(ZoomOut) == 1.0) { // È®´ë/Ãà¼Ò¸¦ ÇÏÁö ¾ÊÀº »óÅ (Á¶±ÝÀÌ¶óµµ ºü¸£°Ô) hBrush = CreatePatternBrush(data->Bitmap->Handle); hOldBrush = SelectObject(dcDst, hBrush); }else { // È®´ë³ª Ãà¼Ò¸¦ ÇÑ»óÅ¿¡´Â ºñÆ®¸Ê¶ÇÇÑ È®´ë/Ãà¼Ò¸¦ ÇØ ÁØ´Ù TempBitmap = new Graphics::TBitmap; TempBitmap->PixelFormat = pf24bit; TempBitmap->Width = data->Bitmap->Width * ZoomIn / ZoomOut; TempBitmap->Height = data->Bitmap->Height * ZoomIn / ZoomOut; StretchBlt(TempBitmap->Canvas->Handle,0,0,TempBitmap->Width,TempBitmap->Height, data->Bitmap->Canvas->Handle,0,0,data->Bitmap->Width,data->Bitmap->Height,SRCCOPY); hBrush = CreatePatternBrush(TempBitmap->Handle); hOldBrush = SelectObject(dcDst, hBrush); } */ int bltwidth, bltheight; HDC dcPattern = NULL, dcMask = NULL; if (data->nCount == 1) { if (data->pList[0].x == data->pList[1].x && data->pList[0].y == data->pList[1].y && data->pList[2].x == data->pList[3].x && data->pList[2].y == data->pList[3].y) { goto patternfail; } } if (!data->TBitmap) goto patternfail; if (!data->MaskBitmap) goto patternfail; if ((dcPattern = data->TBitmap->CreateDC()) == NULL) goto patternfail; if ((dcMask = data->MaskBitmap->CreateDC()) == NULL) goto patternfail; bltwidth = data->TBitmap->Width * ZoomIn / ZoomOut; bltheight = data->TBitmap->Height * ZoomIn / ZoomOut; // º¤ÅÍ ¿ÀºêÁ§Æ® ¾È¿¡ ä¿îºñÆ®¸Ê À̹ÌÁö Ãà¼Òº¸±â ÇßÀ» ¶§ Ä®¶ó³ª ÆÐÅÏÀÌ º¯ÁúµÇÁö ¾Êµµ·Ï ¼öÁ¤ - by monkman (2007.09.13) if (osVERSION < 2) { // 3.1, 95, 98 SetStretchBltMode(dcDst, COLORONCOLOR); } else { SetStretchBltMode(dcDst, HALFTONE); } tx = 55555; ty = 55555; for (int i = 0; i < data->nCount * 3 + 1; i++) { if (data->pList == NULL) continue; if (tx > data->pList[i].x) tx = data->pList[i].x; if (ty > data->pList[i].y) ty = data->pList[i].y; } if (form->NVector->bMergeMode && data->bSelected) { PositionX -= MergeX; PositionY -= MergeY; } tfx = (tx - PositionX) * ZoomIn / ZoomOut - px; tfy = (ty - PositionY) * ZoomIn / ZoomOut - py; if (form->NVector->bMergeMode && data->bSelected) { // µÇµ¹¸®±â PositionX += MergeX; PositionY += MergeY; } StretchBlt(dcDst, tfx, tfy, bltwidth, bltheight, dcMask, 0, 0, data->MaskBitmap->Width, data->MaskBitmap->Height, SRCAND); StretchBlt(dcDst, tfx, tfy, bltwidth, bltheight, dcPattern, 0, 0, data->TBitmap->Width, data->TBitmap->Height, SRCPAINT); /* StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcMask, 0,0, data->MaskBitmap->Width, data->MaskBitmap->Height, SRCAND); StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcPattern, 0,0, data->TBitmap->Width, data->TBitmap->Height, SRCPAINT); */ patternfail: if (dcPattern) { data->TBitmap->DeleteDC(dcPattern); dcPattern = NULL; } if (dcMask) { data->MaskBitmap->DeleteDC(dcMask); dcMask = NULL; } } else if (data->bFill) { // ColorFill À϶§ hBrush = CreateBrushIndirect(&logbrush); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); } else { // Fill X hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } // if (data->bWinding) SetPolyFillMode(dcDst, WINDING); // ä¿ì±â ¸ðµå ¼±Åà // else SetPolyFillMode(dcDst, ALTERNATE); if (data->bWinding) { gFillPath.SetFillMode(gdp::FillModeWinding); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) gRefFillPath.SetFillMode(gdp::FillModeWinding); // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } else { gFillPath.SetFillMode(gdp::FillModeAlternate); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) gRefFillPath.SetFillMode(gdp::FillModeAlternate); // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } logbrush.lbColor = data->Color; // ÆæÀÇ color¸¦ À§Çؼ­... switch(data->PenStyle) { case 0: nPenStyle = int(PS_SOLID); break; case 1: nPenStyle = int(PS_DASH); break; case 2: nPenStyle = int(PS_DOT); break; case 3: nPenStyle = int(PS_DASHDOT); break; case 4: nPenStyle = int(PS_DASHDOTDOT); break; case 5: nPenStyle = P_USERSTYLE; int count = 0; double temp[6] = { 0, 0, 0, 0, 0, 0 }; CheckUserDashedLine(data, temp, count); dashValues = new float[count]; for (int i = 0; i < count; i++) { dashValues[i] = temp[i]; } ObjectPen.SetDashPattern(dashValues, count); break; // DashStyleCustom = 5 } if (osVERSION < 2) { // 3.1, 95, 98 hPen = CreatePen(psSolid, int(data->PenThick * ZoomIn / ZoomOut + 0.5), data->Color); } else { if (data->bRound) { // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù if (data->CapStyle[0] == 1 && data->ArrowCap) // arrow { gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapRound); } } // 2018.12.06 ÃøÁ¤¿ë È­»ìÇ¥ ÆíÁý±â´É ¼öÁ¤ -------- else if (data->CapStyle[0] == 2 && data->CapStyle[1] == 2) { //@jhs - 2016.10.22 ¾ç¹æÇâ È­»ìÇ¥ Ãß°¡ double CapWidth = data->ArrowCap->LineCapWidth * data->ArrowCap->LineCapWidthScale; // Cap Æø ºñÀ² double CapHeight = data->ArrowCap->LineCapHeight * data->ArrowCap->LineCapWidthScale; double LineCapWidth = 0.5 * data->ArrowCap->LineCapLine; double LineCapWidthPositive = LineCapWidth; double LineCapWidthNegative = 0.5; double LineMiddlePointWidth = 1; gdp::PointF ArrowShape[8] = {gdp::PointF(-(CapWidth),(LineCapWidthPositive)), gdp::PointF(-(CapWidth),-(LineCapWidthNegative)), gdp::PointF(-LineMiddlePointWidth, -(LineCapWidthNegative)), gdp::PointF(-(CapWidth), -(CapHeight)), gdp::PointF((CapWidth), -(CapHeight)), gdp::PointF(LineMiddlePointWidth, -(LineCapWidthNegative)), gdp::PointF((CapWidth), -(LineCapWidthNegative)), gdp::PointF((CapWidth),(LineCapWidthPositive))}; gdp::GraphicsPath capPath; capPath.AddPolygon(ArrowShape,8); gdp::CustomLineCap arrowLineCap(&capPath,NULL); ObjectPen.SetCustomStartCap(&arrowLineCap); if (data->ArrowCap->bShowArrowBoth){ ObjectPen.SetCustomEndCap(&arrowLineCap); } //-------------------------------------------- } else { ObjectPen.SetStartCap(gdp::LineCapRound); ObjectPen.SetEndCap(gdp::LineCapRound); } ObjectPen.SetLineJoin(gdp::LineJoinRound); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapRound); } else { if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapFlat); } } else { ObjectPen.SetStartCap(gdp::LineCapFlat); ObjectPen.SetEndCap(gdp::LineCapFlat); } ObjectPen.SetLineJoin(gdp::LineJoinMiter); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapFlat); } } hOldPen = (HPEN)SelectObject(dcDst, hPen); } else { nTemp = data->Font.lfHeight; data->Font.lfHeight = data->Font.lfHeight * ZoomIn / ZoomOut + 0.5; if (data->Font.lfHeight == 0) data->Font.lfHeight = 1; } if (!(data->ParentTextBox || data->ChildList)) { // by linuxjun for CurvedVectorText PAINT_LINEDRAW_VECTOR; } if (data->ChildList) { // ±×¸®´Â °Í ¿©±â¼­ ±¸Çö. by embakum 20090217 ¸ðƼºê if (form->NVector->bProportion == false) { DrawMotiveObjects(dcDst, data, form, px, py); } else { DrawMotiveObjects(dcDst, data, form, px, py, 4); // Selected LineÀ» ±×¸®Áö ¾ÊÀ½ - by monkman (2009.04.10) } } if (pPoints) delete[]pPoints; pPoints = NULL; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (form->NVector->bVectorReflectionMode && (form->NVector->ReflectionVH == 1 || form->NVector->ReflectionVH == 2)) { if (pRefPoints) delete[]pRefPoints; } pRefPoints = NULL; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { SelectObject(dcDst, hOldBrush); SelectObject(dcDst, hOldPen); } if (hBrush) DeleteObject(hBrush); if (hPen) DeleteObject(hPen); hOldPen = NULL; hOldBrush = NULL; hPen = NULL; hBrush = NULL; if (TempBitmap) { delete TempBitmap; TempBitmap = NULL; } if (!(form->NVector->bSelected)) data->bSelected = false; if (nPenStyle == P_USERSTYLE && dashValues) delete[]dashValues; dashValues = NULL; } if (form->NVector->bProportion && data->bSelected /* && !data->bMotive */ ) ProportionInverseTransform(data); // TransformÀÌ °¡ÇØÁø Á¡À» ´Ù½Ã µÇµ¹¸² if (form->NVector->bProportion && data->bSelected && data->Kind == V_TEXTBOX) // by maxleo21c { data->ProportionFirst.x = (data->ProportionFirst.x - PositionX) * ZoomIn / ZoomOut - px; data->ProportionFirst.y = (data->ProportionFirst.y - PositionY) * ZoomIn / ZoomOut - py; for (int j = 0; j < 5; j++) { PropPoints[j].x = (PropPoints[j].x - PositionX) * ZoomIn / ZoomOut - px; PropPoints[j].y = (PropPoints[j].y - PositionY) * ZoomIn / ZoomOut - py; } DrawProportionTextBox(dcDst, data, CenterX, CenterY, px, py); // È®´ë/Ãà¼ÒµÇ´Â ±ÛÀÚ¸¦ º¸¿©ÁÖ±â À§Çؼ­ } } if (!form->NVector->bSelected){ ptNumber = -1; nSelPos = 0; } // if (form->NVector->bSelected && !(form->NVector->bMergeMode)) // DrawSelectedLine(dcDst, px, py, form); // else { // // -->by linuxjun for CurvedVectorText // if (BeReadyEdit) { // if (CurrentTextBox >= 0 && CurrentTextBox < DataList->Count) { // TVecData * TempData = (TVecData*)DataList->Items[CurrentTextBox]; // if (TempData->Kind == V_TEXTBOX && TempData->ListOfAllLine->CurveData) { // DrawSelectedLine(dcDst, px, py, form); // } // } // } // // <--by linuxjun for CurvedVectorText // ptNumber = -1; // nSelPos = 0; // } // if (form->NVector->bRotation) // DrawRotationLine(dcDst, px, py); if (SpreadStep) DrawSpreadObject(dcDst, px, py); if (form->NVector->bPatternMode && form->NVector->PatternStep) DrawSubBitmap(dcDst, px, py); if (VectorForm) { // VectorForm->DrawCurrent(dcDst, px, py, form); if (form->NVector->step != 0 && form->Number == MainImageForm->Number && ! (VectorForm->NVector->bUserInput)) DrawCurrentObject(dcDst, px, py); if (VectorForm->NVector->bUserInput) DrawUserObject(dcDst, px, py); // 2005 Vector upgrade shin 0228 } pPoints = NULL; pRefPoints = NULL; return; fail: if (pPoints) delete[]pPoints; pPoints = NULL; if (pRefPoints) delete[]pRefPoints; pRefPoints = NULL; if (data) delete data; data = NULL; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::ModifyDraw(HDC dcDst, int px, int py, int vw, int vh, TMainImageForm *form) { TList *DataList = form->V_DATA; if (form->NVector->bSelected && !(form->NVector->bMergeMode)) DrawSelectedLine(dcDst, px, py, form); else { // -->by linuxjun for CurvedVectorText if (BeReadyEdit) { if (CurrentTextBox >= 0 && CurrentTextBox < DataList->Count) { TVecData * TempData = (TVecData*)DataList->Items[CurrentTextBox]; if (TempData->Kind == V_TEXTBOX && TempData->ListOfAllLine->CurveData) { DrawSelectedLine(dcDst, px, py, form); } } } // <--by linuxjun for CurvedVectorText ptNumber = -1; nSelPos = 0; } if (form->NVector->bProportion) DrawProportionLine(dcDst, px, py); else if (form->NVector->bRotation) DrawRotationLine(dcDst, px, py); // if (SpreadStep) // DrawSpreadObject(dcDst, px, py); // if (form->NVector->bPatternMode && form->NVector->PatternStep) // DrawSubBitmap(dcDst, px, py); // if (VectorForm) { // // VectorForm->DrawCurrent(dcDst, px, py, form); // if (form->NVector->step != 0 && form->Number == MainImageForm->Number && ! // (VectorForm->NVector->bUserInput)) // DrawCurrentObject(dcDst, px, py); // if (VectorForm->NVector->bUserInput) // DrawUserObject(dcDst, px, py); // 2005 Vector upgrade shin 0228 // } } // --------------------------------------------------------------------------- void __fastcall TVecDraw::MoveDraw(HDC dcDst, int px, int py, int vw, int vh, TMainImageForm *form) { // ¼Óµµ °³¼±À» À§ÇØ ¿òÁ÷ÀÏ °æ¿ì (GDI·Î ±×¸°´Ù - ¿ÀºêÁ§Æ® À̵¿, ĵ¹ö½º À̵¿ µîÀ» À̵¿ÇÒ ¶§) - by monkman (2005.07.11) TList *DataList = form->V_DATA; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) HPEN hOldPen = NULL, hPen = NULL; HBRUSH hOldBrush = NULL, hBrush = NULL; LOGBRUSH logbrush; int nDrawMode, nFillMode, nTemp, nPenStyle; RGBQUAD rgb; POINT *pPoints = NULL; // pPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) HFONT font = NULL, oldfont = NULL; Graphics::TBitmap *TempBitmap = NULL; int ZoomIn = form->iMainImage->ZoomIn; int ZoomOut = form->iMainImage->ZoomOut; int PositionX = form->sbHorz->Position; int PositionY = form->sbVert->Position; int FirstX, FirstY, SecondX, SecondY; int R_FirstX, R_FirstY, R_SecondX, R_SecondY; // Gradient ¹ÝÀü °Å¿ï - by monkman (2009.04.15) int nReflectionIndex; // Gradient ¹ÝÀü °Å¿ï - by monkman (2009.04.15) int PositionX2, PositionY2; // Gradient ¹ÝÀü °Å¿ï - by monkman (2009.05.06) double CenterX, CenterY, FontZoom = 1.0; int OffsetX, OffsetY; // by linuxjun for CurvedVectorText int StartX, StartY; int pw; int tx, ty, tfx, tfy; DWORD* dashValues = NULL; int count = 0; RECT ScreenCanvasRect; RECT VectorRect; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) POINT *pRefPoints = NULL; // pRefPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) int ReflectionIndex = -1; if (form->NVector->bVectorReflectionMode && ((form->NVector->ReflectionVH == 1 && form->NVector->ReflectionVIndex >= 0) || (form->NVector->ReflectionVH == 2 && form->NVector->ReflectionHIndex >= 0))) { // ¼öÁ÷ ±âÁؼ± if (form->NVector->ReflectionVH == 1) ReflectionIndex = (form->NVector->ReflectionVIndex - PositionX) * ZoomIn / ZoomOut; // ¼öÆò ±âÁؼ± if (form->NVector->ReflectionVH == 2) ReflectionIndex = (form->NVector->ReflectionHIndex - PositionY) * ZoomIn / ZoomOut; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¼Óµµ °³¼± - ÇöÀç º¸¿©Áö´Â ĵ¹ö½ºÀÇ ¿µ¿ªÀ» ±¸ÇÑ´Ù - by monkman (2005.07.12) ScreenCanvasRect.left = 0; ScreenCanvasRect.top = 0; ScreenCanvasRect.right = form->iMainImage->Width; ScreenCanvasRect.bottom = form->iMainImage->Height; if (form->NVector->bRotation) DrawRotationLine(dcDst, px, py); // by linuxjun for CurvedVectorText for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; // ¿ø·¡´Â ¾Æ·¡ ¼Ò½º°¡ ÁÖ¼®Ã³¸® µÇ¾î ÀÖ¾úÀ½.. // ´Ù¸¥ ĵ¹ö½º±îÁö °°ÀÌ ¾÷µ¥ÀÌÆ®µÇ¹Ç·Î ÁÖ¼®Ã³¸® - by monkman (2004.10.05) if (!data->Equal(form->Number)) continue; if (form->NVector->bProportion && data->bSelected) { ProportionTransform(data); // È®´ëÃà¼Ò½Ã¿¡´Â Á¡µéÀÇ TransformÀÌ °¡ÇØÁü // if (data->Kind == V_TEXTBOX && data->ParentTextBox) { SET_RECT; // gradientfill // } } if (form->NVector->bMergeMode && data->bSelected) { // Merge Mode¿¡¼­ ¼±ÅÃµÈ ¿ÀºêÁ§Æ®ÀÇ ¸¶¿ì½º À̵¿¿¡ µû¸¥ ÁÂÇ¥ º¯°æ // Gradient¿ë Position °è»ê - by monkman (2009.05.06) PositionX2 = (-MergeX - PositionX); PositionY2 = (-MergeY - PositionY); PositionX -= MergeX; PositionY -= MergeY; } else { PositionX2 = -PositionX; PositionY2 = -PositionY; } FirstX = (data->First.x - PositionX) * ZoomIn / ZoomOut - px; FirstY = (data->First.y - PositionY) * ZoomIn / ZoomOut - py; SecondX = (data->Second.x - PositionX) * ZoomIn / ZoomOut - px; SecondY = (data->Second.y - PositionY) * ZoomIn / ZoomOut - py; // Gradient ¹ÝÀü °Å¿ï - by monkman (2009.04.15) nReflectionIndex = form->NVector->ReflectionVH == 1 ? form->NVector->ReflectionVIndex : form->NVector->ReflectionHIndex; if (form->NVector->bVectorReflectionMode && form->NVector->ReflectionVH > 0) { if (form->NVector->ReflectionVH == 1) { R_FirstX = (nReflectionIndex * 2 - data->Second.x + PositionX2) * ZoomIn / ZoomOut - px; R_FirstY = FirstY; R_SecondX = (nReflectionIndex * 2 - data->First.x + PositionX2) * ZoomIn / ZoomOut - px; R_SecondY = SecondY; } else if (form->NVector->ReflectionVH == 2) { R_FirstX = FirstX; R_FirstY = (nReflectionIndex * 2 - data->Second.y + PositionY2) * ZoomIn / ZoomOut - py; R_SecondX = SecondX; R_SecondY = (nReflectionIndex * 2 - data->First.y + PositionY2) * ZoomIn / ZoomOut - py; } } pw = data->PenThick / 2; // ¼Óµµ °³¼± - CurveDataÀÇ ¿µ¿ªÀ» ±¸ÇÑ´Ù - by monkman (2005.07.12) if (data->Kind == V_TEXTBOX) { if (data->ListOfAllLine && data->ListOfAllLine->CurveData) { TVecData *CurveData; CurveData = data->ListOfAllLine->CurveData; int Margin; try { Margin = data->ListOfAllLine->GetLineTextBox(0)->lineHeight * 3; } catch(...) { Margin = 0; } VectorRect.left = ((CurveData->First.x - Margin) - PositionX) * ZoomIn / ZoomOut - px; VectorRect.right = ((CurveData->Second.x + Margin) - PositionX) * ZoomIn / ZoomOut - px; VectorRect.top = ((CurveData->First.y - Margin) - PositionY) * ZoomIn / ZoomOut - py; VectorRect.bottom = ((CurveData->Second.y + Margin) - PositionY) * ZoomIn / ZoomOut - py; } else { VectorRect.left = FirstX; VectorRect.right = SecondX; VectorRect.top = FirstY; VectorRect.bottom = SecondY; for (int i = 0; i < 5; i++) { VectorRect.left = min(VectorRect.left, (data->pList[i].x - PositionX) * ZoomIn / ZoomOut - px); VectorRect.right = max(VectorRect.right, (data->pList[i].x - PositionX) * ZoomIn / ZoomOut - px); VectorRect.top = min(VectorRect.top, (data->pList[i].y - PositionY) * ZoomIn / ZoomOut - py); VectorRect.bottom = max(VectorRect.bottom, (data->pList[i].y - PositionY) * ZoomIn / ZoomOut - py); } } } else { if (data->ChildList) { int add = data->childwidth > data->childheight ? data->childwidth : data->childheight; if (add > 0) add /= 2; VectorRect.left = FirstX - add; VectorRect.right = SecondX + add; VectorRect.top = FirstY - add; VectorRect.bottom = SecondY + add; // ¹ÝÀü °Å¿ï ¸ðµå¿¡¼­ ¹ÝÀüÂÊ¿¡ º¸¿©Áö´Â ¿µ¿ªµµ ±×¸®°Ô Çϱâ À§ÇØ - by monkman (2012.01.18) if (form->NVector->bVectorReflectionMode && form->NVector->ReflectionVH > 0) { VectorRect.left = min(FirstX - add, R_FirstX - add); VectorRect.right = max(SecondX + add, R_SecondX + add); VectorRect.top = min(FirstY - add, R_FirstY - add); VectorRect.bottom = max(SecondY + add, R_SecondY + add); } } else { VectorRect.left = FirstX; VectorRect.right = SecondX; VectorRect.top = FirstY; VectorRect.bottom = SecondY; // ¹ÝÀü °Å¿ï ¸ðµå¿¡¼­ ¹ÝÀüÂÊ¿¡ º¸¿©Áö´Â ¿µ¿ªµµ ±×¸®°Ô Çϱâ À§ÇØ - by monkman (2012.01.18) if (form->NVector->bVectorReflectionMode && form->NVector->ReflectionVH > 0) { VectorRect.left = min(FirstX, R_FirstX); VectorRect.right = max(SecondX, R_SecondX); VectorRect.top = min(FirstY, R_FirstY); VectorRect.bottom = max(SecondY, R_SecondY); } } } // ¼Óµµ °³¼± - ¿µ¿ª¾È¿¡ µé¾î¿Â º¤Å͸¸ ±×¸°´Ù - by monkman (2005.07.08) if ((NVector->bMergeMode) || !((VectorRect.left < ScreenCanvasRect.left && VectorRect.right < ScreenCanvasRect.left) || (VectorRect.top < ScreenCanvasRect.top && VectorRect.bottom < ScreenCanvasRect.top) || (VectorRect.left > ScreenCanvasRect.right && VectorRect.right > ScreenCanvasRect.right) || (VectorRect.top > ScreenCanvasRect.bottom && VectorRect.bottom > ScreenCanvasRect.bottom))) { if (data->Kind == V_TEXTBOX) { pPoints = new POINT[5]; } else { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new POINT[(data->nCount + 1) * 3 + 1]; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (form->NVector->bVectorReflectionMode && (form->NVector->ReflectionVH == 1 || form->NVector->ReflectionVH == 2)) pRefPoints = new POINT[(data->nCount + 1) * 3 + 1]; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } else { pPoints = new POINT[data->nCount * 3 + 1]; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (form->NVector->bVectorReflectionMode && (form->NVector->ReflectionVH == 1 || form->NVector->ReflectionVH == 2)) pRefPoints = new POINT[data->nCount * 3 + 1]; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } } if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int i = 0; i < data->nCount * 3 + 1; i++) { pPoints[i].x = (data->pList[i].x - PositionX) * ZoomIn / ZoomOut - px; pPoints[i].y = (data->pList[i].y - PositionY) * ZoomIn / ZoomOut - py; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (form->NVector->bVectorReflectionMode) { if (form->NVector->ReflectionVH == 1) { pRefPoints[i].x = ReflectionIndex * 2 - (data->pList[i].x - PositionX) * ZoomIn / ZoomOut - px; pRefPoints[i].y = (data->pList[i].y - PositionY) * ZoomIn / ZoomOut - py; } if (form->NVector->ReflectionVH == 2) { pRefPoints[i].x = (data->pList[i].x - PositionX) * ZoomIn / ZoomOut - px; pRefPoints[i].y = ReflectionIndex * 2 - (data->pList[i].y - PositionY) * ZoomIn / ZoomOut - py; } } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } } if (data->Kind == V_TEXTBOX) { StartX = (data->StartPoint.x - PositionX) * ZoomIn / ZoomOut - px; StartY = (data->StartPoint.y - PositionY) * ZoomIn / ZoomOut - py; CenterX = (data->CenterPoint.x - PositionX) * ZoomIn / ZoomOut - px; CenterY = (data->CenterPoint.y - PositionY) * ZoomIn / ZoomOut - py; OffsetX = PositionX; OffsetY = PositionY; // by linuxjun for CurvedVectorText FontZoom = (double)ZoomIn / ZoomOut; for (int i = 0; i < 5; i++) { pPoints[i].x = (data->pList[i].x - PositionX) * ZoomIn / ZoomOut - px; pPoints[i].y = (data->pList[i].y - PositionY) * ZoomIn / ZoomOut - py; } if (form->NVector->bMergeMode && data->bSelected) { CenterX = (FirstX + SecondX) / 2; CenterY = (FirstY + SecondY) / 2; } } // ¾Æ·¡·Î ¿Å±è // if (form->bMergeMode && data->bSelected) { // µÇµ¹¸®±â // PositionX += MergeX; // PositionY += MergeY; // } //////// Closed Path last point and for nicer close if (data->bClosed && data->PenStyle == P_SOLID) { pPoints[data->nCount * 3] = pPoints[0]; pPoints[data->nCount * 3 + 1] = pPoints[1]; pPoints[data->nCount * 3 + 2] = pPoints[2]; pPoints[data->nCount * 3 + 3] = pPoints[3]; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (form->NVector->bVectorReflectionMode && (form->NVector->ReflectionVH == 1 || form->NVector->ReflectionVH == 2)) { pRefPoints[data->nCount * 3] = pRefPoints[0]; pRefPoints[data->nCount * 3 + 1] = pRefPoints[1]; pRefPoints[data->nCount * 3 + 2] = pRefPoints[2]; pRefPoints[data->nCount * 3 + 3] = pRefPoints[3]; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } //////// nDrawMode = GetROP2(dcDst); nFillMode = GetPolyFillMode(dcDst); if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { // Text´Â Pen°ú Brush°¡ ÇÊ¿ä ¾ø´Ù logbrush.lbStyle = BS_SOLID; logbrush.lbColor = data->Brush; logbrush.lbHatch = 0; if (data->bPatternFill && !data->bModified && ! (form->NVector->bProportion && data->bSelected)) { // PatternFill À϶§ /* SetBrushOrgEx(dcDst, FirstX, FirstY, NULL); if (double(ZoomIn)/double(ZoomOut) == 1.0) { // È®´ë/Ãà¼Ò¸¦ ÇÏÁö ¾ÊÀº »óÅ (Á¶±ÝÀÌ¶óµµ ºü¸£°Ô) hBrush = CreatePatternBrush(data->Bitmap->Handle); hOldBrush = SelectObject(dcDst, hBrush); }else { // È®´ë³ª Ãà¼Ò¸¦ ÇÑ»óÅ¿¡´Â ºñÆ®¸Ê¶ÇÇÑ È®´ë/Ãà¼Ò¸¦ ÇØ ÁØ´Ù TempBitmap = new Graphics::TBitmap; TempBitmap->PixelFormat = pf24bit; TempBitmap->Width = data->Bitmap->Width * ZoomIn / ZoomOut; TempBitmap->Height = data->Bitmap->Height * ZoomIn / ZoomOut; StretchBlt(TempBitmap->Canvas->Handle,0,0,TempBitmap->Width,TempBitmap->Height, data->Bitmap->Canvas->Handle,0,0,data->Bitmap->Width,data->Bitmap->Height,SRCCOPY); hBrush = CreatePatternBrush(TempBitmap->Handle); hOldBrush = SelectObject(dcDst, hBrush); } */ int bltwidth, bltheight; HDC dcPattern = NULL, dcMask = NULL; if (data->nCount == 1) { if (data->pList[0].x == data->pList[1].x && data->pList[0].y == data->pList[1].y && data->pList[2].x == data->pList[3].x && data->pList[2].y == data->pList[3].y) { goto patternfail; } } if (!data->TBitmap) goto patternfail; if (!data->MaskBitmap) goto patternfail; if ((dcPattern = data->TBitmap->CreateDC()) == NULL) goto patternfail; if ((dcMask = data->MaskBitmap->CreateDC()) == NULL) goto patternfail; bltwidth = data->TBitmap->Width * ZoomIn / ZoomOut; bltheight = data->TBitmap->Height * ZoomIn / ZoomOut; // º¤ÅÍ ¿ÀºêÁ§Æ® ¾È¿¡ ä¿îºñÆ®¸Ê À̹ÌÁö Ãà¼Òº¸±â ÇßÀ» ¶§ Ä®¶ó³ª ÆÐÅÏÀÌ º¯ÁúµÇÁö ¾Êµµ·Ï ¼öÁ¤ - by monkman (2007.09.13) if (osVERSION < 2) { // 3.1, 95, 98 SetStretchBltMode(dcDst, COLORONCOLOR); } else { SetStretchBltMode(dcDst, HALFTONE); } tx = 55555; ty = 55555; for (int i = 0; i < data->nCount * 3 + 1; i++) { if (data->pList == NULL) continue; if (tx > data->pList[i].x) tx = data->pList[i].x; if (ty > data->pList[i].y) ty = data->pList[i].y; } // if (form->bMergeMode && data->bSelected) { // PositionX -= MergeX; // PositionY -= MergeY; // } tfx = (tx - PositionX) * ZoomIn / ZoomOut - px; tfy = (ty - PositionY) * ZoomIn / ZoomOut - py; // if (form->bMergeMode && data->bSelected) { // µÇµ¹¸®±â // PositionX += MergeX; // PositionY += MergeY; // } StretchBlt(dcDst, tfx, tfy, bltwidth, bltheight, dcMask, 0, 0, data->MaskBitmap->Width, data->MaskBitmap->Height, SRCAND); StretchBlt(dcDst, tfx, tfy, bltwidth, bltheight, dcPattern, 0, 0, data->TBitmap->Width, data->TBitmap->Height, SRCPAINT); patternfail: if (dcPattern) { data->TBitmap->DeleteDC(dcPattern); dcPattern = NULL; } if (dcMask) { data->MaskBitmap->DeleteDC(dcMask); dcMask = NULL; } } else if (data->bFill) { // ColorFill À϶§ hBrush = CreateBrushIndirect(&logbrush); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); } else { // Fill X hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } if (data->bWinding) { SetPolyFillMode(dcDst, WINDING); // ä¿ì±â ¸ðµå ¼±Åà } else { SetPolyFillMode(dcDst, ALTERNATE); } logbrush.lbColor = data->Color; // ÆæÀÇ color¸¦ À§Çؼ­... switch(data->PenStyle) { case 0: nPenStyle = int(PS_SOLID); break; case 1: nPenStyle = int(PS_DASH); break; case 2: nPenStyle = int(PS_DOT); break; case 3: nPenStyle = int(PS_DASHDOT); break; case 4: nPenStyle = int(PS_DASHDOTDOT); break; case 5: nPenStyle = P_USERSTYLE; count = data->DashValues[0]; dashValues = new DWORD[count]; for (int i = 0; i < count; i++) { if (i % 2 == 0) { if (data->bRound) { if (data->DashValues[i + 1] * data->PenThick <= data->PenThick) dashValues[i] = 1; else dashValues[i] = data->DashValues[i + 1] * data->PenThick - data->PenThick; } else { dashValues[i] = data->DashValues[i + 1] * data->PenThick; } } else { if (data->bRound) dashValues[i] = data->DashValues[i + 1] * data->PenThick + data->PenThick; else dashValues[i] = data->DashValues[i + 1] * data->PenThick; } } break; } if (osVERSION < 2) { // 3.1, 95, 98 hPen = CreatePen(psSolid, int(data->PenThick * ZoomIn / ZoomOut + 0.5), data->Color); } else { if (data->bRound) { // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù if (nPenStyle == 5) { // Ææ ±½±â°¡ 0.5 ÀÌÇÏÀ̸é 1·Î ±×¸®µµ·Ï ¼öÁ¤ (1¹Ì¸¸À̸é hPenÀÌ NULLÀ̵Ǹç ÀǵµÇÏÁö ¾ÊÀº ±½±â·Î ±×¸®°Ô µÈ´Ù) - by monkman (2007.09.21) if (data->PenThick * ZoomIn / ZoomOut >= 0.5) { hPen = ExtCreatePen (PS_GEOMETRIC | PS_USERSTYLE | PS_ENDCAP_ROUND | PS_JOIN_ROUND, int(data->PenThick * ZoomIn / ZoomOut + 0.5), &logbrush, count, dashValues); } else { hPen = ExtCreatePen (PS_GEOMETRIC | PS_USERSTYLE | PS_ENDCAP_ROUND | PS_JOIN_ROUND, 1, &logbrush, count, dashValues); } } else { // Ææ ±½±â°¡ 0.5 ÀÌÇÏÀ̸é 1·Î ±×¸®µµ·Ï ¼öÁ¤ (1¹Ì¸¸À̸é hPenÀÌ NULLÀ̵Ǹç ÀǵµÇÏÁö ¾ÊÀº ±½±â·Î ±×¸®°Ô µÈ´Ù) - by monkman (2007.09.21) if (data->PenThick * ZoomIn / ZoomOut >= 0.5) { hPen = ExtCreatePen (PS_GEOMETRIC | nPenStyle | PS_ENDCAP_ROUND | PS_JOIN_ROUND, int(data->PenThick * ZoomIn / ZoomOut + 0.5), &logbrush, 0, NULL); } else { hPen = ExtCreatePen (PS_GEOMETRIC | nPenStyle | PS_ENDCAP_ROUND | PS_JOIN_ROUND, 1, &logbrush, 0, NULL); } } } else { if (nPenStyle == 5) { // Ææ ±½±â°¡ 0.5 ÀÌÇÏÀ̸é 1·Î ±×¸®µµ·Ï ¼öÁ¤ (1¹Ì¸¸À̸é hPenÀÌ NULLÀ̵Ǹç ÀǵµÇÏÁö ¾ÊÀº ±½±â·Î ±×¸®°Ô µÈ´Ù) - by monkman (2007.09.21) if (data->PenThick * ZoomIn / ZoomOut >= 0.5) { hPen = ExtCreatePen (PS_GEOMETRIC | PS_USERSTYLE | PS_ENDCAP_FLAT | PS_JOIN_MITER, int(data->PenThick * ZoomIn / ZoomOut + 0.5), &logbrush, count, dashValues); } else { hPen = ExtCreatePen (PS_GEOMETRIC | PS_USERSTYLE | PS_ENDCAP_FLAT | PS_JOIN_MITER, 1, &logbrush, count, dashValues); } } else { // Ææ ±½±â°¡ 0.5 ÀÌÇÏÀ̸é 1·Î ±×¸®µµ·Ï ¼öÁ¤ (1¹Ì¸¸À̸é hPenÀÌ NULLÀ̵Ǹç ÀǵµÇÏÁö ¾ÊÀº ±½±â·Î ±×¸®°Ô µÈ´Ù) - by monkman (2007.09.21) if (data->PenThick * ZoomIn / ZoomOut >= 0.5) { hPen = ExtCreatePen (PS_GEOMETRIC | nPenStyle | PS_ENDCAP_FLAT | PS_JOIN_MITER, int(data->PenThick * ZoomIn / ZoomOut + 0.5), &logbrush, 0, NULL); } else { hPen = ExtCreatePen (PS_GEOMETRIC | nPenStyle | PS_ENDCAP_FLAT | PS_JOIN_MITER, 1, &logbrush, 0, NULL); } } } } hOldPen = (HPEN)SelectObject(dcDst, hPen); } else { nTemp = data->Font.lfHeight; data->Font.lfHeight = data->Font.lfHeight * ZoomIn / ZoomOut + 0.5; if (data->Font.lfHeight == 0) data->Font.lfHeight = 1; } // ====================================== // ===================================== if (!(data->ParentTextBox || data->ChildList)) { // by linuxjun for CurvedVectorText PAINT_MOVEDRAW_VECTOR; } if (data->ChildList) { // ±×¸®´Â °Í ¿©±â¼­ ±¸Çö. by embakum 20090217 ¸ðƼºê // DrawMotiveObjects(dcDst, data, form, px, py); MoveMotiveDraw(dcDst, px, py, vw, vh, form, data); } if (form->NVector->bMergeMode && data->bSelected) { // µÇµ¹¸®±â PositionX += MergeX; PositionY += MergeY; } if (pPoints) delete[]pPoints; pPoints = NULL; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (form->NVector->bVectorReflectionMode && (form->NVector->ReflectionVH == 1 || form->NVector->ReflectionVH == 2)) { if (pRefPoints) delete[]pRefPoints; } pRefPoints = NULL; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { SelectObject(dcDst, hOldBrush); SelectObject(dcDst, hOldPen); } if (hBrush) DeleteObject(hBrush); if (hPen) DeleteObject(hPen); hOldPen = NULL; hOldBrush = NULL; hPen = NULL; hBrush = NULL; if (TempBitmap) { delete TempBitmap; TempBitmap = NULL; } if (!(form->NVector->bSelected)) data->bSelected = false; if (nPenStyle == P_USERSTYLE) delete[]dashValues; dashValues = NULL; } if (form->NVector->bProportion && data->bSelected) ProportionInverseTransform(data); // TransformÀÌ °¡ÇØÁø Á¡À» ´Ù½Ã µÇµ¹¸² if (form->NVector->bProportion && data->bSelected && data->Kind == V_TEXTBOX) // by maxleo21c { data->ProportionFirst.x = (data->ProportionFirst.x - PositionX) * ZoomIn / ZoomOut - px; data->ProportionFirst.y = (data->ProportionFirst.y - PositionY) * ZoomIn / ZoomOut - py; for (int j = 0; j < 5; j++) { PropPoints[j].x = (PropPoints[j].x - PositionX) * ZoomIn / ZoomOut - px; PropPoints[j].y = (PropPoints[j].y - PositionY) * ZoomIn / ZoomOut - py; } DrawProportionTextBox(dcDst, data, CenterX, CenterY, px, py); // È®´ë/Ãà¼ÒµÇ´Â ±ÛÀÚ¸¦ º¸¿©ÁÖ±â À§Çؼ­ } } if (!form->NVector->bSelected){ ptNumber = -1; nSelPos = 0; } // if (form->NVector->bSelected && !(form->NVector->bMergeMode)) // DrawSelectedLine(dcDst, px, py, form); // else { // // -->by linuxjun for CurvedVectorText // if (BeReadyEdit) { // if (CurrentTextBox >= 0 && CurrentTextBox < DataList->Count) { // TVecData * TempData = (TVecData*)DataList->Items[CurrentTextBox]; // if (TempData->Kind == V_TEXTBOX && TempData->ListOfAllLine->CurveData) { // DrawSelectedLine(dcDst, px, py, form); // } // } // } // // <--by linuxjun for CurvedVectorText // ptNumber = -1; // nSelPos = 0; // } // if (form->NVector->bRotation) // DrawRotationLine(dcDst, px, py); if (SpreadStep) DrawSpreadObject(dcDst, px, py); if (form->NVector->bPatternMode && form->NVector->PatternStep) DrawSubBitmap(dcDst, px, py); if (VectorForm) { // VectorForm->DrawCurrent(dcDst, px, py, form); if (form->NVector->step != 0 && form->Number == MainImageForm->Number && ! (VectorForm->NVector->bUserInput)) DrawCurrentObject(dcDst, px, py); if (VectorForm->NVector->bUserInput) DrawUserObject(dcDst, px, py); // 2005 Vector upgrade shin 0228 } pPoints = NULL; pRefPoints = NULL; return; fail: if (pPoints) delete[]pPoints; pPoints = NULL; if (pRefPoints) delete[]pRefPoints; pRefPoints = NULL; if (data) delete data; data = NULL; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::MoveMotiveDraw(HDC dcDst, int px, int py, int vw, int vh, TMainImageForm *form, TVecData *ParentData, int nMode) { // ¼Óµµ °³¼±À» À§ÇØ ¿òÁ÷ÀÏ °æ¿ì (GDI·Î ±×¸°´Ù - ¿ÀºêÁ§Æ® À̵¿, ĵ¹ö½º À̵¿ µîÀ» À̵¿ÇÒ ¶§) - by monkman (2005.07.11) TList *tDataList = ParentData->ChildList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) TList *DataList = new TList; TList * ResultBezierPointList; TPointList *tempPointList; bool bSelectedLine; double rx, ry, ratio; DPOINT firstPoint, onPoint, normalPoint, tempCurpt, tempOldpt; DPOINT *pTempList = NULL; /* centerX¿Í centerY¸¦ ÅëÇØ¼­ CHildµéÀÇ center¸¦ ±¸Çϰí, ¹ØÀÇ bezierpointlistÀÇ ÀÌ¿ë(pTempList)À» ÅëÇØ¼­ childÀÇ À§Ä¡¸¦ Á¤ÇØÁØ´Ù. parent ¸¦ n°³·Î ³ª´«´Ù¸é, 3n+1°³ÀÇ Á¡ÀÌ ÀÖ´Ù. (index·Î 0~3n) 0,3,6,9....3nÀ» °¡Á®´Ù ¾²¸é µÊ. */ double dInterval; TBezierPointList * BezierPointList = new TBezierPointList(); // »ý¼º BezierPointList->Init(ParentData); double CurveLength = BezierPointList->GetCurveLength(); int nSegment; double CenterX = 0.0, CenterY = 0.0, FontZoom = 1.0; // int quotient = int(CurveLength/((ParentData->proportion)*(ParentData->childwidth))); // if (quotient==0) quotient = 1; switch(ParentData->mode) { case 0: // ²Ë ä¿ì±â if (ParentData->proportion == 0) { ParentData->proportion = 1; if (VectorForm) VectorForm->eMotiveProportion->Value = 1; } if (ParentData->childwidth == 0) { ParentData->childwidth = 1; } nSegment = int(CurveLength / ((ParentData->proportion) * (ParentData->childwidth))); if (nSegment == 0) nSegment = 1; ParentData->gap = double(CurveLength / nSegment); ParentData->motivecount = nSegment; break; case 1: // °³¼ö ¼³Á¤ nSegment = ParentData->motivecount; if (nSegment == 0) { nSegment = 1; if (VectorForm) VectorForm->eMotiveCount->Value = 1; } ParentData->gap = double(CurveLength / nSegment); break; case 2: // °£°Ý ¼³Á¤ if (ParentData->gap == 0) { ParentData->gap = 1; if (VectorForm) VectorForm->eMotiveGap->Value = 1; } nSegment = int(CurveLength / ParentData->gap); if (nSegment == 0) nSegment = 1; ParentData->motivecount = nSegment; break; } int count = 1; ResultBezierPointList = BezierPointList->Calculate(ParentData, nSegment); if (!ResultBezierPointList) { delete DataList; DataList; delete BezierPointList; BezierPointList = NULL; return; } pTempList = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * (nSegment * 3 + 1)); double *tangentlist = new double[nSegment + 1]; // ±â¿ï±â¸¦ °¡Áö°í ÀÖ´Â ¹è¿­ firstPoint = FindingNormalOnBezier(&ParentData->pList[0], 0, 0, 0); pTempList[0].x = firstPoint.x; pTempList[0].y = firstPoint.y; pTempList[1].x = firstPoint.x; pTempList[1].y = firstPoint.y; tangentlist[0] = FindCurveTangent(&ParentData->pList[0], 0); for (int i = 0; i < ResultBezierPointList->Count; i++) { tempPointList = (TPointList*)ResultBezierPointList->Items[i]; for (tempPointList->First(); !tempPointList->IsDone(); tempPointList->Next()) { dInterval = tempPointList->CurrentDouble(); // BezierCurve À§ÀÇ Á¡À§Ä¡ // onPoint = FindingPointOnBezier(&tData->pList[i*3], dInterval); // ãÀº Á¡ÀÇ NormalÀÇ À§Ä¡ (ãÀº Á¡Àº ResultBezierPointList¾È¿¡ ÀÖÀ½) normalPoint = FindingNormalOnBezier(&ParentData->pList[i * 3], dInterval, 0, count % 2); tangentlist[count] = FindCurveTangent(&ParentData->pList[i * 3], dInterval); pTempList[count * 3 - 2] = pTempList[count * 3 - 3]; pTempList[count * 3 - 1].x = normalPoint.x; pTempList[count * 3 - 1].y = normalPoint.y; pTempList[count * 3].x = normalPoint.x; pTempList[count * 3].y = normalPoint.y; count++; tempOldpt = tempCurpt; } } if (ParentData->bClosed) { // ´ÝÈù ¿ÀºêÁ§Æ®ÀÇ °æ¿ì ³¡Á¡°ú ùÁ¡À» °°°Ô. pTempList[nSegment * 3] = pTempList[0]; pTempList[nSegment * 3 - 1] = pTempList[0]; } delete BezierPointList; BezierPointList = NULL; //////////////////////////////////////////////////////////////// HPEN hOldPen = NULL, hPen = NULL; HBRUSH hOldBrush = NULL, hBrush = NULL; LOGBRUSH logbrush; int nDrawMode, nFillMode, nTemp, nPenStyle; RGBQUAD rgb; POINT *pPoints = NULL; // pPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) POINT *pRefPoints = NULL; // pRefPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) HFONT font = NULL, oldfont = NULL; Graphics::TBitmap *TempBitmap = NULL; int ZoomIn = form->iMainImage->ZoomIn; int ZoomOut = form->iMainImage->ZoomOut; int PositionX = form->sbHorz->Position; int PositionY = form->sbVert->Position; int FirstX, FirstY, SecondX, SecondY; int R_FirstX, R_FirstY, R_SecondX, R_SecondY; // Gradient ¹ÝÀü °Å¿ï - by monkman (2009.04.15) int PositionX2, PositionY2; // Gradient ¹ÝÀü °Å¿ï - by monkman (2009.05.06) int nReflectionIndex; // Gradient ¹ÝÀü °Å¿ï - by monkman (2009.04.15) int OffsetX, OffsetY; // by linuxjun for CurvedVectorText int StartX, StartY; int pw; DWORD* dashValues = NULL; RECT ScreenCanvasRect; RECT VectorRect; //////////////////////////////////////////////////////////////////// // motive childÀÇ È®´ë Ãà¼Ò TVecData *tdata; for (int i = 0; i < tDataList->Count; i++) { data = (TVecData*)tDataList->Items[i]; tdata = new TVecData(data->GetInstNum()); tdata->Copy(data); for (int l = 0; l < data->nCount * 3 + 1; l++) { tdata->pList[l].x = (data->pList[l].x - ParentData->centerX) * ParentData->proportion + ParentData->centerX; tdata->pList[l].y = (data->pList[l].y - ParentData->centerY) * ParentData->proportion + ParentData->centerY; } DataList->Add(tdata); } // ------------------------------------------ // Mode Ãß°¡ - by monkman (2009.04.09) switch(nMode) { case 0: bSelectedLine = true; break; case 1: // Tag bSelectedLine = false; break; } /////////////////////////////////////////////////////////////////// // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) int ReflectionIndex = -1; if (form->NVector->bVectorReflectionMode && ((form->NVector->ReflectionVH == 1 && form->NVector->ReflectionVIndex >= 0) || (form->NVector->ReflectionVH == 2 && form->NVector->ReflectionHIndex >= 0))) { // ¼öÁ÷ ±âÁؼ± if (form->NVector->ReflectionVH == 1) ReflectionIndex = (form->NVector->ReflectionVIndex - PositionX) * ZoomIn / ZoomOut; // ¼öÆò ±âÁؼ± if (form->NVector->ReflectionVH == 2) ReflectionIndex = (form->NVector->ReflectionHIndex - PositionY) * ZoomIn / ZoomOut; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¼Óµµ °³¼± - ÇöÀç º¸¿©Áö´Â ĵ¹ö½ºÀÇ ¿µ¿ªÀ» ±¸ÇÑ´Ù - by monkman (2005.07.12) ScreenCanvasRect.left = 0; ScreenCanvasRect.top = 0; ScreenCanvasRect.right = form->iMainImage->Width; ScreenCanvasRect.bottom = form->iMainImage->Height; for (int k = 0; k < nSegment; k++) { for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; // todo : ¿ø·¡´Â ¾Æ·¡ ¼Ò½º°¡ ÁÖ¼®Ã³¸® µÇ¾î ÀÖ¾úÀ½.. // ´Ù¸¥ ĵ¹ö½º±îÁö °°ÀÌ ¾÷µ¥ÀÌÆ®µÇ¹Ç·Î ÁÖ¼®Ã³¸® - by monkman (2004.10.05) if (!data->Equal(form->Number)) continue; for (int l = 0; l < data->nCount * 3 + 1; l++) { data->pList[l].x = data->pList[l].x - ParentData->centerX + pTempList [3 * k].x; data->pList[l].y = data->pList[l].y - ParentData->centerY + pTempList [3 * k].y; } for (int l = 0; l < data->nCount * 3 + 1; l++) { double dx = data->pList[l].x - pTempList[3 * k].x; double dy = data->pList[l].y - pTempList[3 * k].y; data->pList[l].x = dx * cos(tangentlist[k]) - dy * sin(tangentlist[k]) + pTempList[3 * k].x; data->pList[l].y = dx * sin(tangentlist[k]) + dy * cos(tangentlist[k]) + pTempList[3 * k].y; } // if (form->NVector->bProportion && data->bSelected) { // ProportionTransform(ParentData); // È®´ëÃà¼Ò½Ã¿¡´Â Á¡µéÀÇ TransformÀÌ °¡ÇØÁü // } if (form->NVector->bMergeMode && ParentData->bSelected) { // Merge Mode¿¡¼­ ¼±ÅÃµÈ ¿ÀºêÁ§Æ®ÀÇ ¸¶¿ì½º À̵¿¿¡ µû¸¥ ÁÂÇ¥ º¯°æ // Gradient¿ë Position °è»ê - by monkman (2009.05.06) PositionX2 = (-MergeX - PositionX); PositionY2 = (-MergeY - PositionY); PositionX -= MergeX; PositionY -= MergeY; } else { PositionX2 = -PositionX; PositionY2 = -PositionY; } SET_RECT; // gradientfill FirstX = (data->First.x - PositionX) * ZoomIn / ZoomOut - px; FirstY = (data->First.y - PositionY) * ZoomIn / ZoomOut - py; SecondX = (data->Second.x - PositionX) * ZoomIn / ZoomOut - px; SecondY = (data->Second.y - PositionY) * ZoomIn / ZoomOut - py; pw = data->PenThick / 2; // Gradient ¹ÝÀü °Å¿ï - by monkman (2009.04.15) nReflectionIndex = form->NVector->ReflectionVH == 1 ? form->NVector->ReflectionVIndex : form->NVector->ReflectionHIndex; if (form->NVector->bVectorReflectionMode && form->NVector->ReflectionVH > 0) { if (form->NVector->ReflectionVH == 1) { R_FirstX = (nReflectionIndex * 2 - data->Second.x + PositionX2) * ZoomIn / ZoomOut - px; R_FirstY = FirstY; R_SecondX = (nReflectionIndex * 2 - data->First.x + PositionX2) * ZoomIn / ZoomOut - px; R_SecondY = SecondY; } else if (form->NVector->ReflectionVH == 2) { R_FirstX = FirstX; R_FirstY = (nReflectionIndex * 2 - data->Second.y + PositionY2) * ZoomIn / ZoomOut - py; R_SecondX = SecondX; R_SecondY = (nReflectionIndex * 2 - data->First.y + PositionY2) * ZoomIn / ZoomOut - py; } } if (data->Kind == V_TEXTBOX) { pPoints = new POINT[5]; } else { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new POINT[(data->nCount + 1) * 3 + 1]; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (form->NVector->bVectorReflectionMode && (form->NVector->ReflectionVH == 1 || form->NVector->ReflectionVH == 2)) pRefPoints = new POINT[(data->nCount + 1) * 3 + 1]; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } else { pPoints = new POINT[data->nCount * 3 + 1]; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (form->NVector->bVectorReflectionMode && (form->NVector->ReflectionVH == 1 || form->NVector->ReflectionVH == 2)) pRefPoints = new POINT[data->nCount * 3 + 1]; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } } if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int i = 0; i < data->nCount * 3 + 1; i++) { pPoints[i].x = (data->pList[i].x - PositionX) * ZoomIn / ZoomOut - px; pPoints[i].y = (data->pList[i].y - PositionY) * ZoomIn / ZoomOut - py; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (form->NVector->bVectorReflectionMode) { if (form->NVector->ReflectionVH == 1) { pRefPoints[i].x = ReflectionIndex * 2 - (data->pList[i].x - PositionX) * ZoomIn / ZoomOut - px; pRefPoints[i].y = (data->pList[i].y - PositionY) * ZoomIn / ZoomOut - py; } if (form->NVector->ReflectionVH == 2) { pRefPoints[i].x = (data->pList[i].x - PositionX) * ZoomIn / ZoomOut - px; pRefPoints[i].y = ReflectionIndex * 2 - (data->pList[i].y - PositionY) * ZoomIn / ZoomOut - py; } } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } } if (data->Kind == V_TEXTBOX) { StartX = (data->StartPoint.x - PositionX) * ZoomIn / ZoomOut - px; StartY = (data->StartPoint.y - PositionY) * ZoomIn / ZoomOut - py; CenterX = (data->CenterPoint.x - PositionX) * ZoomIn / ZoomOut - px; CenterY = (data->CenterPoint.y - PositionY) * ZoomIn / ZoomOut - py; OffsetX = PositionX; OffsetY = PositionY; // by linuxjun for CurvedVectorText FontZoom = (double)ZoomIn / ZoomOut; for (int i = 0; i < 5; i++) { pPoints[i].x = (data->pList[i].x - PositionX) * ZoomIn / ZoomOut - px; pPoints[i].y = (data->pList[i].y - PositionY) * ZoomIn / ZoomOut - py; } if (form->NVector->bMergeMode && ParentData->bSelected) { CenterX = (FirstX + SecondX) / 2; CenterY = (FirstY + SecondY) / 2; } } if (form->NVector->bMergeMode && ParentData->bSelected) { // µÇµ¹¸®±â PositionX += MergeX; PositionY += MergeY; } //////// Closed Path last point and for nicer close if (data->bClosed && data->PenStyle == P_SOLID) { pPoints[data->nCount * 3] = pPoints[0]; pPoints[data->nCount * 3 + 1] = pPoints[1]; pPoints[data->nCount * 3 + 2] = pPoints[2]; pPoints[data->nCount * 3 + 3] = pPoints[3]; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (form->NVector->bVectorReflectionMode && (form->NVector->ReflectionVH == 1 || form->NVector->ReflectionVH == 2)) { pRefPoints[data->nCount * 3] = pRefPoints[0]; pRefPoints[data->nCount * 3 + 1] = pRefPoints[1]; pRefPoints[data->nCount * 3 + 2] = pRefPoints[2]; pRefPoints[data->nCount * 3 + 3] = pRefPoints[3]; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } //////// nDrawMode = GetROP2(dcDst); nFillMode = GetPolyFillMode(dcDst); if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { // Text´Â Pen°ú Brush°¡ ÇÊ¿ä ¾ø´Ù logbrush.lbStyle = BS_SOLID; logbrush.lbColor = data->Brush; logbrush.lbHatch = 0; // bOutline Ãß°¡ (2008. 01. 11 Annualring) if (data->bPatternFill && !data->bModified && ! (form->NVector->bProportion && data->bSelected) /* && !(form->bOutline && data->bSelected) */ ) { // PatternFill À϶§ int bltwidth, bltheight; HDC dcPattern = NULL, dcMask = NULL; MakePatternBitmap(data); if (!data->TBitmap) goto patternfail; if (!data->MaskBitmap) goto patternfail; if ((dcPattern = data->TBitmap->CreateDC()) == NULL) goto patternfail; if ((dcMask = data->MaskBitmap->CreateDC()) == NULL) goto patternfail; bltwidth = data->TBitmap->Width * ZoomIn / ZoomOut; bltheight = data->TBitmap->Height * ZoomIn / ZoomOut; // º¤ÅÍ ¿ÀºêÁ§Æ® ¾È¿¡ ä¿îºñÆ®¸Ê À̹ÌÁö Ãà¼Òº¸±â ÇßÀ» ¶§ Ä®¶ó³ª ÆÐÅÏÀÌ º¯ÁúµÇÁö ¾Êµµ·Ï ¼öÁ¤ - by monkman (2007.09.13) if (osVERSION < 2) { // 3.1, 95, 98 SetStretchBltMode(dcDst, COLORONCOLOR); } else { SetStretchBltMode(dcDst, HALFTONE); } StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcMask, 0, 0, data->MaskBitmap->Width, data->MaskBitmap->Height, SRCAND); StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcPattern, 0, 0, data->TBitmap->Width, data->TBitmap->Height, SRCPAINT); patternfail: if (dcPattern) { data->TBitmap->DeleteDC(dcPattern); dcPattern = NULL; } if (dcMask) { data->MaskBitmap->DeleteDC(dcMask); dcMask = NULL; } } else if (data->bFill) { // ColorFill À϶§ hBrush = CreateBrushIndirect(&logbrush); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); } else { // Fill X hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } if (data->bWinding) { SetPolyFillMode(dcDst, WINDING); // ä¿ì±â ¸ðµå ¼±Åà } else { SetPolyFillMode(dcDst, ALTERNATE); } logbrush.lbColor = data->Color; // ÆæÀÇ color¸¦ À§Çؼ­... switch(data->PenStyle) { case 0: nPenStyle = int(PS_SOLID); break; case 1: nPenStyle = int(PS_DASH); break; case 2: nPenStyle = int(PS_DOT); break; case 3: nPenStyle = int(PS_DASHDOT); break; case 4: nPenStyle = int(PS_DASHDOTDOT); break; case 5: nPenStyle = P_USERSTYLE; count = data->DashValues[0]; dashValues = new DWORD[count]; for (int i = 0; i < count; i++) { if (i % 2 == 0) { if (data->bRound) { if (data->DashValues[i + 1] * data->PenThick <= data->PenThick) dashValues[i] = 1; else dashValues[i] = data->DashValues[i + 1] * data->PenThick - data->PenThick; } else { dashValues[i] = data->DashValues[i + 1] * data->PenThick; } } else { if (data->bRound) dashValues[i] = data->DashValues[i + 1] * data->PenThick + data->PenThick; else dashValues[i] = data->DashValues[i + 1] * data->PenThick; } } break; } if (osVERSION < 2) { // 3.1, 95, 98 hPen = CreatePen(psSolid, int(data->PenThick * ZoomIn / ZoomOut + 0.5), data->Color); } else { if (data->bRound) { // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù if (nPenStyle == 5) { // »ç¿ëÀÚ Á¤ÀÇ Ææ ½ºÅ¸ÀÏ // Ææ ±½±â°¡ 0.5 ÀÌÇÏÀ̸é 1·Î ±×¸®µµ·Ï ¼öÁ¤ (1¹Ì¸¸À̸é hPenÀÌ NULLÀ̵Ǹç ÀǵµÇÏÁö ¾ÊÀº ±½±â·Î ±×¸®°Ô µÈ´Ù) - by monkman (2007.09.21) if (data->PenThick * ZoomIn / ZoomOut >= 0.5) { hPen = ExtCreatePen (PS_GEOMETRIC | PS_USERSTYLE | PS_ENDCAP_ROUND | PS_JOIN_ROUND, int(data->PenThick * ZoomIn / ZoomOut + 0.5), &logbrush, count, dashValues); } else { hPen = ExtCreatePen (PS_GEOMETRIC | PS_USERSTYLE | PS_ENDCAP_ROUND | PS_JOIN_ROUND, 1, &logbrush, count, dashValues); } } else { // Ææ ±½±â°¡ 0.5 ÀÌÇÏÀ̸é 1·Î ±×¸®µµ·Ï ¼öÁ¤ (1¹Ì¸¸À̸é hPenÀÌ NULLÀ̵Ǹç ÀǵµÇÏÁö ¾ÊÀº ±½±â·Î ±×¸®°Ô µÈ´Ù) - by monkman (2007.09.21) if (data->PenThick * ZoomIn / ZoomOut >= 0.5) { hPen = ExtCreatePen (PS_GEOMETRIC | nPenStyle | PS_ENDCAP_ROUND | PS_JOIN_ROUND, int(data->PenThick * ZoomIn / ZoomOut + 0.5), &logbrush, 0, NULL); } else { hPen = ExtCreatePen (PS_GEOMETRIC | nPenStyle | PS_ENDCAP_ROUND | PS_JOIN_ROUND, 1, &logbrush, 0, NULL); } } } else { if (nPenStyle == 5) { // »ç¿ëÀÚ Á¤ÀÇ Ææ ½ºÅ¸ÀÏ // Ææ ±½±â°¡ 0.5 ÀÌÇÏÀ̸é 1·Î ±×¸®µµ·Ï ¼öÁ¤ (1¹Ì¸¸À̸é hPenÀÌ NULLÀ̵Ǹç ÀǵµÇÏÁö ¾ÊÀº ±½±â·Î ±×¸®°Ô µÈ´Ù) - by monkman (2007.09.21) if (data->PenThick * ZoomIn / ZoomOut >= 0.5) { hPen = ExtCreatePen (PS_GEOMETRIC | PS_USERSTYLE | PS_ENDCAP_FLAT | PS_JOIN_MITER, int(data->PenThick * ZoomIn / ZoomOut + 0.5), &logbrush, count, dashValues); } else { hPen = ExtCreatePen (PS_GEOMETRIC | PS_USERSTYLE | PS_ENDCAP_FLAT | PS_JOIN_MITER, 1, &logbrush, count, dashValues); } } else { if (data->PenThick * ZoomIn / ZoomOut >= 0.5) { hPen = ExtCreatePen (PS_GEOMETRIC | nPenStyle | PS_ENDCAP_FLAT | PS_JOIN_MITER, int(data->PenThick * ZoomIn / ZoomOut + 0.5), &logbrush, 0, NULL); } else { hPen = ExtCreatePen (PS_GEOMETRIC | nPenStyle | PS_ENDCAP_FLAT | PS_JOIN_MITER, 1, &logbrush, 0, NULL); } } } } hOldPen = (HPEN)SelectObject(dcDst, hPen); } else { nTemp = data->Font.lfHeight; data->Font.lfHeight = data->Font.lfHeight * ZoomIn / ZoomOut + 0.5; if (data->Font.lfHeight == 0) data->Font.lfHeight = 1; } // ====================================== // ===================================== if (!data->ParentTextBox) { // by linuxjun for CurvedVectorText PAINT_MOVEDRAW_VECTOR; } if (pPoints) delete[]pPoints; pPoints = NULL; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (form->NVector->bVectorReflectionMode && (form->NVector->ReflectionVH == 1 || form->NVector->ReflectionVH == 2)) { if (pRefPoints) delete[]pRefPoints; } pRefPoints = NULL; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { SelectObject(dcDst, hOldBrush); SelectObject(dcDst, hOldPen); } if (hBrush) DeleteObject(hBrush); if (hPen) DeleteObject(hPen); hOldPen = NULL; hOldBrush = NULL; hPen = NULL; hBrush = NULL; if (TempBitmap) { delete TempBitmap; TempBitmap = NULL; } if (nPenStyle == P_USERSTYLE) { delete[]dashValues; } dashValues = NULL; // if (form->bProportion && data->bSelected) // ProportionInverseTransform(ParentData); // TransformÀÌ °¡ÇØÁø Á¡À» ´Ù½Ã µÇµ¹¸² /* if (form->bProportion && data->bSelected && data->Kind == V_TEXTBOX) // by maxleo21c { data->ProportionFirst.x = (data->ProportionFirst.x - PositionX) * ZoomIn / ZoomOut -px; data->ProportionFirst.y = (data->ProportionFirst.y - PositionY) * ZoomIn / ZoomOut -py; for (int j = 0; j < 5; j++) { Temp[j].x = (Temp[j].x - PositionX) * ZoomIn / ZoomOut -px; Temp[j].y = (Temp[j].y - PositionY) * ZoomIn / ZoomOut -py; } // È®´ë/Ãà¼ÒµÇ´Â ±ÛÀÚ¸¦ º¸¿©ÁÖ±â À§Çؼ­ DrawProportionTextBox(dcDst, data, CenterX, CenterY, px, py); } */ // 20090220 °¢µµº¯È¯ reverseÇÊ¿ä for (int l = 0; l < data->nCount * 3 + 1; l++) { double dx = data->pList[l].x - pTempList[3 * k].x; double dy = data->pList[l].y - pTempList[3 * k].y; data->pList[l].x = dx * cos(-tangentlist[k]) - dy * sin (-tangentlist[k]) + pTempList[3 * k].x; data->pList[l].y = dx * sin(-tangentlist[k]) + dy * cos (-tangentlist[k]) + pTempList[3 * k].y; } for (int l = 0; l < data->nCount * 3 + 1; l++) { data->pList[l].x = data->pList[l].x + ParentData->centerX - pTempList [3 * k].x; data->pList[l].y = data->pList[l].y + ParentData->centerY - pTempList [3 * k].y; } } } if (DataList) { for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (data) delete data; } DataList->Clear(); delete DataList; DataList = NULL; } if (tangentlist) delete[]tangentlist; tangentlist = NULL; // ¸Þ¸ð¸® ÇØÁ¦ - by monkman (2009.04.16) if (pTempList) { HeapFree(GetProcessHeap(), 0, pTempList); } pTempList = NULL; pPoints = NULL; pRefPoints = NULL; return; fail: if (DataList) { for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (data) delete data; } DataList->Clear(); delete DataList; DataList = NULL; } if (tangentlist) delete[]tangentlist; tangentlist = NULL; if (pPoints) delete[]pPoints; pPoints = NULL; if (pRefPoints) delete[]pRefPoints; pRefPoints = NULL; if (data) delete data; data = NULL; // ¸Þ¸ð¸® ÇØÁ¦ - by monkman (2009.04.16) if (pTempList) { HeapFree(GetProcessHeap(), 0, pTempList); } pTempList = NULL; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::TransFormDraw(HDC dcDst, int px, int py, bool Back, double dRatio) { TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) HPEN hOldPen = NULL, hPen = NULL; HBRUSH hOldBrush = NULL, hBrush = NULL; LOGBRUSH logbrush; int nDrawMode, nFillMode, nTemp, nPenStyle; RGBQUAD rgb; HFONT font = NULL, oldfont = NULL; Graphics::TBitmap *TempBitmap = NULL; // int PositionX = form->sbHorz->Position; // int PositionY = form->sbVert->Position; TList *TransList; int FirstX, FirstY, SecondX, SecondY; double CenterX, CenterY, FontZoom = 1.0; int OffsetX, OffsetY; // by linuxjun for CurvedVectorText int StartX, StartY; int pw; if (Back) TransList = TransList2; else TransList = TransList1; gdp::Graphics graphics(dcDst); // using GDI+ gdp::PointF *pPoints = NULL; gdp::RectF rtCircle, rtRect; graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); // antialiasing for (int i = 0; i < TransList->Count; i++) { data = (TVecData*)TransList->Items[i]; // if (!data->Equal(form->Number)) continue; FirstX = data->First.x * dRatio - px; FirstY = data->First.y * dRatio - py; SecondX = data->Second.x * dRatio - px; SecondY = data->Second.y * dRatio - py; pw = data->PenThick / 2; gdp::Color penColor(GetRValue(data->Color), GetGValue(data->Color), GetBValue(data->Color)); gdp::Color FillColor(GetRValue(data->Brush), GetGValue(data->Brush), GetBValue(data->Brush)); gdp::Pen ObjectPen(penColor, data->PenThick*dRatio); gdp::SolidBrush ObjectBrush(FillColor); gdp::GraphicsPath gFillPath; float *dashValues = NULL; if (data->Kind == V_TEXTBOX) { pPoints = new gdp::PointF[5]; } else { if (data->bClosed) { pPoints = new gdp::PointF[(data->nCount + 1) * 3 + 1]; } else { pPoints = new gdp::PointF[data->nCount * 3 + 1]; } } if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int i = 0; i < data->nCount * 3 + 1; i++) { pPoints[i].X = data->pList[i].x * dRatio - px; pPoints[i].Y = data->pList[i].y * dRatio - py; } } if (data->Kind == V_TEXTBOX) { StartX = data->StartPoint.x * dRatio - px; StartY = data->StartPoint.y * dRatio - py; CenterX = data->CenterPoint.x * dRatio - px; CenterY = data->CenterPoint.y * dRatio - py; OffsetX = 0; OffsetY = 0; // by linuxjun for CurvedVectorText for (int i = 0; i < 5; i++) { pPoints[i].X = data->pList[i].x * dRatio - px; pPoints[i].Y = data->pList[i].y * dRatio - py; } } //////// Closed Path last point and for nicer close if (data->bClosed && data->PenStyle == P_SOLID) { pPoints[data->nCount * 3] = pPoints[0]; pPoints[data->nCount * 3 + 1] = pPoints[1]; pPoints[data->nCount * 3 + 2] = pPoints[2]; pPoints[data->nCount * 3 + 3] = pPoints[3]; } //////// nDrawMode = GetROP2(dcDst); nFillMode = GetPolyFillMode(dcDst); if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { // Text´Â Pen°ú Brush°¡ ÇÊ¿ä ¾ø´Ù logbrush.lbStyle = BS_SOLID; logbrush.lbColor = data->Brush; logbrush.lbHatch = 0; if (data->bPatternFill) { // PatternFill À϶§ // SetBrushOrgEx(dcDst, FirstX, FirstY, NULL); // hBrush = CreatePatternBrush(data->Bitmap->Handle); // hOldBrush = SelectObject(dcDst, hBrush); } else if (data->bFill) { // ColorFill À϶§ hBrush = CreateBrushIndirect(&logbrush); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); } else { // Fill X hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } // if (data->bWinding) SetPolyFillMode(dcDst, WINDING); // ä¿ì±â ¸ðµå ¼±Åà // else SetPolyFillMode(dcDst, ALTERNATE); if (data->bWinding) gFillPath.SetFillMode(gdp::FillModeWinding); else gFillPath.SetFillMode(gdp::FillModeAlternate); logbrush.lbColor = data->Color; // ÆæÀÇ color¸¦ À§Çؼ­... switch(data->PenStyle) { case 0: nPenStyle = int(PS_SOLID); break; case 1: nPenStyle = int(PS_DASH); break; case 2: nPenStyle = int(PS_DOT); break; case 3: nPenStyle = int(PS_DASHDOT); break; case 4: nPenStyle = int(PS_DASHDOTDOT); break; case 5: nPenStyle = P_USERSTYLE; int count = 0; double temp[6] = { 0, 0, 0, 0, 0, 0 }; CheckUserDashedLine(data, temp, count); dashValues = new float[count]; for (int i = 0; i < count; i++) { dashValues[i] = temp[i]; } ObjectPen.SetDashPattern(dashValues, count); break; // DashStyleCustom = 5 } if (osVERSION < 2) { // 3.1, 95, 98 hPen = CreatePen(psSolid, data->PenThick, data->Color); } else { if (data->bRound) { // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapRound); } } else { ObjectPen.SetStartCap(gdp::LineCapRound); ObjectPen.SetEndCap(gdp::LineCapRound); } ObjectPen.SetLineJoin(gdp::LineJoinRound); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapRound); } else { if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapFlat); } } else { ObjectPen.SetStartCap(gdp::LineCapFlat); ObjectPen.SetEndCap(gdp::LineCapFlat); } ObjectPen.SetLineJoin(gdp::LineJoinMiter); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapFlat); } } hOldPen = (HPEN)SelectObject(dcDst, hPen); } else { nTemp = data->Font.lfHeight; data->Font.lfHeight = data->Font.lfHeight; if (data->Font.lfHeight == 0) data->Font.lfHeight = 1; } if (!(data->ParentTextBox || data->ChildList)) { // by linuxjun for CurvedVectorText PAINT_VECTOR; } if (data->ChildList) { // 090303 embakum motiveobjects DrawMotiveObjects(dcDst, data, MainImageForm, px, py, 1, 0, 0, dRatio, data->GetInstNum()); } if (pPoints) delete[]pPoints; pPoints = NULL; if (dashValues) delete[]dashValues; dashValues = NULL; if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { SelectObject(dcDst, hOldBrush); SelectObject(dcDst, hOldPen); } if (hBrush) DeleteObject(hBrush); if (hPen) DeleteObject(hPen); hPen = NULL; hBrush = NULL; if (TempBitmap) { delete TempBitmap; TempBitmap = NULL; } } // ÀÌÀü¿¡´Â ¼±ÅÃµÈ Çϴûö ¶óÀÎÀ» ±×¸®´Â DrawTransLine() ÇÔ¼ö¸¦ È£ÃâÇØÁÖ¾úÁö¸¸, Vista¿¡¼­ // ÁÂÇ¥°¡ ´Þ¶óÁö´Â ¹®Á¦°¡ ¹ß»ýÇØ¼­, ÀÌ ÇÔ¼ö¿Í DrawTransLine()À» ÇÕÃÆ´Ù. // ÀÌ ÇÔ¼ö´Â PAINT_VECTORÀ» DrawTransLine()ÇÔ¼ö´Â Á÷Á¢ ±×·ÁÁÖ´Â ¹æ¹ýÀ» »ç¿ëÇϴµ¥, // ÁÂÇ¥°ªÀ̳ª dcDst ÁÖ¼Ò°ªÀÌ ¹Ù²î´Â °Íµµ ¾Æ´Ñµ¥, ¿Ö ÀÌ·±ÀÏÀÌ ¹ß»ýÇÏ´ÂÁö ¸ð¸£°Ú´Ù. // by monkman (2007.06.21) // DrawTransLine(dcDst, px, py, Back, dRatio); if (Back) TransList = TransList2; else TransList = TransList1; hPen = CreatePen(psSolid, 1, PathColor); hOldPen = (HPEN)SelectObject(dcDst, hPen); nDrawMode = GetROP2(dcDst); SetROP2(dcDst, R2_COPYPEN); hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); gdp::Color penColor(GetRValue(PathColor), GetGValue(PathColor), GetBValue(PathColor)); gdp::Pen pathPen(penColor, 1); for (int i = 0; i < TransList->Count; i++) { data = (TVecData*)TransList->Items[i]; if (!data->bSelected) continue; FirstX = data->First.x * dRatio - px; FirstY = data->First.y * dRatio - py; SecondX = data->Second.x * dRatio - px; SecondY = data->Second.y * dRatio - py; if (data->Kind == V_TEXTBOX) { pPoints = new gdp::PointF[5]; } else { pPoints = new gdp::PointF[data->nCount * 3 + 1]; } if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int i = 0; i < data->nCount * 3 + 1; i++) { pPoints[i].X = data->pList[i].x * dRatio - px; pPoints[i].Y = data->pList[i].y * dRatio - py; } } if (data->Kind == V_TEXTBOX) { for (int i = 0; i < 5; i++) { pPoints[i].X = data->pList[i].x * dRatio - px; pPoints[i].Y = data->pList[i].y * dRatio - py; } } if (data->bClosed) pPoints[data->nCount * 3] = pPoints[0]; if (data->Kind == V_TEXT) { int height = data->Font.lfHeight; double angle = 2 * M_PI * data->Font.lfEscapement / 10 / 360; if (angle < M_PI / 2 || (angle > M_PI && angle < M_PI * 3 / 2)) { // 1, 3»çºÐ¸é¿¡¼­ FirstX = FirstX - height * sin(angle); SecondX = SecondX + height * sin(angle); } else { // 2, 4»çºÐ¸é¿¡¼­ FirstY = FirstY - height * cos(angle); SecondY = SecondY + height * cos(angle); } } // GDI+·Î º¯°æ - by monkman (2011.04.14) switch(data->Kind) { case V_LINE: for (int i = 0; i < data->nCount * 3 + 1; i++) { // SmallCircle(dcDst, pTemp[i]); SmallCirclePlus(graphics, pathPen, pPoints[i]); // rtCircle = gdp::RectF(pPoints[i].X-4, pPoints[i].Y-4, pPoints[i].X+4, pPoints[i].Y+4); // graphics.DrawEllipse(&pathPen, rtCircle); if ((data->pMask[i / 8] >> i % 8) & 0x01) { // SmallRect2(dcDst, pTemp[i]); SmallRectPlus2(graphics, pathPen, pPoints[i]); // rtRect = gdp::RectF(pPoints[i].X-2, pPoints[i].Y-2, pPoints[i].X+2, pPoints[i].Y+2); // graphics.DrawRectangle(&pathPen, rtRect); } } // Polyline(dcDst, pTemp, data->nCount +1); graphics.DrawPolygon(&pathPen, pPoints, data->nCount + 1); // SmallCircle(dcDst, Point((FirstX+SecondX)/2, (FirstY+SecondY)/2)); SmallCirclePlus(graphics, pathPen, gdp::PointF((FirstX + SecondX) / 2, (FirstY + SecondY) / 2)); // rtCircle = gdp::RectF((FirstX+SecondX/2)-4, (FirstY+SecondY/2)-4, (FirstX+SecondX/2)+4, (FirstY+SecondY/2)+4); // graphics.DrawEllipse(&pathPen, rtCircle); break; case V_TEXTBOX: for (int i = 0; i < 5; i++) { // SmallRect(dcDst, pTemp[i]); SmallRectPlus(graphics, pathPen, pPoints[i]); // rtRect = gdp::RectF(pPoints[i].X-3, pPoints[i].Y-3, pPoints[i].X+3, pPoints[i].Y+3); // graphics.DrawRectangle(&pathPen, rtRect); if ((data->pMask[i / 8] >> i % 8) & 0x01) { // SmallRect2(dcDst, pTemp[i]); SmallRectPlus2(graphics, pathPen, pPoints[i]); // rtRect = gdp::RectF(pPoints[i].X-2, pPoints[i].Y-2, pPoints[i].X+2, pPoints[i].Y+2); // graphics.DrawRectangle(&pathPen, rtRect); } } // Polyline(dcDst, pTemp, 5); graphics.DrawPolygon(&pathPen, pPoints, 5); // SmallRect(dcDst, Point((pTemp[0].x+pTemp[2].x)/2, (pTemp[0].y+pTemp[2].y)/2)); SmallRectPlus(graphics, pathPen, gdp::PointF((FirstX + SecondX) / 2, (FirstY + SecondY) / 2)); // rtRect = gdp::RectF((pPoints[0].X+pPoints[2].X)/2-3, (pPoints[0].Y+pPoints[2].Y)-3, (pPoints[0].X+pPoints[2].X)+3, (pPoints[0].Y+pPoints[2].Y)+3); // graphics.DrawRectangle(&pathPen, rtRect); break; case V_CURVE: graphics.DrawBeziers(&pathPen, pPoints, data->nCount * 3 + 1); graphics.DrawEllipse(&pathPen, (FirstX + SecondX) / 2 - 3, (FirstY + SecondY) / 2 - 3, 7, 7); for (int j = 0; j < data->nCount * 3 + (!data->bClosed); j += 3) { graphics.DrawEllipse(&pathPen, (float)(pPoints[j].X - 3), (float)(pPoints[j].Y - 3), (float)7, (float)7); if ((data->pMask[j / 8] >> j % 8) & 0x01) { graphics.DrawRectangle(&pathPen, (float)pPoints[j].X, (float)pPoints[j].Y, (float)3, (float)3); } } for (int j = 0; j < data->nCount * 3 + (!data->bClosed); j++) { if ((data->pMask[j / 8] >> j % 8) & 0x01) { switch(j % 3) { case 0: // ½ÇÁ¦ Á¡ if (j == data->nCount * 3) { // ¸¶Áö¸· Á¡Àΰæ¿ì!~ graphics.DrawEllipse(&pathPen, (float)(pPoints[j - 1].X - 3), (float)(pPoints[j - 1].Y - 3), (float)7, (float)7); graphics.DrawLine(&pathPen, pPoints[j - 1].X, pPoints[j - 1].Y, pPoints[j].X, pPoints[j].Y); } else { if (j == 0) { if (data->bClosed) { // for Closed path graphics.DrawEllipse(&pathPen, (float)(pPoints[data->nCount * 3 - 1].X - 3), (float)(pPoints[data->nCount * 3 - 1].Y - 3), (float)7, (float)7); graphics.DrawEllipse(&pathPen, (float)(pPoints[j + 1].X - 3), (float)(pPoints[j + 1].Y - 3), (float)7, (float)7); graphics.DrawLine(&pathPen, pPoints[j].X, pPoints[j].Y, pPoints[data->nCount * 3 - 1].X, pPoints[data->nCount * 3 - 1].Y); graphics.DrawLine(&pathPen, pPoints[data->nCount * 3 - 1].X, pPoints[data->nCount * 3 - 1].Y, pPoints[j + 1].X, pPoints[j + 1].Y); } else { // when j equal zero graphics.DrawEllipse(&pathPen, (float)(pPoints[j + 1].X - 3), (float)(pPoints[j + 1].Y - 3), (float)7, (float)7); graphics.DrawLine(&pathPen, pPoints[j].X, pPoints[j].Y, pPoints[j + 1].X, pPoints[j + 1].Y); } } else { // ordinary graphics.DrawEllipse(&pathPen, (float)(pPoints[j - 1].X - 3), (float)(pPoints[j - 1].Y - 3), (float)7, (float)7); graphics.DrawEllipse(&pathPen, (float)(pPoints[j + 1].X - 3), (float)(pPoints[j + 1].Y - 3), (float)7, (float)7); graphics.DrawLine(&pathPen, pPoints[j].X, pPoints[j].Y, pPoints[j - 1].X, pPoints[j - 1].Y); graphics.DrawLine(&pathPen, pPoints[j - 1].X, pPoints[j - 1].Y, pPoints[j + 1].X, pPoints[j + 1].Y); } } break; case 1: if (j == 1) { if (data->bClosed) { graphics.DrawEllipse(&pathPen, (float)(pPoints[data->nCount * 3 - 1].X - 3), (float)(pPoints[data->nCount * 3 - 1].Y - 3), (float)7, (float)7); graphics.DrawEllipse(&pathPen, (float)(pPoints[j].X - 3), (float)(pPoints[j].Y - 3), (float)7, (float)7); graphics.DrawLine(&pathPen, pPoints[j - 1].X, pPoints[j - 1].Y, pPoints[data->nCount * 3 - 1].X, pPoints[data->nCount * 3 - 1].Y); graphics.DrawLine(&pathPen, pPoints[data->nCount * 3 - 1].X, pPoints[data->nCount * 3 - 1].Y, pPoints[j].X, pPoints[j].Y); } else { graphics.DrawEllipse(&pathPen, (float)(pPoints[j].X - 3), (float)(pPoints[j].Y - 3), (float)7, (float)7); graphics.DrawLine(&pathPen, pPoints[j - 1].X, pPoints[j - 1].Y, pPoints[j].X, pPoints[j].Y); } } else { graphics.DrawEllipse(&pathPen, (float)(pPoints[j - 2].X - 3), (float)(pPoints[j - 2].Y - 3), (float)7, (float)7); graphics.DrawEllipse(&pathPen, (float)(pPoints[j].X - 3), (float)(pPoints[j].Y - 3), (float)7, (float)7); graphics.DrawLine(&pathPen, pPoints[j - 1].X, pPoints[j - 1].Y, pPoints[j - 2].X, pPoints[j - 2].Y); graphics.DrawLine(&pathPen, pPoints[j - 2].X, pPoints[j - 2].Y, pPoints[j].X, pPoints[j].Y); } break; case 2: if (j == data->nCount * 3 - 1) { // ¸¶Áö¸· Á¶ÀýÁ¡Àΰæ¿ì!~ if (data->bClosed) { graphics.DrawEllipse(&pathPen, (float)(pPoints[j].X - 3), (float)(pPoints[j].Y - 3), (float)7, (float)7); graphics.DrawEllipse(&pathPen, (float)(pPoints[1].X - 3), (float)(pPoints[1].Y - 3), (float)7, (float)7); graphics.DrawLine(&pathPen, pPoints[j + 1].X, pPoints[j + 1].Y, pPoints[j].X, pPoints[j].Y); graphics.DrawLine(&pathPen, pPoints[j].X, pPoints[j].Y, pPoints[1].X, pPoints[1].Y); } else { graphics.DrawEllipse(&pathPen, (float)(pPoints[j].X - 3), (float)(pPoints[j].Y - 3), (float)7, (float)7); graphics.DrawLine(&pathPen, pPoints[j + 1].X, pPoints[j + 1].Y, pPoints[j].X, pPoints[j].Y); } } else { graphics.DrawEllipse(&pathPen, (float)(pPoints[j].X - 3), (float)(pPoints[j].Y - 3), (float)7, (float)7); graphics.DrawEllipse(&pathPen, (float)(pPoints[j + 2].X - 3), (float)(pPoints[j + 2].Y - 3), (float)7, (float)7); graphics.DrawLine(&pathPen, pPoints[j + 1].X, pPoints[j + 1].Y, pPoints[j].X, pPoints[j].Y); graphics.DrawLine(&pathPen, pPoints[j].X, pPoints[j].Y, pPoints[j + 2].X, pPoints[j + 2].Y); } break; } } } break; default: graphics.DrawRectangle(&pathPen, FirstX, FirstY, SecondX - FirstX, SecondY - FirstY); graphics.DrawEllipse(&pathPen, (float)(FirstX - 3), (float)(FirstY - 3), (float)7, (float)7); graphics.DrawEllipse(&pathPen, (float)(SecondX - 3), (float)(SecondY - 3), (float)7, (float)7); graphics.DrawEllipse(&pathPen, (float)(FirstX - 3), (float)(SecondY - 3), (float)7, (float)7); graphics.DrawEllipse(&pathPen, (float)(SecondX - 3), (float)(FirstY - 3), (float)7, (float)7); graphics.DrawEllipse(&pathPen, (float)((FirstX + SecondX) / 2 - 3), (float)((FirstY + SecondY) / 2 - 3), (float)7, (float)7); break; } if (pPoints) delete[]pPoints; pPoints = NULL; } SetROP2(dcDst, nDrawMode); SelectObject(dcDst, hOldPen); SelectObject(dcDst, hOldBrush); SelectObject(dcDst, hOldPen); if (hBrush) { DeleteObject(hBrush); hBrush = NULL; } if (hPen) { DeleteObject(hPen); hPen = NULL; } pPoints = NULL; return; fail: if (pPoints) delete[]pPoints; pPoints = NULL; if (data) delete data; data = NULL; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::ArbitraryDraw(HDC dcDst, TList *list, double CWidth, double CHeight, int number, double Zoom) { TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) HPEN hOldPen = NULL, hPen = NULL; HBRUSH hOldBrush = NULL, hBrush = NULL; LOGBRUSH logbrush; int nDrawMode, nFillMode, nTemp, nPenStyle; RGBQUAD rgb; HFONT font = NULL, oldfont = NULL; Graphics::TBitmap *TempBitmap = NULL; long minx = MaxInt, miny = MaxInt, maxx = 0, maxy = 0; int cenx, ceny, width, height; int FirstX, FirstY, SecondX, SecondY; double CenterX, CenterY, FontZoom = 1.0; int OffsetX, OffsetY; // by linuxjun for CurvedVectorText int StartX, StartY; int pw; double dTempCenterX, dTempCenterY; // DrawMotiveObject()ÀÇ data->centerX, data->centerY Àӽà ¹é¾÷ - by monkman (2009.04.09) gdp::Graphics graphics(dcDst); // using GDI+ gdp::PointF *pPoints = NULL; graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); // antialiasing for (int i = 0; i < list->Count; i++) { // objectÀ§Ä¡ º¸Á¤ data = (TVecData*)list->Items[i]; if (0 <= number && !data->Equal(number)) continue; SET_RECT; minx = min(minx, data->First.x); minx = min(minx, data->Second.x); maxx = max(maxx, data->First.x); maxx = max(maxx, data->Second.x); miny = min(miny, data->First.y); miny = min(miny, data->Second.y); maxy = max(maxy, data->First.y); maxy = max(maxy, data->Second.y); } cenx = (minx + maxx) / 2; ceny = (miny + maxy) / 2; // center Á¡ width = maxx - minx; height = maxy - miny; // zoom º¸Á¤À§ÇØ if (Zoom == 0.0) { Zoom = CWidth / width < CHeight / height ? CWidth / width : CHeight / height; Zoom *= 0.95; // ¿©¹éÁÖ±â Zoom = Zoom > 1.0 ? 1.0 : Zoom; Zoom = Zoom < 4.0 / 8.0 ? 4.0 / 8.0 : Zoom; } for (int i = 0; i < list->Count; i++) { data = (TVecData*)list->Items[i]; if (0 <= number && !data->Equal(number)) continue; FirstX = (data->First.x - cenx) * Zoom + CWidth / 2 + 0.5; FirstY = (data->First.y - ceny) * Zoom + CHeight / 2 + 0.5; SecondX = (data->Second.x - cenx) * Zoom + CWidth / 2 + 0.5; SecondY = (data->Second.y - ceny) * Zoom + CHeight / 2 + 0.5; pw = data->PenThick / 2; float *dashValues = NULL; gdp::Color penColor(GetRValue(data->Color), GetGValue(data->Color), GetBValue(data->Color)); gdp::Color FillColor(GetRValue(data->Brush), GetGValue(data->Brush), GetBValue(data->Brush)); gdp::Pen ObjectPen(penColor, data->PenThick * Zoom); gdp::SolidBrush ObjectBrush(FillColor); gdp::GraphicsPath gFillPath; if (data->Kind == V_TEXTBOX) { pPoints = new gdp::PointF[5]; } else { if (data->bClosed) { pPoints = new gdp::PointF[(data->nCount + 1) * 3 + 1]; } else { pPoints = new gdp::PointF[data->nCount * 3 + 1]; } } if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int i = 0; i < data->nCount * 3 + 1; i++) { pPoints[i].X = (data->pList[i].x - cenx) * Zoom + CWidth / 2 + 0.5; pPoints[i].Y = (data->pList[i].y - ceny) * Zoom + CHeight / 2 + 0.5; } } if (data->Kind == V_TEXTBOX) { StartX = (data->StartPoint.x - cenx) * Zoom + CWidth / 2 + 0.5; StartY = (data->StartPoint.y - ceny) * Zoom + CHeight / 2 + 0.5; CenterX = (data->CenterPoint.x - cenx) * Zoom + CWidth / 2 + 0.5; CenterY = (data->CenterPoint.y - ceny) * Zoom + CHeight / 2 + 0.5; OffsetX = cenx; OffsetY = ceny; // by linuxjun for CurvedVectorText for (int i = 0; i < 5; i++) { pPoints[i].X = (data->pList[i].x - cenx) * Zoom + CWidth / 2 + 0.5; pPoints[i].Y = (data->pList[i].y - ceny) * Zoom + CHeight / 2 + 0.5; } FontZoom = Zoom; } //////// Closed Path last point and for nicer close if (data->bClosed && data->PenStyle == P_SOLID) { pPoints[data->nCount * 3] = pPoints[0]; pPoints[data->nCount * 3 + 1] = pPoints[1]; pPoints[data->nCount * 3 + 2] = pPoints[2]; pPoints[data->nCount * 3 + 3] = pPoints[3]; } //////// nDrawMode = GetROP2(dcDst); nFillMode = GetPolyFillMode(dcDst); if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { // Text´Â Pen°ú Brush°¡ ÇÊ¿ä ¾ø´Ù logbrush.lbStyle = BS_SOLID; logbrush.lbColor = data->Brush; logbrush.lbHatch = 0; if (data->bPatternFill) { // PatternFill À϶§ SetBrushOrgEx(dcDst, FirstX, FirstY, NULL); hBrush = CreatePatternBrush(data->Bitmap->Handle); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); } else if (data->bFill) { // ColorFill À϶§ hBrush = CreateBrushIndirect(&logbrush); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); } else { // Fill X hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } // if (data->bWinding) SetPolyFillMode(dcDst, WINDING); // ä¿ì±â ¸ðµå ¼±Åà // else SetPolyFillMode(dcDst, ALTERNATE); if (data->bWinding) gFillPath.SetFillMode(gdp::FillModeWinding); else gFillPath.SetFillMode(gdp::FillModeAlternate); logbrush.lbColor = data->Color; // ÆæÀÇ color¸¦ À§Çؼ­... switch(data->PenStyle) { case 0: nPenStyle = int(PS_SOLID); break; case 1: nPenStyle = int(PS_DASH); break; case 2: nPenStyle = int(PS_DOT); break; case 3: nPenStyle = int(PS_DASHDOT); break; case 4: nPenStyle = int(PS_DASHDOTDOT); break; case 5: nPenStyle = P_USERSTYLE; int count = 0; double temp[6] = { 0, 0, 0, 0, 0, 0 }; CheckUserDashedLine(data, temp, count); dashValues = new float[count]; for (int i = 0; i < count; i++) { dashValues[i] = temp[i]; } ObjectPen.SetDashPattern(dashValues, count); break; // DashStyleCustom = 5 } if (osVERSION < 2) { // 3.1, 95, 98 hPen = CreatePen(psSolid, int(data->PenThick * Zoom + 0.5), data->Color); } else { if (data->bRound) { // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù // hPen = ExtCreatePen(PS_GEOMETRIC | nPenStyle | PS_ENDCAP_ROUND | PS_JOIN_ROUND, // int(data->PenThick*Zoom+0.5), &logbrush, 0, NULL ); if (data->CapStyle[0] == 1) ObjectPen.SetStartCap(gdp::LineCapArrowAnchor); else ObjectPen.SetStartCap(gdp::LineCapRound); ObjectPen.SetEndCap(gdp::LineCapRound); ObjectPen.SetLineJoin(gdp::LineJoinRound); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapRound); } else { // hPen = ExtCreatePen(PS_GEOMETRIC | nPenStyle | PS_ENDCAP_FLAT | PS_JOIN_MITER, // int(data->PenThick*Zoom+0.5), &logbrush, 0, NULL ); if (data->CapStyle[0] == 1) ObjectPen.SetStartCap(gdp::LineCapArrowAnchor); else ObjectPen.SetStartCap(gdp::LineCapFlat); ObjectPen.SetEndCap(gdp::LineCapFlat); ObjectPen.SetLineJoin(gdp::LineJoinMiter); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapFlat); } } hOldPen = (HPEN)SelectObject(dcDst, hPen); } else { nTemp = data->Font.lfHeight * Zoom + 0.5; data->Font.lfHeight = data->Font.lfHeight; if (data->Font.lfHeight == 0) data->Font.lfHeight = 1; } if (!(data->ParentTextBox || data->ChildList)) { // by linuxjun for CurvedVectorText PAINT_VECTOR; } if (data->ChildList) { // 090303 embakum motiveobjects DrawMotiveObjects(dcDst, data, MainImageForm, CWidth, CHeight, 2, cenx, ceny, Zoom, number); } if (pPoints) delete[]pPoints; pPoints = NULL; if (dashValues) delete[]dashValues; dashValues = NULL; if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { SelectObject(dcDst, hOldBrush); SelectObject(dcDst, hOldPen); } if (hBrush) DeleteObject(hBrush); if (hPen) DeleteObject(hPen); hOldPen = NULL; hOldBrush = NULL; hPen = NULL; hBrush = NULL; if (TempBitmap) { delete TempBitmap; TempBitmap = NULL; } if (!(NVector->bSelected)) data->bSelected = false; } pPoints = NULL; return; fail: if (pPoints) delete[]pPoints; pPoints = NULL; if (data) delete data; data = NULL; return; } // --------------------------------------------------------------------------- // ½ÇÁÂÇ¥¸¦ ArbitraryDraw¿¡¼­ »ç¿ëÇÑ ÁÂÇ¥·Î ¸ÅÇÎÇÑ´Ù - by monkman (2011.02.21) POINT __fastcall TVecDraw::GetArbitraryPosition(TList *DataList, double CWidth, double CHeight, int nInstNum, double Zoom, int nRealPosX, int nRealPosY) { TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) long minx = MaxInt, miny = MaxInt, maxx = 0, maxy = 0; int width, height; POINT ptReturn = TPoint(0, 0); if (DataList == NULL) return ptReturn; for (int i = 0; i < DataList->Count; i++) { // objectÀ§Ä¡ º¸Á¤ data = (TVecData*)DataList->Items[i]; if (0 <= nInstNum && !data->Equal(nInstNum)) continue; SET_RECT; minx = min(minx, data->First.x); minx = min(minx, data->Second.x); maxx = max(maxx, data->First.x); maxx = max(maxx, data->Second.x); miny = min(miny, data->First.y); miny = min(miny, data->Second.y); maxy = max(maxy, data->First.y); maxy = max(maxy, data->Second.y); } width = maxx - minx; height = maxy - miny; // zoom º¸Á¤À§ÇØ if (Zoom == 0.0) { Zoom = CWidth / width < CHeight / height ? CWidth / width : CHeight / height; Zoom *= 0.95; // ¿©¹éÁÖ±â Zoom = Zoom > 1.0 ? 1.0 : Zoom; Zoom = Zoom < 4.0 / 8.0 ? 4.0 / 8.0 : Zoom; } ptReturn.x = nRealPosX / Zoom; ptReturn.y = nRealPosY / Zoom; return ptReturn; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::PrintDraw(HDC dcDst, int posx, int posy, int WidthRes, int HeightRes, double dpi, int number) { TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) bIsPrint = true; TList *DataList = NVector->DataList; HPEN hOldPen = NULL, hPen = NULL; HBRUSH hOldBrush = NULL, hBrush = NULL; LOGBRUSH logbrush; int nDrawMode, nFillMode, nTemp, nPenStyle; RGBQUAD rgb; HFONT font = NULL, oldfont = NULL; Graphics::TBitmap *TempBitmap = NULL; // int ZoomIn = DPI; double ZoomOut = dpi; int PositionX = posx; int PositionY = posy; int px = 0, py = 0; RECT Src; double FirstX, FirstY, SecondX, SecondY; double CenterX, CenterY, FontZoom = 1.0; int OffsetX, OffsetY; // by linuxjun for CurvedVectorText double StartX, StartY; int pw; gdp::Graphics graphics(dcDst); // using GDI+ 2005 Vector upgrade Shin 0315 gdp::PointF *pPoints = NULL; graphics.SetPageUnit(gdp::UnitPixel); if (MainImageForm->WorkArea->Mask) { Src = MainImageForm->WorkArea->Range; PositionX += Src.left; PositionY += Src.top; } for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(number)) continue; // Á¤È®ÇÑ °è»êÀ» À§Çؼ­ if (data->bAntialiasing) { graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); // antialiasing } else { graphics.SetSmoothingMode(gdp::SmoothingModeNone); } FirstX = (data->First.x - PositionX) * WidthRes / ZoomOut - px; FirstY = (data->First.y - PositionY) * HeightRes / ZoomOut - py; SecondX = (data->Second.x - PositionX) * WidthRes / ZoomOut - px; SecondY = (data->Second.y - PositionY) * HeightRes / ZoomOut - py; pw = data->PenThick / 2; float *dashValues = NULL; gdp::Color penColor(GetRValue(data->Color), GetGValue(data->Color), GetBValue(data->Color)); gdp::Color FillColor(GetRValue(data->Brush), GetGValue(data->Brush), GetBValue(data->Brush)); gdp::Pen ObjectPen(penColor, data->PenThick * WidthRes / ZoomOut); gdp::SolidBrush ObjectBrush(FillColor); gdp::GraphicsPath gFillPath; if (data->Kind == V_TEXTBOX) { pPoints = new gdp::PointF[5]; } else { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new gdp::PointF[(data->nCount + 1) * 3 + 1]; } else { pPoints = new gdp::PointF[data->nCount * 3 + 1]; } } if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int i = 0; i < data->nCount * 3 + 1; i++) { pPoints[i].X = (data->pList[i].x - PositionX) * WidthRes / ZoomOut - px; pPoints[i].Y = (data->pList[i].y - PositionY) * HeightRes / ZoomOut - py; } } if (data->Kind == V_TEXTBOX) { FontZoom = (double)WidthRes / ZoomOut; StartX = (data->StartPoint.x - PositionX) * WidthRes / ZoomOut - px; StartY = (data->StartPoint.y - PositionY) * HeightRes / ZoomOut - py; CenterX = (data->CenterPoint.x - PositionX) * WidthRes / ZoomOut - px; CenterY = (data->CenterPoint.y - PositionY) * HeightRes / ZoomOut - py; OffsetX = PositionX; OffsetY = PositionY; // by linuxjun for CurvedVectorText for (int i = 0; i < 5; i++) { pPoints[i].X = (data->pList[i].x - PositionX) * WidthRes / ZoomOut - px; pPoints[i].Y = (data->pList[i].y - PositionY) * HeightRes / ZoomOut - py; } } //////// Closed Path last point and for nicer close if (data->bClosed && data->PenStyle == P_SOLID) { pPoints[data->nCount * 3] = pPoints[0]; pPoints[data->nCount * 3 + 1] = pPoints[1]; pPoints[data->nCount * 3 + 2] = pPoints[2]; pPoints[data->nCount * 3 + 3] = pPoints[3]; } //////// nDrawMode = GetROP2(dcDst); nFillMode = GetPolyFillMode(dcDst); if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { // Text´Â Pen°ú Brush°¡ ÇÊ¿ä ¾ø´Ù logbrush.lbStyle = BS_SOLID; logbrush.lbColor = data->Brush; logbrush.lbHatch = 0; if (data->bPatternFill) { // PatternFill À϶§ // ÇöÀç ÀÌÀ¯¸¦ ¾Ë¼ö ¾ø´Â ¹®Á¦(StretchBltÈÄ¿¡ data->TBitmap, data->MaskBitmapÀÌ // NULL·Î º¯ÇÏ´Â ¹®Á¦) ¶§¹®¿¡ ¾Æ·¡¿Í °°ÀÌ Ã³¸®Çß´Ù. ÀÌ °æ¿ì¿¡µµ ¹®Á¦°¡ ³²¾Æ // Àִµ¥ NULL°ªÀÌ µÇ¾úÀ» °æ¿ì¿¡ DeleteDC¸¦ ÇÏÁö ¾Ê°Ô µÈ´Ù. // Test ÇØ º» °á°ú Ưº°ÇÑ ¹®Á¦ ¾øÀÌ Print µÇ´Â °ÍÀ¸·Î È®ÀÎ!! maxleo21c(05.07.19) int bltwidth = 0, bltheight = 0; HDC dcPattern = NULL, dcMask = NULL, tempDC = NULL; int mw, mh, pw, ph; if (data->TBitmap == NULL || data->MaskBitmap == NULL) goto next; pw = data->TBitmap->Width; ph = data->TBitmap->Height; mw = data->MaskBitmap->Width; mh = data->MaskBitmap->Height; bltwidth = pw * WidthRes / ZoomOut; bltheight = ph * HeightRes / ZoomOut; if (bltwidth > 0 && bltheight > 0 && mw > 0 && mh > 0) { if ((dcPattern = data->TBitmap->CreateDC()) == NULL) goto next; if ((dcMask = data->MaskBitmap->CreateDC()) == NULL) goto next; // º¤ÅÍ ¿ÀºêÁ§Æ® ¾È¿¡ ä¿îºñÆ®¸Ê À̹ÌÁö Ãà¼Òº¸±â ÇßÀ» ¶§ Ä®¶ó³ª ÆÐÅÏÀÌ º¯ÁúµÇÁö ¾Êµµ·Ï ¼öÁ¤ - by monkman (2007.09.13) if (osVERSION < 2) { // 3.1, 95, 98 SetStretchBltMode(dcDst, COLORONCOLOR); } else { SetStretchBltMode(dcDst, HALFTONE); } StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcMask, 0, 0, mw, mh, SRCAND); StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcPattern, 0, 0, pw, ph, SRCPAINT); next: if (dcPattern && data->TBitmap) { data->TBitmap->DeleteDC(dcPattern); dcPattern = NULL; } if (dcMask && data->MaskBitmap) { data->MaskBitmap->DeleteDC(dcMask); dcMask = NULL; } } } else if (data->bFill) { // ColorFill À϶§ hBrush = CreateBrushIndirect(&logbrush); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); } else { // Fill X hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } if (data->bWinding) SetPolyFillMode(dcDst, WINDING); // ä¿ì±â ¸ðµå ¼±Åà else SetPolyFillMode(dcDst, ALTERNATE); logbrush.lbColor = data->Color; // ÆæÀÇ color¸¦ À§Çؼ­... switch(data->PenStyle) { case 0: { // nPenStyle = int (PS_SOLID); // ±âÁ¸¿¡ »ç¿ë // Solid·Î ó¸®ÇÒ¶§¿¡´Â epson ÇÁ¸°Æ®¿¡¼­ ¶óÀÎÀÌ ²÷¾îÁö´Â Çö»óÀÌ ¹ß°ßµÇ±â // ¶§¹®¿¡ Solid ¶óÀÎÀ» user style·Î ¹Ù²ã ó¸®Çß´Ù. (05.07.12) nPenStyle = P_USERSTYLE; int count = 2; float t_dashValues[2] = { 10, 0 }; ObjectPen.SetDashPattern(t_dashValues, count); break; } case 1: nPenStyle = int(PS_DASH); break; case 2: nPenStyle = int(PS_DOT); break; case 3: nPenStyle = int(PS_DASHDOT); break; case 4: nPenStyle = int(PS_DASHDOTDOT); break; case 5: // 2005 Vector upgrade shin 0315 nPenStyle = P_USERSTYLE; int count = 0; double temp[6] = { 0, 0, 0, 0, 0, 0 }; CheckUserDashedLine(data, temp, count); dashValues = new float[count]; for (int i = 0; i < count; i++) { dashValues[i] = temp[i]; } // int count = data->DashValues[0]; // dashValues = new float[count]; // for (int i = 0; i < count; i++){ // dashValues[i] = data->DashValues[i+1]; // } ObjectPen.SetDashPattern(dashValues, count); break; // DashStyleCustom = 5 } if (osVERSION < 2) { // 3.1, 95, 98 hPen = CreatePen(psSolid, data->PenThick * WidthRes / ZoomOut, data->Color); } else { if (data->bRound) { // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapRound); } } else { ObjectPen.SetStartCap(gdp::LineCapRound); ObjectPen.SetEndCap(gdp::LineCapRound); } ObjectPen.SetLineJoin(gdp::LineJoinRound); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapRound); } else { if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapFlat); } } else { ObjectPen.SetStartCap(gdp::LineCapRound); ObjectPen.SetEndCap(gdp::LineCapRound); } ObjectPen.SetLineJoin(gdp::LineJoinRound); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapRound); } } hOldPen = (HPEN)SelectObject(dcDst, hPen); } else { nTemp = data->Font.lfHeight; data->Font.lfHeight = data->Font.lfHeight * WidthRes / ZoomOut + 0.5; if (data->Font.lfHeight == 0) data->Font.lfHeight = 1; } if (!(data->ParentTextBox || data->ChildList)) { // by linuxjun for CurvedVectorText PAINT_VECTOR; } if (data->ChildList) { // 090303 embakum motiveobjects DrawMotiveObjects(dcDst, data, MainImageForm, 0, 0, 2); } if (pPoints) delete[]pPoints; pPoints = NULL; if (dashValues) delete[]dashValues; dashValues = NULL; if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { SelectObject(dcDst, hOldBrush); SelectObject(dcDst, hOldPen); } if (hBrush) DeleteObject(hBrush); if (hPen) DeleteObject(hPen); hOldPen = NULL; hOldBrush = NULL; hPen = NULL; hBrush = NULL; if (TempBitmap) { delete TempBitmap; TempBitmap = NULL; } } pPoints = NULL; bIsPrint = false; return; fail: if (pPoints) delete[]pPoints; pPoints = NULL; bIsPrint = false; if (data) delete data; data = NULL; } // --------------------------------------------------------------------------- // by siuaa 080408 ¼öÁ¤ // vector ¹Ýº¹ print¸¦ À§ÇØ TSize endCnt, print ¹æ¹ý(Ç¥ÁØ or °¡·ÎºÐÇÒ or ¼¼·ÎºÐÇÒ)À» ÀúÀåÇÏ´Â int item Ãß°¡ // óÀ½¿¡ clippingÀÌ ¾ÈµÇ´Â ¹®Á¦¶§¹®¿¡ ´Ù½Ã ±×·ÁÁÙ¶§ ÇÊ¿äÇÑ color°ª tempColor Ãß°¡ void __fastcall TVecDraw::PrintDraw(HDC dcDst, int posx, int posy, int WidthRes, int HeightRes, double dpi, int number, TSize endCnt, int item, TColor tempColor) { TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) bIsPrint = true; TList *DataList = NVector->DataList; HPEN hOldPen = NULL, hPen = NULL; HBRUSH hOldBrush = NULL, hBrush = NULL; LOGBRUSH logbrush; int nDrawMode, nFillMode, nTemp, nPenStyle; RGBQUAD rgb; HFONT font = NULL, oldfont = NULL; Graphics::TBitmap *TempBitmap = NULL; // int ZoomIn = DPI; double ZoomOut = dpi; int tempPosX = posx; // by siuaa int tempPosY = posy; // by siuaa int PositionX = posx; int PositionY = posy; int px = 0, py = 0; RECT Src; double FirstX, FirstY, SecondX, SecondY; double CenterX, CenterY, FontZoom = 1.0; int OffsetX, OffsetY; // by linuxjun for CurvedVectorText double StartX, StartY; int pw; int left, right, top, bottom; // by siuaa for rgn clipping gdp::Graphics graphics(dcDst); // using GDI+ 2005 Vector upgrade Shin 0315 gdp::PointF *pPoints = NULL; graphics.SetPageUnit(gdp::UnitPixel); if (MainImageForm->WorkArea->Mask) { Src = MainImageForm->WorkArea->Range; // PositionX += Src.left; // PositionY += Src.top; tempPosX += Src.left; tempPosY += Src.top; } else { Src.left = 0; Src.right = MainImageForm->iMainImage->uBitmap->Width; Src.top = 0; Src.bottom = MainImageForm->iMainImage->uBitmap->Height; tempPosX += Src.left; tempPosY += Src.top; } if (item == 1) // °¡·Î ºÐÇÒÀ» À§ÇØ endCnt.cx++; else if (item == 2) // ¼¼·Î ºÐÇÒ À§ÇØ endCnt.cy++; // by siuaa 080408 // ÆäÀÌÁö¿¡ µû¸¥ ¹Ýº¹µÇ¾îÁú patternÀÇ ¼ö¸¸Å­ ¹Ýº¹½ÃÅ´ for (int repY = 0; repY < endCnt.cy; repY++) { for (int repX = 0; repX < endCnt.cx; repX++) { // PRINT ¹æ¹ý(Ç¥ÁØ or °¡·ÎºÐÇÒ or ¼¼·ÎºÐÇÒ)¿¡ µû¸¥ À§Ä¡ ÁöÁ¤ switch(item) { case 0: // Ç¥ÁØ PositionX = tempPosX - repX * (Src.right - Src.left); PositionY = tempPosY - repY * (Src.bottom - Src.top); break; case 1: // °¡·Î ºÐÇÒ if (repY % 2 == 0) PositionX = tempPosX - repX * (Src.right - Src.left); else PositionX = tempPosX + (Src.right - Src.left) / 2 - repX * (Src.right - Src.left); PositionY = tempPosY - repY * (Src.bottom - Src.top); break; case 2: // ¼¼·Î ºÐÇÒ PositionX = tempPosX - repX * (Src.right - Src.left); if (repX % 2 == 0) PositionY = tempPosY - repY * (Src.bottom - Src.top); else PositionY = tempPosY + (Src.bottom - Src.top) / 2 - repY * (Src.bottom - Src.top); break; } // clipping rgn Á¤Çϱâ // if (ZoomOut == 0) Application->MessageBox("zoomÁ¤µµ¿¡ µû¶ó clippingrgnÀ» Á¤ÇØÁÜ. VecDraw.cppÀÇ PrintDrawÇÔ¼ö", "Division Point", MB_OK); // else { left = (tempPosX - PositionX - posx) * WidthRes / ZoomOut - px; right = left + (Src.right - Src.left) * WidthRes / ZoomOut - px; top = (tempPosY - PositionY - posy) * HeightRes / ZoomOut - py; bottom = top + (Src.bottom - Src.top) * HeightRes / ZoomOut - py; // } if (left < 0) left = 0; if (top < 0) top = 0; // ¸¶Áö¸· ºÎºÐ¿¡¼­ ¿µ¿ªÀ» ¹þ¾î³ªÁö ¾Ê°Ô ¿µ¿ª Á¶Á¤ if (item == 1) { if (repY % 2 == 0) { if (repX == endCnt.cx - 1) continue; } else { if (repX == endCnt.cx - 1) right -= ((Src.right - Src.left) * WidthRes / ZoomOut) / 2; } } else if (item == 2) { if (repX % 2 == 0) { if (repY == endCnt.cy - 1) continue; } else { if (repY == endCnt.cy - 1) bottom -= ((Src.bottom - Src.top) * HeightRes / ZoomOut) / 2; } } //// for (int i = 0; i < DataList->Count; i++) { // óÀ½ paint vector¸¦ ÇÒ¶§ clippingÀÌ ¾ÈµÇ´Â ¹®Á¦¸¦ ÇØ°áÇϱâÀ§ÇØ ¸¸µê (¿øÀÎ ÆÄ¾ÇÀÌ ¾ÈµÇ¼­ ±×³É Æí¹ýÀ¸·Î;;) // ÀÓÀÇ·Î (0, 0)°ú (1, 0)¿¡ ±×·ÁÁÖ°í ´Ù½Ã ¿ø·¡ÀÇ »öÀ¸·Î ±×·ÁÁÖ°í ½ÃÀÛÇÔ // k°¡ 0À϶§ (0, 0)°ú (1, 0)¿¡ ÀÓÀÇ·Î ±×·ÁÁÖ°í k°¡ 1À϶§ ¿ø·¡ÀÇ »öÀ¸·Î ´Ù½Ã ±×·ÁÁØ´Ù // k°¡ 2À϶§´Â ±×¸®°íÀÚ Çß´ø data¸¦ ±×·ÁÁØ´Ù int st; if (repX == 0 && repY == 0 && i == 0) // óÀ½ Çѹø¸¸ k°¡ 0ºÎÅÍ ½ÃÀÛÇϵµ·Ï... st = 0; else st = 2; for (int k = st; k < 3; k++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(number)) continue; // Á¤È®ÇÑ °è»êÀ» À§Çؼ­ if (data->bAntialiasing) { graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); // antialiasing } else { graphics.SetSmoothingMode(gdp::SmoothingModeNone); } FirstX = (data->First.x - PositionX) * WidthRes / ZoomOut - px; FirstY = (data->First.y - PositionY) * HeightRes / ZoomOut - py; SecondX = (data->Second.x - PositionX) * WidthRes / ZoomOut - px; SecondY = (data->Second.y - PositionY) * HeightRes / ZoomOut - py; pw = data->PenThick / 2; float *dashValues = NULL; gdp::Color penColor(GetRValue(data->Color), GetGValue(data->Color), GetBValue(data->Color)); if (k == 1) // ÀÓÀÇ·Î ±×¸° Á¡¿¡ ´Ù½Ã ±×·ÁÁÙ ¿ø·¡ »öÀ¸·Î... { penColor.SetFromCOLORREF(tempColor); } gdp::Color FillColor(GetRValue(data->Brush), GetGValue(data->Brush), GetBValue(data->Brush)); gdp::Pen ObjectPen(penColor, data->PenThick * WidthRes / ZoomOut); gdp::SolidBrush ObjectBrush(FillColor); gdp::GraphicsPath gFillPath; // vector°¡ ¿µ¿ªÀ» ¹þ¾î³ª¼­ ´Ù¸¥ °Í°ú °ãÃÄÁö´Â °ÍÀ» ¸·±â À§ÇØ clipping ÇØÁÜ HRGN hrgn = CreateRectRgn(left, top, right, bottom); SelectClipRgn(dcDst, hrgn); if (data->Kind == V_TEXTBOX) { pPoints = new gdp::PointF[5]; } else { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new gdp::PointF[(data->nCount + 1) * 3 + 1]; } else { pPoints = new gdp::PointF[data->nCount * 3 + 1]; } } if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int i = 0; i < data->nCount * 3 + 1; i++) { pPoints[i].X = (data->pList[i].x - PositionX) * WidthRes / ZoomOut - px; pPoints[i].Y = (data->pList[i].y - PositionY) * HeightRes / ZoomOut - py; if (k < 2) // (0, 0), (1, 0)¿¡ ±×·ÁÁÖ±âÀ§ÇØ { pPoints[i].X = i % 2; pPoints[i].Y = 0; } } } if (data->Kind == V_TEXTBOX) { FontZoom = (double)WidthRes / ZoomOut; StartX = (data->StartPoint.x - PositionX) * WidthRes / ZoomOut - px; StartY = (data->StartPoint.y - PositionY) * HeightRes / ZoomOut - py; CenterX = (data->CenterPoint.x - PositionX) * WidthRes / ZoomOut - px; CenterY = (data->CenterPoint.y - PositionY) * HeightRes / ZoomOut - py; OffsetX = PositionX; OffsetY = PositionY; // by linuxjun for CurvedVectorText for (int i = 0; i < 5; i++) { pPoints[i].X = (data->pList[i].x - PositionX) * WidthRes / ZoomOut - px; pPoints[i].Y = (data->pList[i].y - PositionY) * HeightRes / ZoomOut - py; if (k < 2) // (0, 0), (1, 0)¿¡ ±×·ÁÁÖ±âÀ§ÇØ { pPoints[i].X = i % 2; pPoints[i].Y = 0; } } } //////// Closed Path last point and for nicer close if (data->bClosed && data->PenStyle == P_SOLID) { pPoints[data->nCount * 3] = pPoints[0]; pPoints[data->nCount * 3 + 1] = pPoints[1]; pPoints[data->nCount * 3 + 2] = pPoints[2]; pPoints[data->nCount * 3 + 3] = pPoints[3]; } //////// nDrawMode = GetROP2(dcDst); nFillMode = GetPolyFillMode(dcDst); if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { // Text´Â Pen°ú Brush°¡ ÇÊ¿ä ¾ø´Ù logbrush.lbStyle = BS_SOLID; logbrush.lbColor = data->Brush; logbrush.lbHatch = 0; if (data->bPatternFill) { // PatternFill À϶§ // ÇöÀç ÀÌÀ¯¸¦ ¾Ë¼ö ¾ø´Â ¹®Á¦(StretchBltÈÄ¿¡ data->TBitmap, data->MaskBitmapÀÌ // NULL·Î º¯ÇÏ´Â ¹®Á¦) ¶§¹®¿¡ ¾Æ·¡¿Í °°ÀÌ Ã³¸®Çß´Ù. ÀÌ °æ¿ì¿¡µµ ¹®Á¦°¡ ³²¾Æ // Àִµ¥ NULL°ªÀÌ µÇ¾úÀ» °æ¿ì¿¡ DeleteDC¸¦ ÇÏÁö ¾Ê°Ô µÈ´Ù. // Test ÇØ º» °á°ú Ưº°ÇÑ ¹®Á¦ ¾øÀÌ Print µÇ´Â °ÍÀ¸·Î È®ÀÎ!! maxleo21c(05.07.19) int bltwidth = 0, bltheight = 0; HDC dcPattern = NULL, dcMask = NULL, tempDC = NULL; int pw = 0, ph = 0, mw = 0, mh = 0; if (data->TBitmap == NULL || data->MaskBitmap == NULL) goto next; pw = data->TBitmap->Width; ph = data->TBitmap->Height; mw = data->MaskBitmap->Width; mh = data->MaskBitmap->Height; bltwidth = pw * WidthRes / ZoomOut; bltheight = ph * HeightRes / ZoomOut; if (bltwidth <= 0 || bltheight <= 0 || mw <= 0 || mh <= 0) goto next; if ((dcPattern = data->TBitmap->CreateDC()) == NULL) goto next; if ((dcMask = data->MaskBitmap->CreateDC()) == NULL) goto next; // º¤ÅÍ ¿ÀºêÁ§Æ® ¾È¿¡ ä¿îºñÆ®¸Ê À̹ÌÁö Ãà¼Òº¸±â ÇßÀ» ¶§ Ä®¶ó³ª ÆÐÅÏÀÌ º¯ÁúµÇÁö ¾Êµµ·Ï ¼öÁ¤ - by monkman (2007.09.13) if (osVERSION < 2) { // 3.1, 95, 98 SetStretchBltMode(dcDst, COLORONCOLOR); } else { SetStretchBltMode(dcDst, HALFTONE); } StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcMask, 0, 0, mw, mh, SRCAND); StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcPattern, 0, 0, pw, ph, SRCPAINT); next: if (dcPattern && data->TBitmap) { data->TBitmap->DeleteDC(dcPattern); dcPattern = NULL; } if (dcMask && data->MaskBitmap) { data->MaskBitmap->DeleteDC(dcMask); dcMask = NULL; } } else if (data->bFill) { // ColorFill À϶§ hBrush = CreateBrushIndirect(&logbrush); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); } else { // Fill X hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } if (data->bWinding) SetPolyFillMode(dcDst, WINDING); // ä¿ì±â ¸ðµå ¼±Åà else SetPolyFillMode(dcDst, ALTERNATE); logbrush.lbColor = data->Color; // ÆæÀÇ color¸¦ À§Çؼ­... switch(data->PenStyle) { case 0: { // nPenStyle = int (PS_SOLID); // ±âÁ¸¿¡ »ç¿ë // Solid·Î ó¸®ÇÒ¶§¿¡´Â epson ÇÁ¸°Æ®¿¡¼­ ¶óÀÎÀÌ ²÷¾îÁö´Â Çö»óÀÌ ¹ß°ßµÇ±â // ¶§¹®¿¡ Solid ¶óÀÎÀ» user style·Î ¹Ù²ã ó¸®Çß´Ù. (05.07.12) nPenStyle = P_USERSTYLE; int count = 2; float t_dashValues[2] = { 10, 0 }; ObjectPen.SetDashPattern(t_dashValues, count); break; } case 1: nPenStyle = int(PS_DASH); break; case 2: nPenStyle = int(PS_DOT); break; case 3: nPenStyle = int(PS_DASHDOT); break; case 4: nPenStyle = int(PS_DASHDOTDOT); break; case 5: // 2005 Vector upgrade shin 0315 nPenStyle = P_USERSTYLE; int count = 0; double temp[6] = { 0, 0, 0, 0, 0, 0 }; CheckUserDashedLine(data, temp, count); dashValues = new float[count]; for (int i = 0; i < count; i++) { dashValues[i] = temp[i]; } ObjectPen.SetDashPattern(dashValues, count); break; // DashStyleCustom = 5 } if (osVERSION < 2) { // 3.1, 95, 98 hPen = CreatePen(psSolid, data->PenThick * WidthRes / ZoomOut, data->Color); } else { if (data->bRound) { // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapRound); } } else { ObjectPen.SetStartCap(gdp::LineCapRound); ObjectPen.SetEndCap(gdp::LineCapRound); } ObjectPen.SetLineJoin(gdp::LineJoinRound); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapRound); } else { if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapFlat); } } else { ObjectPen.SetStartCap(gdp::LineCapFlat); ObjectPen.SetEndCap(gdp::LineCapFlat); } ObjectPen.SetLineJoin(gdp::LineJoinMiter); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapFlat); } } hOldPen = (HPEN)SelectObject(dcDst, hPen); } else { nTemp = data->Font.lfHeight; data->Font.lfHeight = data->Font.lfHeight * WidthRes / ZoomOut + 0.5; if (data->Font.lfHeight == 0) data->Font.lfHeight = 1; } if (!(data->ParentTextBox || data->ChildList)) { // by linuxjun for CurvedVectorText // PAINT_VECTOR; // ±âÁ¸ PAINT_VECTOR¸¦ »ç¿ëÇÏ¿´Áö¸¸ ÀÛ¾÷±¸¿ª ¸®ÇÍ º¤ÅÍ ¹Ì¸®º¸±â ¹× Ãâ·ÂÀ» °³¹ß Çϸ鼭 // RegionÀ» ÀÌ¿ëÇϴµ¥ Gradient¿¡¼­µµ RegionÀ» »ç¿ëÇÏ¿© Á¤»óÀûÀ¸·Î Ãâ·ÂÀÌ µÇÁö ¾Ê´Â ¹®Á¦°¡ // ÀÖ¾ù´Ù. ±×·¡¼­ ±× ºÎºÐÀ» ¼Ò½º¿¡ Ãß°¡Çϰí SelectClipRgn(dcDst, hrgn); ÇÔ¼ö¸¦ ³Ö¾ú´Ù. // by david 090508 SetROP2(dcDst, R2_COPYPEN); switch(data->Kind) { case V_LINE: graphics.DrawPolygon(&ObjectPen, pPoints, data->nCount + 1); break; case V_CURVE: if (data->bGradientFill) { DrawGradientFill(dcDst, data, pPoints, data->nCount * 3 + 1, FirstX, FirstY, SecondX, SecondY); SelectClipRgn(dcDst, hrgn); } if (data->bClosed && data->PenStyle == P_SOLID) { graphics.DrawBeziers(&ObjectPen, pPoints, (data->nCount + 1) * 3 + 1); } else { graphics.DrawBeziers(&ObjectPen, pPoints, data->nCount * 3 + 1); } if (data->bFill) { gFillPath.AddBeziers(pPoints, data->nCount * 3 + 1); graphics.FillPath(&ObjectBrush, &gFillPath); graphics.DrawPath(&ObjectPen, &gFillPath); } break; case V_RECT: if (data->bRound) RoundRect(dcDst, FirstX, FirstY, SecondX, SecondY, pw, pw); else Rectangle(dcDst, FirstX, FirstY, SecondX, SecondY); break; case V_ELLIPSE: Ellipse(dcDst, FirstX, FirstY, SecondX, SecondY); break; case V_TEXT: Char * tempstr; tempstr = (Char*)malloc(data->nCount); for (int k = 0; k < data->nCount; k++) tempstr[k] = Char(data->TextString[k + 1]); SetTextAlign(dcDst, TA_BOTTOM); SetTextColor(dcDst, data->Color); SetBkMode(dcDst, TRANSPARENT); font = CreateFontIndirect(&data->Font); oldfont = (HFONT)SelectObject(dcDst, font); TextOut(dcDst, FirstX, FirstY, tempstr, data->nCount); SelectObject(dcDst, oldfont); DeleteObject(font); data->Font.lfHeight = nTemp; free(tempstr); break; case V_TEXTBOX: if (BeReadyEdit && CurrentTextBox == i) DrawEditTextBox(dcDst, data, StartX, StartY, FontZoom, CenterX, CenterY, OffsetX, OffsetY); else DrawTextBox(dcDst, data, StartX, StartY, CenterX, CenterY, FontZoom, OffsetX, OffsetY); break; } SetROP2(dcDst, nDrawMode); SetPolyFillMode(dcDst, nFillMode); } if (k == 2 && data->ChildList) { // 090303 embakum motiveobjects PrintDrawMotive(data, dcDst, PositionX, PositionY, WidthRes, HeightRes, dpi, number, endCnt, item, tempColor, hrgn); } if (pPoints) delete[]pPoints; pPoints = NULL; if (dashValues) delete[]dashValues; dashValues = NULL; if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { SelectObject(dcDst, hOldBrush); SelectObject(dcDst, hOldPen); } if (hBrush) DeleteObject(hBrush); if (hPen) DeleteObject(hPen); hOldPen = NULL; hOldBrush = NULL; hPen = NULL; hBrush = NULL; if (TempBitmap) { delete TempBitmap; TempBitmap = NULL; } // clipping rgn free SelectClipRgn(dcDst, NULL); DeleteObject(hrgn); } } //// } } pPoints = NULL; bIsPrint = false; return; fail: if (pPoints) delete[]pPoints; pPoints = NULL; bIsPrint = false; if (data) delete data; data = NULL; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::PrintDrawMotive(TVecData *ParentData, HDC dcDst, int posx, int posy, int WidthRes, int HeightRes, double dpi, int number, TSize endCnt, int item, TColor tempColor, HRGN hrgn) { TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) TList *tDataList = ParentData->ChildList; TList *DataList = new TList; TList * ResultBezierPointList; TPointList *tempPointList; DPOINT firstPoint, onPoint, normalPoint, tempCurpt, tempOldpt; DPOINT *pTempList = NULL; double dInterval; TBezierPointList * BezierPointList = new TBezierPointList(); // »ý¼º BezierPointList->Init(ParentData); double CurveLength = BezierPointList->GetCurveLength(); int nSegment; int quotient = int(CurveLength / ((ParentData->proportion) * (ParentData->childwidth))); if (quotient == 0) quotient = 1; switch(ParentData->mode) { case 0: // ²Ë ä¿ì±â nSegment = int(CurveLength / ((ParentData->proportion) * (ParentData->childwidth))); if (nSegment == 0) nSegment = 1; break; case 1: // °³¼ö ¼³Á¤ nSegment = ParentData->motivecount; if (nSegment == 0) { nSegment = 1; VectorForm->eMotiveCount->Value = 1; } break; case 2: // °£°Ý ¼³Á¤ nSegment = int(CurveLength / ParentData->gap); if (nSegment == 0) nSegment = 1; break; } ParentData->gap = double(CurveLength / nSegment); ParentData->motivecount = nSegment; if (VectorForm) { VectorForm->eMotiveCount->Value = int(ParentData->motivecount); VectorForm->eMotiveGap->Value = int(ParentData->gap); } int count = 1; ResultBezierPointList = BezierPointList->Calculate(ParentData, nSegment); pTempList = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * (nSegment * 3 + 1)); double *tangentlist = new double[nSegment + 1]; // ±â¿ï±â¸¦ °¡Áö°í ÀÖ´Â ¹è¿­ firstPoint = FindingNormalOnBezier(&ParentData->pList[0], 0, 0, 0); pTempList[0].x = firstPoint.x; pTempList[0].y = firstPoint.y; pTempList[1].x = firstPoint.x; pTempList[1].y = firstPoint.y; tangentlist[0] = FindCurveTangent(&ParentData->pList[0], 0); for (int i = 0; i < ResultBezierPointList->Count; i++) { tempPointList = (TPointList*)ResultBezierPointList->Items[i]; for (tempPointList->First(); !tempPointList->IsDone(); tempPointList->Next()) { dInterval = tempPointList->CurrentDouble(); // BezierCurve À§ÀÇ Á¡À§Ä¡ // onPoint = FindingPointOnBezier(&tData->pList[i*3], dInterval); // ãÀº Á¡ÀÇ NormalÀÇ À§Ä¡ (ãÀº Á¡Àº ResultBezierPointList¾È¿¡ ÀÖÀ½) normalPoint = FindingNormalOnBezier(&ParentData->pList[i * 3], dInterval, 0, count % 2); tangentlist[count] = FindCurveTangent(&ParentData->pList[i * 3], dInterval); pTempList[count * 3 - 2] = pTempList[count * 3 - 3]; pTempList[count * 3 - 1].x = normalPoint.x; pTempList[count * 3 - 1].y = normalPoint.y; pTempList[count * 3].x = normalPoint.x; pTempList[count * 3].y = normalPoint.y; count++; tempOldpt = tempCurpt; } } if (ParentData->bClosed) { // ´ÝÈù ¿ÀºêÁ§Æ®ÀÇ °æ¿ì ³¡Á¡°ú ùÁ¡À» °°°Ô. pTempList[nSegment * 3] = pTempList[0]; pTempList[nSegment * 3 - 1] = pTempList[0]; } delete BezierPointList; BezierPointList = NULL; HPEN hOldPen = NULL, hPen = NULL; HBRUSH hOldBrush = NULL, hBrush = NULL; LOGBRUSH logbrush; int nDrawMode, nFillMode, nTemp, nPenStyle; RGBQUAD rgb; HFONT font = NULL, oldfont = NULL; Graphics::TBitmap *TempBitmap = NULL; double ZoomOut = dpi; int tempPosX = posx; // by siuaa int tempPosY = posy; // by siuaa int PositionX = posx; int PositionY = posy; int px = 0, py = 0; RECT Src; int FirstX, FirstY, SecondX, SecondY; double CenterX, CenterY, FontZoom = 1.0; int OffsetX, OffsetY; // by linuxjun for CurvedVectorText int StartX, StartY; int pw; gdp::Graphics graphics(dcDst); // using GDI+ gdp::PointF *pPoints = NULL; // Point -> PointF·Î º¯°æ by maxleo21c(05.07.01) graphics.SetPageUnit(gdp::UnitPixel); TVecData *tdata; // motive childÀÇ È®´ë Ãà¼Ò for (int i = 0; i < tDataList->Count; i++) { data = (TVecData*)tDataList->Items[i]; tdata = new TVecData(data->GetInstNum()); tdata->Copy(data); for (int l = 0; l < data->nCount * 3 + 1; l++) { tdata->pList[l].x = (data->pList[l].x - ParentData->centerX) * ParentData->proportion + ParentData->centerX; tdata->pList[l].y = (data->pList[l].y - ParentData->centerY) * ParentData->proportion + ParentData->centerY; } DataList->Add(tdata); } // ------------------------------------------ for (int m = 0; m < nSegment; m++) { for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; for (int l = 0; l < data->nCount * 3 + 1; l++) { data->pList[l].x = data->pList[l].x - ParentData->centerX + pTempList [3 * m].x; data->pList[l].y = data->pList[l].y - ParentData->centerY + pTempList [3 * m].y; } for (int l = 0; l < data->nCount * 3 + 1; l++) { double dx = data->pList[l].x - pTempList[3 * m].x; double dy = data->pList[l].y - pTempList[3 * m].y; data->pList[l].x = dx * cos(tangentlist[m]) - dy * sin(tangentlist[m]) + pTempList[3 * m].x; data->pList[l].y = dx * sin(tangentlist[m]) + dy * cos(tangentlist[m]) + pTempList[3 * m].y; } // if (!data->Equal(MainImageForm->Number)) continue; if (!data->Equal(number)) continue; // Á¤È®ÇÑ °è»êÀ» À§Çؼ­ if (data->bAntialiasing) { graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); // antialiasing } else { graphics.SetSmoothingMode(gdp::SmoothingModeNone); } SET_RECT; FirstX = (data->First.x - PositionX) * WidthRes / ZoomOut - px; FirstY = (data->First.y - PositionY) * HeightRes / ZoomOut - py; SecondX = (data->Second.x - PositionX) * WidthRes / ZoomOut - px; SecondY = (data->Second.y - PositionY) * HeightRes / ZoomOut - py; pw = data->PenThick / 2; float *dashValues = NULL; gdp::Color penColor(GetRValue(data->Color), GetGValue(data->Color), GetBValue(data->Color)); gdp::Color FillColor(GetRValue(data->Brush), GetGValue(data->Brush), GetBValue(data->Brush)); gdp::Pen ObjectPen(penColor, data->PenThick * WidthRes / ZoomOut); gdp::SolidBrush ObjectBrush(FillColor); gdp::GraphicsPath gFillPath; if (data->Kind == V_TEXTBOX) { pPoints = new gdp::PointF[5]; } else { if (data->bClosed) { pPoints = new gdp::PointF[(data->nCount + 1) * 3 + 1]; } else { pPoints = new gdp::PointF[data->nCount * 3 + 1]; } } if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int i = 0; i < data->nCount * 3 + 1; i++) { pPoints[i].X = (data->pList[i].x - PositionX) * WidthRes / ZoomOut - px; pPoints[i].Y = (data->pList[i].y - PositionY) * HeightRes / ZoomOut - py; } } if (data->Kind == V_TEXTBOX) { FontZoom = (double)WidthRes / ZoomOut; StartX = (data->StartPoint.x - PositionX) * WidthRes / ZoomOut - px; StartY = (data->StartPoint.y - PositionY) * HeightRes / ZoomOut - py; CenterX = (data->CenterPoint.x - PositionX) * WidthRes / ZoomOut - px; CenterY = (data->CenterPoint.y - PositionY) * HeightRes / ZoomOut - py; OffsetX = PositionX; OffsetY = PositionY; // by linuxjun for CurvedVectorText for (int i = 0; i < 5; i++) { pPoints[i].X = (data->pList[i].x - PositionX) * WidthRes / ZoomOut - px; pPoints[i].Y = (data->pList[i].y - PositionY) * HeightRes / ZoomOut - py; } } //////// Closed Path last point and for nicer close if (data->bClosed) { pPoints[data->nCount * 3] = pPoints[0]; if (data->PenStyle == P_SOLID) { pPoints[data->nCount * 3 + 1] = pPoints[1]; pPoints[data->nCount * 3 + 2] = pPoints[2]; pPoints[data->nCount * 3 + 3] = pPoints[3]; } } //////// nDrawMode = GetROP2(dcDst); nFillMode = GetPolyFillMode(dcDst); if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { // Text´Â Pen°ú Brush°¡ ÇÊ¿ä ¾ø´Ù logbrush.lbStyle = BS_SOLID; logbrush.lbColor = data->Brush; logbrush.lbHatch = 0; if (data->bPatternFill) { // PatternFill À϶§ // ÇöÀç ÀÌÀ¯¸¦ ¾Ë¼ö ¾ø´Â ¹®Á¦(StretchBltÈÄ¿¡ data->TBitmap, data->MaskBitmapÀÌ // NULL·Î º¯ÇÏ´Â ¹®Á¦) ¶§¹®¿¡ ¾Æ·¡¿Í °°ÀÌ Ã³¸®Çß´Ù. ÀÌ °æ¿ì¿¡µµ ¹®Á¦°¡ ³²¾Æ // Àִµ¥ NULL°ªÀÌ µÇ¾úÀ» °æ¿ì¿¡ DeleteDC¸¦ ÇÏÁö ¾Ê°Ô µÈ´Ù. // Test ÇØ º» °á°ú Ưº°ÇÑ ¹®Á¦ ¾øÀÌ Print µÇ´Â °ÍÀ¸·Î È®ÀÎ!! maxleo21c(05.07.19) int bltwidth = 0, bltheight = 0; HDC dcPattern = NULL, dcMask = NULL; int pw = 0, ph = 0, mw = 0, mh = 0; MakePatternBitmap(data); if (data->TBitmap == NULL || data->MaskBitmap == NULL) goto next; pw = data->TBitmap->Width; ph = data->TBitmap->Height; mw = data->MaskBitmap->Width; mh = data->MaskBitmap->Height; bltwidth = pw * WidthRes / ZoomOut; bltheight = ph * HeightRes / ZoomOut; if (bltwidth <= 0 || bltheight <= 0 || mw <= 0 || mh <= 0) goto next; if ((dcPattern = data->TBitmap->CreateDC()) == NULL) goto next; if ((dcMask = data->MaskBitmap->CreateDC()) == NULL) goto next; // º¤ÅÍ ¿ÀºêÁ§Æ® ¾È¿¡ ä¿îºñÆ®¸Ê À̹ÌÁö Ãà¼Òº¸±â ÇßÀ» ¶§ Ä®¶ó³ª ÆÐÅÏÀÌ º¯ÁúµÇÁö ¾Êµµ·Ï ¼öÁ¤ - by monkman (2007.09.13) if (osVERSION < 2) { // 3.1, 95, 98 SetStretchBltMode(dcDst, COLORONCOLOR); } else { SetStretchBltMode(dcDst, HALFTONE); } StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcMask, 0, 0, mw, mh, SRCAND); StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcPattern, 0, 0, pw, ph, SRCPAINT); next: if (dcPattern && data->TBitmap) { data->TBitmap->DeleteDC(dcPattern); dcPattern = NULL; } if (dcMask && data->MaskBitmap) { data->MaskBitmap->DeleteDC(dcMask); dcMask = NULL; } } else if (data->bFill) { // ColorFill À϶§ hBrush = CreateBrushIndirect(&logbrush); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); } else { // Fill X hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } if (data->bWinding) gFillPath.SetFillMode(gdp::FillModeWinding); else gFillPath.SetFillMode(gdp::FillModeAlternate); logbrush.lbColor = data->Color; // ÆæÀÇ color¸¦ À§Çؼ­... switch(data->PenStyle) { case 0: { nPenStyle = P_USERSTYLE; int count = 2; float t_dashValues[2] = { 10, 0 }; ObjectPen.SetDashPattern(t_dashValues, count); break; } case 1: nPenStyle = int(PS_DASH); break; case 2: nPenStyle = int(PS_DOT); break; case 3: nPenStyle = int(PS_DASHDOT); break; case 4: nPenStyle = int(PS_DASHDOTDOT); break; case 5: nPenStyle = P_USERSTYLE; int count = 0; double temp[6] = { 0, 0, 0, 0, 0, 0 }; CheckUserDashedLine(data, temp, count); dashValues = new float[count]; for (int i = 0; i < count; i++) { dashValues[i] = temp[i]; } ObjectPen.SetDashPattern(dashValues, count); break; // DashStyleCustom = 5 } if (osVERSION < 2) { // 3.1, 95, 98 hPen = CreatePen(psSolid, data->PenThick * WidthRes / ZoomOut, data->Color); } else { if (data->bRound) { // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapRound); } } else { ObjectPen.SetStartCap(gdp::LineCapRound); ObjectPen.SetEndCap(gdp::LineCapRound); } ObjectPen.SetEndCap(gdp::LineCapRound); ObjectPen.SetLineJoin(gdp::LineJoinRound); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapRound); } else { if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapFlat); } } else { ObjectPen.SetStartCap(gdp::LineCapFlat); ObjectPen.SetEndCap(gdp::LineCapFlat); } ObjectPen.SetLineJoin(gdp::LineJoinMiter); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapFlat); } } hOldPen = (HPEN)SelectObject(dcDst, hPen); } else { nTemp = data->Font.lfHeight; data->Font.lfHeight = data->Font.lfHeight * WidthRes / ZoomOut + 0.5; if (data->Font.lfHeight == 0) data->Font.lfHeight = 1; } if (!(data->ParentTextBox || data->ChildList)) { // by linuxjun for CurvedVectorText // PAINT_VECTOR; // if (data->bGradientFill) SelectClipRgn(dcDst, hrgn); // ±âÁ¸ PAINT_VECTOR¸¦ »ç¿ëÇÏ¿´Áö¸¸ ÀÛ¾÷±¸¿ª ¸®ÇÍ º¤ÅÍ ¹Ì¸®º¸±â ¹× Ãâ·ÂÀ» °³¹ß Çϸ鼭 // RegionÀ» ÀÌ¿ëÇϴµ¥ Gradient¿¡¼­µµ RegionÀ» »ç¿ëÇÏ¿© Á¤»óÀûÀ¸·Î Ãâ·ÂÀÌ µÇÁö ¾Ê´Â ¹®Á¦°¡ // ÀÖ¾ù´Ù. ±×·¡¼­ ±× ºÎºÐÀ» ¼Ò½º¿¡ Ãß°¡Çϰí SelectClipRgn(dcDst, hrgn); ÇÔ¼ö¸¦ ³Ö¾ú´Ù. // by david 090508 SetROP2(dcDst, R2_COPYPEN); switch(data->Kind) { case V_LINE: graphics.DrawPolygon(&ObjectPen, pPoints, data->nCount + 1); break; case V_CURVE: if (data->bGradientFill) { DrawGradientFill(dcDst, data, pPoints, data->nCount * 3 + 1, FirstX, FirstY, SecondX, SecondY); SelectClipRgn(dcDst, hrgn); } if (data->bClosed && data->PenStyle == P_SOLID) { graphics.DrawBeziers(&ObjectPen, pPoints, (data->nCount + 1) * 3 + 1); } else { graphics.DrawBeziers(&ObjectPen, pPoints, data->nCount * 3 + 1); } if (data->bFill) { gFillPath.AddBeziers(pPoints, data->nCount * 3 + 1); graphics.FillPath(&ObjectBrush, &gFillPath); graphics.DrawPath(&ObjectPen, &gFillPath); } break; case V_RECT: if (data->bRound) RoundRect(dcDst, FirstX, FirstY, SecondX, SecondY, pw, pw); else Rectangle(dcDst, FirstX, FirstY, SecondX, SecondY); break; case V_ELLIPSE: Ellipse(dcDst, FirstX, FirstY, SecondX, SecondY); break; case V_TEXT: Char * tempstr; tempstr = (Char*)malloc(data->nCount); for (int k = 0; k < data->nCount; k++) tempstr[k] = Char(data->TextString[k + 1]); SetTextAlign(dcDst, TA_BOTTOM); SetTextColor(dcDst, data->Color); SetBkMode(dcDst, TRANSPARENT); font = CreateFontIndirect(&data->Font); oldfont = (HFONT)SelectObject(dcDst, font); TextOut(dcDst, FirstX, FirstY, tempstr, data->nCount); SelectObject(dcDst, oldfont); DeleteObject(font); data->Font.lfHeight = nTemp; free(tempstr); break; case V_TEXTBOX: if (BeReadyEdit && CurrentTextBox == i) DrawEditTextBox(dcDst, data, StartX, StartY, FontZoom, CenterX, CenterY, OffsetX, OffsetY); else DrawTextBox(dcDst, data, StartX, StartY, CenterX, CenterY, FontZoom, OffsetX, OffsetY); break; } SetROP2(dcDst, nDrawMode); SetPolyFillMode(dcDst, nFillMode); } if (pPoints) delete[]pPoints; pPoints = NULL; if (dashValues) delete[]dashValues; dashValues = NULL; if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { SelectObject(dcDst, hOldBrush); SelectObject(dcDst, hOldPen); } if (hBrush) DeleteObject(hBrush); if (hPen) DeleteObject(hPen); hOldPen = NULL; hOldBrush = NULL; hPen = NULL; hBrush = NULL; if (TempBitmap) { delete TempBitmap; TempBitmap = NULL; } // 20090220 °¢µµº¯È¯ reverseÇÊ¿ä for (int l = 0; l < data->nCount * 3 + 1; l++) { double dx = data->pList[l].x - pTempList[3 * m].x; double dy = data->pList[l].y - pTempList[3 * m].y; data->pList[l].x = dx * cos(-tangentlist[m]) - dy * sin (-tangentlist[m]) + pTempList[3 * m].x; data->pList[l].y = dx * sin(-tangentlist[m]) + dy * cos (-tangentlist[m]) + pTempList[3 * m].y; } for (int l = 0; l < data->nCount * 3 + 1; l++) { data->pList[l].x = data->pList[l].x + ParentData->centerX - pTempList [3 * m].x; data->pList[l].y = data->pList[l].y + ParentData->centerY - pTempList [3 * m].y; } } } for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (data) delete data; } DataList->Clear(); delete DataList; DataList = NULL; if (tangentlist) delete[]tangentlist; tangentlist = NULL; // ¸Þ¸ð¸® ÇØÁ¦ - by monkman (2009.04.16) if (pTempList) { HeapFree(GetProcessHeap(), 0, pTempList); } pTempList = NULL; pPoints = NULL; return; fail: for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (data) delete data; } DataList->Clear(); delete DataList; DataList = NULL; if (tangentlist) delete[]tangentlist; tangentlist = NULL; if (pPoints) delete[]pPoints; pPoints = NULL; if (data) delete data; data = NULL; // ¸Þ¸ð¸® ÇØÁ¦ - by monkman (2009.04.16) if (pTempList) { HeapFree(GetProcessHeap(), 0, pTempList); } pTempList = NULL; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::PrintDraw(HDC dcDst, TRect ScreenCanvasRect, int WidthRes, int HeightRes, double dpi, int number) { bIsPrint = true; TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) HPEN hOldPen = NULL, hPen = NULL; HBRUSH hOldBrush = NULL, hBrush = NULL; LOGBRUSH logbrush; int nDrawMode, nFillMode, nTemp, nPenStyle; RGBQUAD rgb; HFONT font = NULL, oldfont = NULL; Graphics::TBitmap *TempBitmap = NULL; // int ZoomIn = DPI; double ZoomOut = dpi; int PositionX = ScreenCanvasRect.left; int PositionY = ScreenCanvasRect.top; int px = 0, py = 0; RECT Src; double FirstX, FirstY, SecondX, SecondY; double CenterX, CenterY, FontZoom = 1.0; int OffsetX, OffsetY; // by linuxjun for CurvedVectorText double StartX, StartY; int pw; RECT VectorRect; gdp::Graphics graphics(dcDst); // using GDI+ 2005 Vector upgrade Shin 0315 gdp::PointF *pPoints = NULL; graphics.SetPageUnit(gdp::UnitPixel); graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); // antialiasing if (MainImageForm->WorkArea->Mask) { Src = MainImageForm->WorkArea->Range; PositionX += Src.left; PositionY += Src.top; } for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(number)) continue; // Á¤È®ÇÑ °è»êÀ» À§Çؼ­ FirstX = (data->First.x - PositionX) * WidthRes / ZoomOut - px; FirstY = (data->First.y - PositionY) * HeightRes / ZoomOut - py; SecondX = (data->Second.x - PositionX) * WidthRes / ZoomOut - px; SecondY = (data->Second.y - PositionY) * HeightRes / ZoomOut - py; pw = data->PenThick / 2; // ¼Óµµ °³¼± - CurveDataÀÇ ¿µ¿ªÀ» ±¸ÇÑ´Ù - by monkman (2005.07.12) if (data->ListOfAllLine && data->ListOfAllLine->CurveData) { TVecData *CurveData; CurveData = data->ListOfAllLine->CurveData; int Margin; try { Margin = data->ListOfAllLine->GetLineTextBox(0)->lineHeight * 3; } catch(...) { Margin = 0; } VectorRect.left = CurveData->First.x - Margin; VectorRect.right = CurveData->Second.x + Margin; VectorRect.top = CurveData->First.y - Margin; VectorRect.bottom = CurveData->Second.y + Margin; } else { VectorRect.left = FirstX; VectorRect.right = SecondX; VectorRect.top = FirstY; VectorRect.bottom = SecondY; } // ¼Óµµ °³¼± - ¿µ¿ª¾È¿¡ µé¾î¿Â º¤Å͸¸ ±×¸°´Ù - by monkman (2005.07.08) if ((VectorRect.left < ScreenCanvasRect.left && VectorRect.right < ScreenCanvasRect.left) || (VectorRect.top < ScreenCanvasRect.top && VectorRect.bottom < ScreenCanvasRect.top) || (VectorRect.left > ScreenCanvasRect.right && VectorRect.right > ScreenCanvasRect.right) || (VectorRect.top > ScreenCanvasRect.bottom && VectorRect.bottom > ScreenCanvasRect.bottom)) continue; float *dashValues = NULL; gdp::Color penColor(GetRValue(data->Color), GetGValue(data->Color), GetBValue(data->Color)); gdp::Color FillColor(GetRValue(data->Brush), GetGValue(data->Brush), GetBValue(data->Brush)); gdp::Pen ObjectPen(penColor, data->PenThick * WidthRes / ZoomOut); gdp::SolidBrush ObjectBrush(FillColor); gdp::GraphicsPath gFillPath; if (data->Kind == V_TEXTBOX) { pPoints = new gdp::PointF[5]; } else { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new gdp::PointF[(data->nCount + 1) * 3 + 1]; } else { pPoints = new gdp::PointF[data->nCount * 3 + 1]; } } if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int i = 0; i < data->nCount * 3 + 1; i++) { pPoints[i].X = (data->pList[i].x - PositionX) * WidthRes / ZoomOut - px; pPoints[i].Y = (data->pList[i].y - PositionY) * HeightRes / ZoomOut - py; } } if (data->Kind == V_TEXTBOX) { FontZoom = (double)WidthRes / ZoomOut; StartX = (data->StartPoint.x - PositionX) * WidthRes / ZoomOut - px; StartY = (data->StartPoint.y - PositionY) * HeightRes / ZoomOut - py; CenterX = (data->CenterPoint.x - PositionX) * WidthRes / ZoomOut - px; CenterY = (data->CenterPoint.y - PositionY) * HeightRes / ZoomOut - py; OffsetX = PositionX; OffsetY = PositionY; // by linuxjun for CurvedVectorText for (int i = 0; i < 5; i++) { pPoints[i].X = (data->pList[i].x - PositionX) * WidthRes / ZoomOut - px; pPoints[i].Y = (data->pList[i].y - PositionY) * HeightRes / ZoomOut - py; } } //////// Closed Path last point and for nicer close if (data->bClosed && data->PenStyle == P_SOLID) { pPoints[data->nCount * 3] = pPoints[0]; pPoints[data->nCount * 3 + 1] = pPoints[1]; pPoints[data->nCount * 3 + 2] = pPoints[2]; pPoints[data->nCount * 3 + 3] = pPoints[3]; } //////// nDrawMode = GetROP2(dcDst); nFillMode = GetPolyFillMode(dcDst); if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { // Text´Â Pen°ú Brush°¡ ÇÊ¿ä ¾ø´Ù logbrush.lbStyle = BS_SOLID; logbrush.lbColor = data->Brush; logbrush.lbHatch = 0; if (data->bPatternFill) { // PatternFill À϶§ if (data->TBitmap && data->MaskBitmap) { int bltwidth, bltheight; HDC dcPattern, dcMask; bltwidth = data->TBitmap->Width * WidthRes / ZoomOut; bltheight = data->TBitmap->Height * HeightRes / ZoomOut; if ((dcPattern = data->TBitmap->CreateDC()) == NULL) goto fail; if ((dcMask = data->MaskBitmap->CreateDC()) == NULL) goto fail; StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcMask, 0, 0, data->MaskBitmap->Width, data->MaskBitmap->Height, SRCAND); StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcPattern, 0, 0, data->TBitmap->Width, data->TBitmap->Height, SRCPAINT); if (dcPattern) { data->TBitmap->DeleteDC(dcPattern); dcPattern = NULL; } if (dcMask) { data->MaskBitmap->DeleteDC(dcMask); dcMask = NULL; } } } else if (data->bFill) { // ColorFill À϶§ hBrush = CreateBrushIndirect(&logbrush); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); } else { // Fill X hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } if (data->bWinding) SetPolyFillMode(dcDst, WINDING); // ä¿ì±â ¸ðµå ¼±Åà else SetPolyFillMode(dcDst, ALTERNATE); logbrush.lbColor = data->Color; // ÆæÀÇ color¸¦ À§Çؼ­... switch(data->PenStyle) { case 0: { // nPenStyle = int (PS_SOLID); // ±âÁ¸¿¡ »ç¿ë // Solid·Î ó¸®ÇÒ¶§¿¡´Â epson ÇÁ¸°Æ®¿¡¼­ ¶óÀÎÀÌ ²÷¾îÁö´Â Çö»óÀÌ ¹ß°ßµÇ±â // ¶§¹®¿¡ Solid ¶óÀÎÀ» user style·Î ¹Ù²ã ó¸®Çß´Ù. (05.07.12) nPenStyle = P_USERSTYLE; int count = 2; float t_dashValues[2] = { 10, 0 }; ObjectPen.SetDashPattern(t_dashValues, count); break; } case 1: nPenStyle = int(PS_DASH); break; case 2: nPenStyle = int(PS_DOT); break; case 3: nPenStyle = int(PS_DASHDOT); break; case 4: nPenStyle = int(PS_DASHDOTDOT); break; case 5: // 2005 Vector upgrade shin 0315 nPenStyle = P_USERSTYLE; int count = 0; double temp[6] = { 0, 0, 0, 0, 0, 0 }; CheckUserDashedLine(data, temp, count); dashValues = new float[count]; for (int i = 0; i < count; i++) { dashValues[i] = temp[i]; } // int count = data->DashValues[0]; // dashValues = new float[count]; // for (int i = 0; i < count; i++){ // dashValues[i] = data->DashValues[i+1]; // } ObjectPen.SetDashPattern(dashValues, count); break; // DashStyleCustom = 5 } if (osVERSION < 2) { // 3.1, 95, 98 hPen = CreatePen(psSolid, data->PenThick * WidthRes / ZoomOut, data->Color); } else { if (data->bRound) { // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapRound); } } else { ObjectPen.SetStartCap(gdp::LineCapRound); ObjectPen.SetEndCap(gdp::LineCapRound); } ObjectPen.SetLineJoin(gdp::LineJoinRound); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapRound); } else { if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapFlat); } } else { ObjectPen.SetStartCap(gdp::LineCapFlat); ObjectPen.SetEndCap(gdp::LineCapFlat); } ObjectPen.SetLineJoin(gdp::LineJoinMiter); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapFlat); } } hOldPen = (HPEN)SelectObject(dcDst, hPen); } else { nTemp = data->Font.lfHeight; data->Font.lfHeight = data->Font.lfHeight * WidthRes / ZoomOut + 0.5; if (data->Font.lfHeight == 0) data->Font.lfHeight = 1; } if (!(data->ParentTextBox || data->ChildList)) { // by linuxjun for CurvedVectorText PAINT_VECTOR; } if (data->ChildList) { // 090303 embakum motiveobjects DrawMotiveObjects(dcDst, data, MainImageForm, 0, 0, 2); } if (pPoints) delete[]pPoints; pPoints = NULL; if (dashValues) delete[]dashValues; dashValues = NULL; if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { SelectObject(dcDst, hOldBrush); SelectObject(dcDst, hOldPen); } if (hBrush) DeleteObject(hBrush); hBrush = NULL; if (hPen) DeleteObject(hPen); hPen = NULL; hOldPen = NULL; hOldBrush = NULL; if (TempBitmap) { delete TempBitmap; TempBitmap = NULL; } } bIsPrint = false; return; fail: bIsPrint = false; if (data) delete data; data = NULL; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::FullViewDraw(HDC dcDst, int px, int py, int vw, int vh) // convert by celberus { TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) HPEN hOldPen = NULL, hPen = NULL; HBRUSH hOldBrush = NULL, hBrush = NULL; LOGBRUSH logbrush; int nDrawMode, nFillMode, nTemp, nPenStyle; RGBQUAD rgb; POINT *pPoints = NULL; // pPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) HFONT font = NULL, oldfont = NULL; double rx = (double)MainImageForm->iMainImage->bmFullView->Width / MainImageForm->iMainImage->uBitmap->Width; double ry = (double)MainImageForm->iMainImage->bmFullView->Height / MainImageForm->iMainImage->uBitmap->Height; // double rx = (double) vw / MainImageForm->iMainImage->uBitmap->Width; // double ry = (double) vh / MainImageForm->iMainImage->uBitmap->Height; int FirstX, FirstY, SecondX, SecondY; double CenterX, CenterY, FontZoom = 1.0; int R_FirstX, R_FirstY, R_SecondX, R_SecondY; // Gradient ¹ÝÀü °Å¿ï - by monkman (2009.04.15) int nReflectionIndex; // Gradient ¹ÝÀü °Å¿ï - by monkman (2009.04.15) int OffsetX, OffsetY; // by linuxjun for CurvedVectorText int StartX, StartY; int pw, resizedPenThick; DWORD* dashValues = NULL; int count = 0; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) POINT *pRefPoints = NULL; // pRefPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) int ReflectionIndex = -1; if (NVector->bVectorReflectionMode && ((NVector->ReflectionVH == 1 && NVector->ReflectionVIndex >= 0) || (NVector->ReflectionVH == 2 && NVector->ReflectionHIndex >= 0))) { // ¼öÁ÷ ±âÁؼ± if (NVector->ReflectionVH == 1) ReflectionIndex = NVector->ReflectionVIndex; // ¼öÆò ±âÁؼ± if (NVector->ReflectionVH == 2) ReflectionIndex = NVector->ReflectionHIndex; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; FirstX = data->First.x * rx; FirstY = data->First.y * ry; SecondX = data->Second.x * rx; SecondY = data->Second.y * ry; // convert by celberus pw = data->PenThick / 2; resizedPenThick = max(1.0, data->PenThick * min(rx, ry)); // convert by celberus // Gradient ¹ÝÀü °Å¿ï - by monkman (2009.04.15) nReflectionIndex = MainImageForm->NVector->ReflectionVH == 1 ? MainImageForm->NVector->ReflectionVIndex : MainImageForm->NVector->ReflectionHIndex; if (MainImageForm->NVector->bVectorReflectionMode && MainImageForm->NVector->ReflectionVH > 0) { if (MainImageForm->NVector->ReflectionVH == 1) { R_FirstX = (nReflectionIndex * 2 - data->Second.x) * rx; R_FirstY = FirstY; R_SecondX = (nReflectionIndex * 2 - data->First.x) * ry; R_SecondY = SecondY; } else if (MainImageForm->NVector->ReflectionVH == 2) { R_FirstX = FirstX; R_FirstY = (nReflectionIndex * 2 - data->Second.y) * rx; R_SecondX = SecondX; R_SecondY = (nReflectionIndex * 2 - data->First.y) * ry; } } int deltaX = 0, deltaY = 0; if (NVector->bMergeMode && data->bSelected) { // Merge Mode¿¡¼­ ¼±ÅÃµÈ ¿ÀºêÁ§Æ®ÀÇ ¸¶¿ì½º À̵¿¿¡ µû¸¥ ÁÂÇ¥ º¯°æ deltaX = MergeX; deltaY = MergeY; } if (data->Kind == V_TEXTBOX) { pPoints = new POINT[5]; } else { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new POINT[(data->nCount + 1) * 3 + 1]; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (MainImageForm->NVector->bVectorReflectionMode && (MainImageForm->NVector->ReflectionVH == 1 || MainImageForm->NVector->ReflectionVH == 2)) pRefPoints = new POINT[(data->nCount + 1) * 3 + 1]; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } else { pPoints = new POINT[data->nCount * 3 + 1]; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (MainImageForm->NVector->bVectorReflectionMode && (MainImageForm->NVector->ReflectionVH == 1 || MainImageForm->NVector->ReflectionVH == 2)) pRefPoints = new POINT[data->nCount * 3 + 1]; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } } if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int i = 0; i < data->nCount * 3 + 1; i++) { pPoints[i].x = (data->pList[i].x + deltaX) * rx; pPoints[i].y = (data->pList[i].y + deltaY) * ry; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (NVector->bVectorReflectionMode) { if (NVector->ReflectionVH == 1) { pRefPoints[i].x = (ReflectionIndex * 2 - (data->pList[i].x + deltaX) ) * rx; pRefPoints[i].y = (data->pList[i].y + deltaY) * ry; } if (NVector->ReflectionVH == 2) { pRefPoints[i].x = (data->pList[i].x + deltaX) * rx; pRefPoints[i].y = (ReflectionIndex * 2 - (data->pList[i].y + deltaY) ) * ry; } } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } } if (data->Kind == V_TEXTBOX) { FontZoom = rx; StartX = (data->StartPoint.x + deltaX) * rx; StartY = (data->StartPoint.y + deltaY) * ry; CenterX = (data->CenterPoint.x + deltaX) * rx; CenterY = (data->CenterPoint.y + deltaY) * ry; OffsetX = 0; OffsetY = 0; // by linuxjun for CurvedVectorText for (int i = 0; i < 5; i++) { pPoints[i].x = (data->pList[i].x + deltaX) * rx; pPoints[i].y = (data->pList[i].y + deltaY) * ry; } } //////// Closed Path last point and for nicer close if (data->bClosed && data->PenStyle == P_SOLID) { pPoints[data->nCount * 3] = pPoints[0]; pPoints[data->nCount * 3 + 1] = pPoints[1]; pPoints[data->nCount * 3 + 2] = pPoints[2]; pPoints[data->nCount * 3 + 3] = pPoints[3]; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (NVector->bVectorReflectionMode && (NVector->ReflectionVH == 1 || NVector->ReflectionVH == 2)) { pRefPoints[data->nCount * 3] = pRefPoints[0]; pRefPoints[data->nCount * 3 + 1] = pRefPoints[1]; pRefPoints[data->nCount * 3 + 2] = pRefPoints[2]; pRefPoints[data->nCount * 3 + 3] = pRefPoints[3]; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } //////// nDrawMode = GetROP2(dcDst); nFillMode = GetPolyFillMode(dcDst); if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { // Text´Â Pen°ú Brush°¡ ÇÊ¿ä ¾ø´Ù logbrush.lbStyle = BS_SOLID; logbrush.lbColor = data->Brush; logbrush.lbHatch = 0; if (data->bPatternFill) { // PatternFill À϶§ FullView¿¡¼­´Â Ä¥ÇÏÁö ¾Ê´Â´Ù(¼Óµµ¹®Á¦) hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } else if (data->bFill) { // ColorFill À϶§ hBrush = CreateBrushIndirect(&logbrush); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); } else { // Fill X hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } if (data->bWinding) SetPolyFillMode(dcDst, WINDING); // ä¿ì±â ¸ðµå ¼±Åà else SetPolyFillMode(dcDst, ALTERNATE); logbrush.lbColor = data->Color; // ÆæÀÇ color¸¦ À§Çؼ­... switch(data->PenStyle) { case 0: nPenStyle = int(PS_SOLID); break; case 1: nPenStyle = int(PS_DASH); break; case 2: nPenStyle = int(PS_DOT); break; case 3: nPenStyle = int(PS_DASHDOT); break; case 4: nPenStyle = int(PS_DASHDOTDOT); break; case 5: nPenStyle = P_USERSTYLE; count = data->DashValues[0]; dashValues = new DWORD[count]; for (int i = 0; i < count; i++) { if (i % 2 == 0 && data->DashValues[i + 1] < data->PenThick) { if (data->bRound) dashValues[i] = 1; else dashValues[i] = (DWORD)(data->PenThick + 0.5) * (data->DashValues[i + 1] + 0.5); } else { dashValues[i] = (DWORD)(data->PenThick + 0.5) * (data->DashValues[i + 1] + 0.5); } } break; } if (osVERSION < 2) { // 3.1, 95, 98 hPen = CreatePen(psSolid, resizedPenThick, data->Color); } else { if (data->bRound) { // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù if (nPenStyle == 5) { // »ç¿ëÀÚ Á¤ÀÇ Ææ ½ºÅ¸ÀÏ hPen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE | PS_ENDCAP_ROUND | PS_JOIN_ROUND, int(resizedPenThick + 0.5), &logbrush, count, dashValues); } else { hPen = ExtCreatePen(PS_GEOMETRIC | nPenStyle | PS_ENDCAP_ROUND | PS_JOIN_ROUND, int(resizedPenThick + 0.5), &logbrush, 0, NULL); } } else { if (nPenStyle == 5) { // »ç¿ëÀÚ Á¤ÀÇ Ææ ½ºÅ¸ÀÏ hPen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE | PS_ENDCAP_FLAT | PS_JOIN_MITER, int(resizedPenThick + 0.5), &logbrush, count, dashValues); } else { hPen = ExtCreatePen(PS_GEOMETRIC | nPenStyle | PS_ENDCAP_FLAT | PS_JOIN_MITER, int(resizedPenThick + 0.5), &logbrush, 0, NULL); } } } hOldPen = (HPEN)SelectObject(dcDst, hPen); } else { nTemp = data->Font.lfHeight; data->Font.lfHeight = data->Font.lfHeight * min(rx, ry); // convert by celberus if (data->Font.lfHeight < 6) data->Font.lfHeight = 0; // ÅØ½ºÆ®´Â »çÀÌÁî°¡ ÃÖ¼Ò »çÀÌÁ´Ù ÀÛÀ¸¸é Ç×»ó ÃÖ¼Ò »çÀÌÁî·Î ±×¸®±â ¶§¹®¿¡ by celberus } if (data->Kind != V_TEXT || data->Font.lfHeight != 0) { if (!data->ParentTextBox) { // by linuxjun for CurvedVectorText if (!data->ChildList) { PAINT_FULLVIEW_VECTOR; } } } else { data->Font.lfHeight = nTemp; } if (!(data->ParentTextBox || data->ChildList)) { // by linuxjun for CurvedVectorText PAINT_FULLVIEW_VECTOR; } if (data->ChildList) { // motive object draw embakum 090303 // DrawMotiveObjects(dcDst, data, MainImageForm, px, py, 3, vw, vh); //FullView FullViewMotiveDraw(dcDst, px, py, vw, vh, data); } if (pPoints) delete[]pPoints; pPoints = NULL; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (MainImageForm->NVector->bVectorReflectionMode && (MainImageForm->NVector->ReflectionVH == 1 || MainImageForm->NVector->ReflectionVH == 2)) { if (pRefPoints) delete[]pRefPoints; } pRefPoints = NULL; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { SelectObject(dcDst, hOldBrush); SelectObject(dcDst, hOldPen); } if (hBrush) DeleteObject(hBrush); if (hPen) DeleteObject(hPen); hOldPen = NULL; hOldBrush = NULL; hPen = NULL; hBrush = NULL; if (dashValues) delete[]dashValues; dashValues = NULL; } pPoints = NULL; pRefPoints = NULL; return; fail: if (pPoints) delete[]pPoints; pPoints = NULL; if (pRefPoints) delete[]pRefPoints; pRefPoints = NULL; if (data) delete data; data = NULL; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::FullViewDrawMask(HDC dcDst, int px, int py, int vw, int vh) // convert by celberus { TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) HPEN hOldPen = NULL, hPen = NULL; HBRUSH hOldBrush = NULL, hBrush = NULL; LOGBRUSH logbrush; int nDrawMode, nFillMode, nTemp, nPenStyle; RGBQUAD rgb; POINT *pPoints = NULL; // pPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) HFONT font = NULL, oldfont = NULL; double rx = (double)MainImageForm->iMainImage->bmFullView->Width / MainImageForm->iMainImage->uBitmap->Width; double ry = (double)MainImageForm->iMainImage->bmFullView->Height / MainImageForm->iMainImage->uBitmap->Height; int FirstX, FirstY, SecondX, SecondY; int R_FirstX, R_FirstY, R_SecondX, R_SecondY; // Gradient ¹ÝÀü °Å¿ï - by monkman (2009.04.15) int nReflectionIndex; // Gradient ¹ÝÀü °Å¿ï - by monkman (2009.04.15) double CenterX, CenterY, FontZoom = 1.0; int OffsetX, OffsetY; // by linuxjun for CurvedVectorText int StartX, StartY; int pw, resizedPenThick; DWORD* dashValues = NULL; int count = 0; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) POINT *pRefPoints = NULL; // pRefPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) int ReflectionIndex = -1; if (NVector->bVectorReflectionMode && ((NVector->ReflectionVH == 1 && NVector->ReflectionVIndex >= 0) || (NVector->ReflectionVH == 2 && NVector->ReflectionHIndex >= 0))) { // ¼öÁ÷ ±âÁؼ± if (NVector->ReflectionVH == 1) ReflectionIndex = NVector->ReflectionVIndex; // ¼öÆò ±âÁؼ± if (NVector->ReflectionVH == 2) ReflectionIndex = NVector->ReflectionHIndex; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; FirstX = data->First.x * rx; FirstY = data->First.y * ry; SecondX = data->Second.x * rx; SecondY = data->Second.y * ry; // convert by celberus pw = data->PenThick / 2; resizedPenThick = max(1.0, data->PenThick * min(rx, ry)); // convert by celberus int deltaX = 0, deltaY = 0; if (NVector->bMergeMode && data->bSelected) { // Merge Mode¿¡¼­ ¼±ÅÃµÈ ¿ÀºêÁ§Æ®ÀÇ ¸¶¿ì½º À̵¿¿¡ µû¸¥ ÁÂÇ¥ º¯°æ deltaX = MergeX; deltaY = MergeY; } if (data->Kind == V_TEXTBOX) { pPoints = new POINT[5]; } else { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new POINT[(data->nCount + 1) * 3 + 1]; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (MainImageForm->NVector->bVectorReflectionMode && (MainImageForm->NVector->ReflectionVH == 1 || MainImageForm->NVector->ReflectionVH == 2)) pRefPoints = new POINT[(data->nCount + 1) * 3 + 1]; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } else { pPoints = new POINT[data->nCount * 3 + 1]; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (MainImageForm->NVector->bVectorReflectionMode && (MainImageForm->NVector->ReflectionVH == 1 || MainImageForm->NVector->ReflectionVH == 2)) pRefPoints = new POINT[data->nCount * 3 + 1]; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } } if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int i = 0; i < data->nCount * 3 + 1; i++) { pPoints[i].x = (data->pList[i].x + deltaX) * rx; pPoints[i].y = (data->pList[i].y + deltaY) * ry; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (NVector->bVectorReflectionMode) { if (NVector->ReflectionVH == 1) { pRefPoints[i].x = (ReflectionIndex * 2 - (data->pList[i].x + deltaX) ) * rx; pRefPoints[i].y = (data->pList[i].y + deltaY) * ry; } if (NVector->ReflectionVH == 2) { pRefPoints[i].x = (data->pList[i].x + deltaX) * rx; pRefPoints[i].y = (ReflectionIndex * 2 - (data->pList[i].y + deltaY) ) * ry; } } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } } if (data->Kind == V_TEXTBOX) { FontZoom = rx; StartX = (data->StartPoint.x + deltaX) * rx; StartY = (data->StartPoint.y + deltaY) * ry; CenterX = (data->CenterPoint.x + deltaX) * rx; CenterY = (data->CenterPoint.y + deltaY) * ry; OffsetX = 0; OffsetY = 0; // by linuxjun for CurvedVectorText for (int i = 0; i < 5; i++) { pPoints[i].x = (data->pList[i].x + deltaX) * rx; pPoints[i].y = (data->pList[i].y + deltaY) * ry; } } //////// Closed Path last point and for nicer close if (data->bClosed && data->PenStyle == P_SOLID) { pPoints[data->nCount * 3] = pPoints[0]; pPoints[data->nCount * 3 + 1] = pPoints[1]; pPoints[data->nCount * 3 + 2] = pPoints[2]; pPoints[data->nCount * 3 + 3] = pPoints[3]; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (NVector->bVectorReflectionMode && (NVector->ReflectionVH == 1 || NVector->ReflectionVH == 2)) { pRefPoints[data->nCount * 3] = pRefPoints[0]; pRefPoints[data->nCount * 3 + 1] = pRefPoints[1]; pRefPoints[data->nCount * 3 + 2] = pRefPoints[2]; pRefPoints[data->nCount * 3 + 3] = pRefPoints[3]; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } //////// nDrawMode = GetROP2(dcDst); nFillMode = GetPolyFillMode(dcDst); if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { // Text´Â Pen°ú Brush°¡ ÇÊ¿ä ¾ø´Ù logbrush.lbStyle = BS_SOLID; logbrush.lbColor = clBlack; // For Mask logbrush.lbHatch = 0; if (data->bPatternFill) { // PatternFill À϶§ FullView¿¡¼­´Â Ä¥ÇÏÁö ¾Ê´Â´Ù(¼Óµµ¹®Á¦) hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } else if (data->bFill) { // ColorFill À϶§ hBrush = CreateBrushIndirect(&logbrush); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); } else { // Fill X hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } if (data->bWinding) SetPolyFillMode(dcDst, WINDING); // ä¿ì±â ¸ðµå ¼±Åà else SetPolyFillMode(dcDst, ALTERNATE); logbrush.lbColor = clBlack; // ÆæÀÇ color¸¦ À§Çؼ­... // For Mask switch(data->PenStyle) { case 0: nPenStyle = int(PS_SOLID); break; case 1: nPenStyle = int(PS_DASH); break; case 2: nPenStyle = int(PS_DOT); break; case 3: nPenStyle = int(PS_DASHDOT); break; case 4: nPenStyle = int(PS_DASHDOTDOT); break; case 5: nPenStyle = P_USERSTYLE; count = data->DashValues[0]; dashValues = new DWORD[count]; for (int i = 0; i < count; i++) { if (i % 2 == 0 && data->DashValues[i + 1] < data->PenThick) { if (data->bRound) dashValues[i] = 1; else dashValues[i] = (DWORD)(data->PenThick + 0.5) * (data->DashValues[i + 1] + 0.5); } else { dashValues[i] = (DWORD)(data->PenThick + 0.5) * (data->DashValues[i + 1] + 0.5); } } break; } if (osVERSION < 2) { // 3.1, 95, 98 hPen = CreatePen(psSolid, resizedPenThick, clBlack); // For Mask } else { if (data->bRound) { // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù if (nPenStyle == 5) { // »ç¿ëÀÚ Á¤ÀÇ Ææ ½ºÅ¸ÀÏ hPen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE | PS_ENDCAP_ROUND | PS_JOIN_ROUND, int(resizedPenThick + 0.5), &logbrush, count, dashValues); } else { hPen = ExtCreatePen(PS_GEOMETRIC | nPenStyle | PS_ENDCAP_ROUND | PS_JOIN_ROUND, int(resizedPenThick + 0.5), &logbrush, 0, NULL); } } else { if (nPenStyle == 5) { // »ç¿ëÀÚ Á¤ÀÇ Ææ ½ºÅ¸ÀÏ hPen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE | PS_ENDCAP_FLAT | PS_JOIN_MITER, int(resizedPenThick + 0.5), &logbrush, count, dashValues); } else { hPen = ExtCreatePen(PS_GEOMETRIC | nPenStyle | PS_ENDCAP_FLAT | PS_JOIN_MITER, int(resizedPenThick + 0.5), &logbrush, 0, NULL); } } } hOldPen = (HPEN)SelectObject(dcDst, hPen); } else { nTemp = data->Font.lfHeight; data->Font.lfHeight = data->Font.lfHeight * min(rx, ry); // convert by celberus if (data->Font.lfHeight < 6) data->Font.lfHeight = 0; // ÅØ½ºÆ®´Â »çÀÌÁî°¡ ÃÖ¼Ò »çÀÌÁ´Ù ÀÛÀ¸¸é Ç×»ó ÃÖ¼Ò »çÀÌÁî·Î ±×¸®±â ¶§¹®¿¡ by celberus } if (data->Kind != V_TEXT || data->Font.lfHeight != 0) { if (!data->ParentTextBox) { // by linuxjun for CurvedVectorText if (!data->ChildList) { PAINT_FULLVIEW_VECTOR; } } } else { data->Font.lfHeight = nTemp; } if (data->ChildList) { // motive object draw embakum 090303 // DrawMotiveObjects(dcDst, data, MainImageForm, px, py); FullViewMotiveDraw(dcDst, px, py, vw, vh, data); } if (pPoints) delete[]pPoints; pPoints = NULL; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (MainImageForm->NVector->bVectorReflectionMode && (MainImageForm->NVector->ReflectionVH == 1 || MainImageForm->NVector->ReflectionVH == 2)) { if (pRefPoints) delete[]pRefPoints; } pRefPoints = NULL; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { SelectObject(dcDst, hOldBrush); SelectObject(dcDst, hOldPen); } if (hBrush) DeleteObject(hBrush); if (hPen) DeleteObject(hPen); hOldPen = NULL; hOldBrush = NULL; hPen = NULL; hBrush = NULL; if (dashValues) delete[]dashValues; dashValues = NULL; } pPoints = NULL; pRefPoints = NULL; return; fail: if (pPoints) delete[]pPoints; pPoints = NULL; if (pRefPoints) delete[]pRefPoints; pRefPoints = NULL; if (data) delete data; data = NULL; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::FullViewMotiveDraw(HDC dcDst, int px, int py, int vw, int vh, TVecData *ParentData) { TList *tDataList = ParentData->ChildList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) TList *DataList = new TList; TList * ResultBezierPointList; TPointList *tempPointList; DPOINT firstPoint, onPoint, normalPoint, tempCurpt, tempOldpt; DPOINT *pTempList = NULL; double dInterval; TBezierPointList * BezierPointList = new TBezierPointList(); // »ý¼º BezierPointList->Init(ParentData); double CurveLength = BezierPointList->GetCurveLength(); int nSegment; // int quotient = int(CurveLength/((ParentData->proportion)*(ParentData->childwidth))); // if (quotient==0) quotient = 1; switch(ParentData->mode) { case 0: // ²Ë ä¿ì±â if (ParentData->proportion == 0) { ParentData->proportion = 1; if (VectorForm) VectorForm->eMotiveProportion->Value = 1; } if (ParentData->childwidth == 0) { ParentData->childwidth = 1; } nSegment = int(CurveLength / ((ParentData->proportion) * (ParentData->childwidth))); if (nSegment == 0) nSegment = 1; ParentData->gap = double(CurveLength / nSegment); ParentData->motivecount = nSegment; break; case 1: // °³¼ö ¼³Á¤ nSegment = ParentData->motivecount; if (nSegment == 0) { nSegment = 1; if (VectorForm) VectorForm->eMotiveCount->Value = 1; } ParentData->gap = double(CurveLength / nSegment); break; case 2: // °£°Ý ¼³Á¤ if (ParentData->gap == 0) { ParentData->gap = 1; if (VectorForm) VectorForm->eMotiveGap->Value = 1; } nSegment = int(CurveLength / ParentData->gap); if (nSegment == 0) nSegment = 1; ParentData->motivecount = nSegment; break; } int count = 1; ResultBezierPointList = BezierPointList->Calculate(ParentData, nSegment); if (!ResultBezierPointList) { delete DataList; DataList; delete BezierPointList; BezierPointList = NULL; return; } pTempList = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * (nSegment * 3 + 1)); double *tangentlist = new double[nSegment + 1]; // ±â¿ï±â¸¦ °¡Áö°í ÀÖ´Â ¹è¿­ firstPoint = FindingNormalOnBezier(&ParentData->pList[0], 0, 0, 0); pTempList[0].x = firstPoint.x; pTempList[0].y = firstPoint.y; pTempList[1].x = firstPoint.x; pTempList[1].y = firstPoint.y; tangentlist[0] = FindCurveTangent(&ParentData->pList[0], 0); for (int i = 0; i < ResultBezierPointList->Count; i++) { tempPointList = (TPointList*)ResultBezierPointList->Items[i]; for (tempPointList->First(); !tempPointList->IsDone(); tempPointList->Next()) { dInterval = tempPointList->CurrentDouble(); // BezierCurve À§ÀÇ Á¡À§Ä¡ // onPoint = FindingPointOnBezier(&tData->pList[i*3], dInterval); // ãÀº Á¡ÀÇ NormalÀÇ À§Ä¡ (ãÀº Á¡Àº ResultBezierPointList¾È¿¡ ÀÖÀ½) normalPoint = FindingNormalOnBezier(&ParentData->pList[i * 3], dInterval, 0, count % 2); tangentlist[count] = FindCurveTangent(&ParentData->pList[i * 3], dInterval); pTempList[count * 3 - 2] = pTempList[count * 3 - 3]; pTempList[count * 3 - 1].x = normalPoint.x; pTempList[count * 3 - 1].y = normalPoint.y; pTempList[count * 3].x = normalPoint.x; pTempList[count * 3].y = normalPoint.y; count++; tempOldpt = tempCurpt; } } if (ParentData->bClosed) { // ´ÝÈù ¿ÀºêÁ§Æ®ÀÇ °æ¿ì ³¡Á¡°ú ùÁ¡À» °°°Ô. pTempList[nSegment * 3] = pTempList[0]; pTempList[nSegment * 3 - 1] = pTempList[0]; } delete BezierPointList; BezierPointList = NULL; // È­¸é¿¡ º¸À̱â HPEN hOldPen = NULL, hPen = NULL; HBRUSH hOldBrush = NULL, hBrush = NULL; LOGBRUSH logbrush; int nDrawMode, nFillMode, nTemp, nPenStyle; RGBQUAD rgb; POINT *pPoints = NULL; // pPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) HFONT font = NULL, oldfont = NULL; double rx = (double)MainImageForm->iMainImage->bmFullView->Width / MainImageForm->iMainImage->uBitmap->Width; double ry = (double)MainImageForm->iMainImage->bmFullView->Height / MainImageForm->iMainImage->uBitmap->Height; int FirstX, FirstY, SecondX, SecondY; int R_FirstX, R_FirstY, R_SecondX, R_SecondY; // Gradient ¹ÝÀü °Å¿ï - by monkman (2009.04.15) int nReflectionIndex; // Gradient ¹ÝÀü °Å¿ï - by monkman (2009.04.15) double CenterX, CenterY, FontZoom = 1.0; int OffsetX, OffsetY; // by linuxjun for CurvedVectorText int StartX, StartY; int pw, resizedPenThick; DWORD* dashValues = NULL; count = 0; // motive childÀÇ È®´ë Ãà¼Ò TVecData *tdata; for (int i = 0; i < tDataList->Count; i++) { data = (TVecData*)tDataList->Items[i]; tdata = new TVecData(data->GetInstNum()); tdata->Copy(data); tdata->bSelected = data->bSelected; // º¹»ç ºÙ¿©³Ö±â ½Ã º¸¿©Áöµµ·Ï - by monkman (2009.04.02) for (int l = 0; l < data->nCount * 3 + 1; l++) { tdata->pList[l].x = (data->pList[l].x - ParentData->centerX) * ParentData->proportion + ParentData->centerX; tdata->pList[l].y = (data->pList[l].y - ParentData->centerY) * ParentData->proportion + ParentData->centerY; } DataList->Add(tdata); } // ------------------------------------------ // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) POINT *pRefPoints = NULL; // pRefPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) int ReflectionIndex = -1; if (NVector->bVectorReflectionMode && ((NVector->ReflectionVH == 1 && NVector->ReflectionVIndex >= 0) || (NVector->ReflectionVH == 2 && NVector->ReflectionHIndex >= 0))) { // ¼öÁ÷ ±âÁؼ± if (NVector->ReflectionVH == 1) ReflectionIndex = NVector->ReflectionVIndex; // ¼öÆò ±âÁؼ± if (NVector->ReflectionVH == 2) ReflectionIndex = NVector->ReflectionHIndex; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- for (int k = 0; k < nSegment; k++) { for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; // --------------------------------------------- for (int l = 0; l < data->nCount * 3 + 1; l++) { data->pList[l].x = data->pList[l].x - ParentData->centerX + pTempList [3 * k].x; data->pList[l].y = data->pList[l].y - ParentData->centerY + pTempList [3 * k].y; } for (int l = 0; l < data->nCount * 3 + 1; l++) { double dx = data->pList[l].x - pTempList[3 * k].x; double dy = data->pList[l].y - pTempList[3 * k].y; data->pList[l].x = dx * cos(tangentlist[k]) - dy * sin(tangentlist[k]) + pTempList[3 * k].x; data->pList[l].y = dx * sin(tangentlist[k]) + dy * cos(tangentlist[k]) + pTempList[3 * k].y; } // --------------------------------------------- SET_RECT; FirstX = data->First.x * rx; FirstY = data->First.y * ry; SecondX = data->Second.x * rx; SecondY = data->Second.y * ry; // convert by celberus pw = data->PenThick / 2; resizedPenThick = max(1.0, data->PenThick * min(rx, ry)); // convert by celberus if (!data->Equal(MainImageForm->Number)) continue; int deltaX = 0, deltaY = 0; if (NVector->bMergeMode && data->bSelected) { // Merge Mode¿¡¼­ ¼±ÅÃµÈ ¿ÀºêÁ§Æ®ÀÇ ¸¶¿ì½º À̵¿¿¡ µû¸¥ ÁÂÇ¥ º¯°æ deltaX = MergeX; deltaY = MergeY; } if (data->Kind == V_TEXTBOX) { pPoints = new POINT[5]; } else { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new POINT[(data->nCount + 1) * 3 + 1]; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (MainImageForm->NVector->bVectorReflectionMode && (MainImageForm->NVector->ReflectionVH == 1 || MainImageForm->NVector->ReflectionVH == 2)) pRefPoints = new POINT[(data->nCount + 1) * 3 + 1]; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } else { pPoints = new POINT[data->nCount * 3 + 1]; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (MainImageForm->NVector->bVectorReflectionMode && (MainImageForm->NVector->ReflectionVH == 1 || MainImageForm->NVector->ReflectionVH == 2)) pRefPoints = new POINT[data->nCount * 3 + 1]; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } } if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int i = 0; i < data->nCount * 3 + 1; i++) { pPoints[i].x = (data->pList[i].x + deltaX) * rx; pPoints[i].y = (data->pList[i].y + deltaY) * ry; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (NVector->bVectorReflectionMode) { if (NVector->ReflectionVH == 1) { pRefPoints[i].x = (ReflectionIndex * 2 - (data->pList[i].x + deltaX)) * rx; pRefPoints[i].y = (data->pList[i].y + deltaY) * ry; } if (NVector->ReflectionVH == 2) { pRefPoints[i].x = (data->pList[i].x + deltaX) * rx; pRefPoints[i].y = (ReflectionIndex * 2 - (data->pList[i].y + deltaY)) * ry; } } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } } if (data->Kind == V_TEXTBOX) { FontZoom = rx; StartX = (data->StartPoint.x + deltaX) * rx; StartY = (data->StartPoint.y + deltaY) * ry; CenterX = (data->CenterPoint.x + deltaX) * rx; CenterY = (data->CenterPoint.y + deltaY) * ry; OffsetX = 0; OffsetY = 0; // by linuxjun for CurvedVectorText for (int i = 0; i < 5; i++) { pPoints[i].x = (data->pList[i].x + deltaX) * rx; pPoints[i].y = (data->pList[i].y + deltaY) * ry; } } //////// Closed Path last point and for nicer close if (data->bClosed && data->PenStyle == P_SOLID) { pPoints[data->nCount * 3] = pPoints[0]; pPoints[data->nCount * 3 + 1] = pPoints[1]; pPoints[data->nCount * 3 + 2] = pPoints[2]; pPoints[data->nCount * 3 + 3] = pPoints[3]; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (NVector->bVectorReflectionMode && (NVector->ReflectionVH == 1 || NVector->ReflectionVH == 2) ) { pRefPoints[data->nCount * 3] = pRefPoints[0]; pRefPoints[data->nCount * 3 + 1] = pRefPoints[1]; pRefPoints[data->nCount * 3 + 2] = pRefPoints[2]; pRefPoints[data->nCount * 3 + 3] = pRefPoints[3]; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } //////// nDrawMode = GetROP2(dcDst); nFillMode = GetPolyFillMode(dcDst); if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { // Text´Â Pen°ú Brush°¡ ÇÊ¿ä ¾ø´Ù logbrush.lbStyle = BS_SOLID; logbrush.lbColor = data->Brush; logbrush.lbHatch = 0; if (data->bPatternFill) { // PatternFill À϶§ FullView¿¡¼­´Â Ä¥ÇÏÁö ¾Ê´Â´Ù(¼Óµµ¹®Á¦) hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } else if (data->bFill) { // ColorFill À϶§ hBrush = CreateBrushIndirect(&logbrush); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); } else { // Fill X hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } if (data->bWinding) SetPolyFillMode(dcDst, WINDING); // ä¿ì±â ¸ðµå ¼±Åà else SetPolyFillMode(dcDst, ALTERNATE); logbrush.lbColor = data->Color; // ÆæÀÇ color¸¦ À§Çؼ­... switch(data->PenStyle) { case 0: nPenStyle = int(PS_SOLID); break; case 1: nPenStyle = int(PS_DASH); break; case 2: nPenStyle = int(PS_DOT); break; case 3: nPenStyle = int(PS_DASHDOT); break; case 4: nPenStyle = int(PS_DASHDOTDOT); break; case 5: nPenStyle = P_USERSTYLE; count = data->DashValues[0]; dashValues = new DWORD[count]; for (int i = 0; i < count; i++) { if (i % 2 == 0 && data->DashValues[i + 1] < data->PenThick) { if (data->bRound) dashValues[i] = 1; else dashValues[i] = (DWORD)(data->PenThick + 0.5) * (data->DashValues[i + 1] + 0.5); } else { dashValues[i] = (DWORD)(data->PenThick + 0.5) * (data->DashValues[i + 1] + 0.5); } } break; } if (osVERSION < 2) { // 3.1, 95, 98 hPen = CreatePen(psSolid, resizedPenThick, data->Color); } else { if (data->bRound) { // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù if (nPenStyle == 5) { // »ç¿ëÀÚ Á¤ÀÇ Ææ ½ºÅ¸ÀÏ hPen = ExtCreatePen (PS_GEOMETRIC | PS_USERSTYLE | PS_ENDCAP_ROUND | PS_JOIN_ROUND, int(resizedPenThick + 0.5), &logbrush, count, dashValues); } else { hPen = ExtCreatePen (PS_GEOMETRIC | nPenStyle | PS_ENDCAP_ROUND | PS_JOIN_ROUND, int(resizedPenThick + 0.5), &logbrush, 0, NULL); } } else { if (nPenStyle == 5) { // »ç¿ëÀÚ Á¤ÀÇ Ææ ½ºÅ¸ÀÏ hPen = ExtCreatePen (PS_GEOMETRIC | PS_USERSTYLE | PS_ENDCAP_FLAT | PS_JOIN_MITER, int(resizedPenThick + 0.5), &logbrush, count, dashValues); } else { hPen = ExtCreatePen (PS_GEOMETRIC | nPenStyle | PS_ENDCAP_FLAT | PS_JOIN_MITER, int(resizedPenThick + 0.5), &logbrush, 0, NULL); } } } hOldPen = (HPEN)SelectObject(dcDst, hPen); } else { nTemp = data->Font.lfHeight; data->Font.lfHeight = data->Font.lfHeight * min(rx, ry); // convert by celberus if (data->Font.lfHeight < 6) data->Font.lfHeight = 0; // ÅØ½ºÆ®´Â »çÀÌÁî°¡ ÃÖ¼Ò »çÀÌÁ´Ù ÀÛÀ¸¸é Ç×»ó ÃÖ¼Ò »çÀÌÁî·Î ±×¸®±â ¶§¹®¿¡ by celberus } if (data->Kind != V_TEXT || data->Font.lfHeight != 0) { if (!data->ParentTextBox) { // by linuxjun for CurvedVectorText if (!data->ChildList) { PAINT_FULLVIEW_VECTOR; } } } else { data->Font.lfHeight = nTemp; } if (!(data->ParentTextBox || data->ChildList)) { // by linuxjun for CurvedVectorText PAINT_FULLVIEW_VECTOR; } if (pPoints) delete[]pPoints; pPoints = NULL; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (MainImageForm->NVector->bVectorReflectionMode && (MainImageForm->NVector->ReflectionVH == 1 || MainImageForm->NVector->ReflectionVH == 2)) { if (pRefPoints) delete[]pRefPoints; } pRefPoints = NULL; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { SelectObject(dcDst, hOldBrush); SelectObject(dcDst, hOldPen); } if (hBrush) DeleteObject(hBrush); hBrush = NULL; if (hPen) DeleteObject(hPen); hPen = NULL; hOldPen = NULL; hOldBrush = NULL; if (dashValues) delete[]dashValues; dashValues = NULL; // 20090220 °¢µµº¯È¯ reverseÇÊ¿ä for (int l = 0; l < data->nCount * 3 + 1; l++) { double dx = data->pList[l].x - pTempList[3 * k].x; double dy = data->pList[l].y - pTempList[3 * k].y; data->pList[l].x = dx * cos(-tangentlist[k]) - dy * sin (-tangentlist[k]) + pTempList[3 * k].x; data->pList[l].y = dx * sin(-tangentlist[k]) + dy * cos (-tangentlist[k]) + pTempList[3 * k].y; } for (int l = 0; l < data->nCount * 3 + 1; l++) { data->pList[l].x = data->pList[l].x + ParentData->centerX - pTempList [3 * k].x; data->pList[l].y = data->pList[l].y + ParentData->centerY - pTempList [3 * k].y; } } } if (DataList) { for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (data) delete data; } DataList->Clear(); delete DataList; DataList = NULL; } if (tangentlist) delete[]tangentlist; tangentlist = NULL; // ¸Þ¸ð¸® ÇØÁ¦ - by monkman (2009.04.16) if (pTempList) { HeapFree(GetProcessHeap(), 0, pTempList); } pTempList = NULL; pPoints = NULL; pRefPoints = NULL; return; fail: if (DataList) { for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (data) delete data; } DataList->Clear(); delete DataList; DataList = NULL; } if (tangentlist) delete[]tangentlist; tangentlist = NULL; if (data) delete data; data = NULL; // ¸Þ¸ð¸® ÇØÁ¦ - by monkman (2009.04.16) if (pTempList) { HeapFree(GetProcessHeap(), 0, pTempList); } pTempList = NULL; if (pPoints) delete[]pPoints; pPoints = NULL; if (pRefPoints) delete[]pRefPoints; pRefPoints = NULL; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::TagDraw(HDC dcDst, int tagWidth, int tagHeight, TRect src, int method, TList *DataList, int textileVersion) // 090226 { TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) HPEN hOldPen = NULL, hPen = NULL; HBRUSH hOldBrush = NULL, hBrush = NULL; int nDrawMode, nFillMode, nTemp, nPenStyle; RGBQUAD rgb; HFONT font = NULL, oldfont = NULL; LOGBRUSH logbrush; Graphics::TBitmap *TempBitmap = NULL; int PositionX = src.Left; int PositionY = src.Top; int px = 0, py = 0, w, h; double rx, ry, Zoom; int FirstX, FirstY, SecondX, SecondY; double CenterX, CenterY, FontZoom = 1.0; int OffsetX, OffsetY; // by linuxjun for CurvedVectorText int StartX, StartY; int pw; bool bColorfill = false, bPatternfill = false, bGradientfill = false; TColor tColor = clBlack, tBrush = clBlack; int version; if (textileVersion == TextileFileVersionOld) version = 120; else if (textileVersion == TextileFileVersion10) version = 160; else version = 181; gdp::Graphics graphics(dcDst); // using GDI+ gdp::PointF *pPoints = NULL; if (DataList) { graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); // antialiasing // rx = 50.0 / (src.Right - src.Left); // ry = 50.0 / (src.Bottom - src.Top); rx = (double)tagWidth / (src.Right - src.Left); ry = (double)tagHeight / (src.Bottom - src.Top); } else { // MainImageForm¿¡ ÀÖ´Â DataList ¸»°í ´Ù¸¥ ¸®½ºÆ®µµ ¹ÞÀ» ¼ö ÀÖµµ·Ï ó¸® // TList *DataList = NVector->DataList; DataList = NVector->DataList; // 256À϶§´Â AntialiasingÀ¸·Î ±×¸®¸é ¾È µÈ´Ù.. - by monkman (2005.06.23) switch(MainImageForm->iMainImage->uBitmap->BitsPerPixel) { case 8: graphics.SetSmoothingMode(gdp::SmoothingModeNone); // None break; case 24: graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); // antialiasing break; default: graphics.SetSmoothingMode(gdp::SmoothingModeNone); // None break; } // rx = 80.0 / (src.Right - src.Left); // ry = 100.0 / (src.Bottom - src.Top); rx = (double)tagWidth / (src.Right - src.Left); ry = (double)tagHeight / (src.Bottom - src.Top); } if (rx > ry) { w = (src.Right - src.Left) * ry; h = (src.Bottom - src.Top) * ry; Zoom = double(h) / double(src.Bottom - src.top); } else { w = (src.Right - src.Left) * rx; h = (src.Bottom - src.Top) * rx; Zoom = double(w) / double(src.Right - src.Left); } for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (version < 170 && data->bMotive == true) continue; FirstX = (data->First.x - PositionX) * Zoom - px; FirstY = (data->First.y - PositionY) * Zoom - py; SecondX = (data->Second.x - PositionX) * Zoom - px; SecondY = (data->Second.y - PositionY) * Zoom - py; pw = data->PenThick / 2; // if (method == 4 && !data->bSelected) continue; // 4: ¼±ÅÃµÈ ¿ÀºêÁ§Æ®¸¸ ±×·ÁÁÜ if ((method & 8) && !data->bSelected) continue; // 4: ¼±ÅÃµÈ ¿ÀºêÁ§Æ®¸¸ ±×·ÁÁÜ if (MainImageForm->WorkArea->Mask) { // ÀÛ¾÷±¸¿ª ¹Ù±ù °´Ã¼´Â °É·¯ÁÜ TRect Src = MainImageForm->WorkArea->Range; bool bRange = true; // INRECTMETHOD; // ¿µ¿ª ¾È¿¡ ¾ø´Â°ÍÀº °É·¯³»´Â define if (!InRectMethod(Src, data, method, bRange)) continue; } // 090811 by david // Style Data(Color´Â ºí·¢, ColorFill, Pattern, Gradient Á¦¿Ü Çϰí ÀúÀå) if (method & 32) { tColor = data->Color, tBrush = data->Brush; bColorfill = data->bFill; bPatternfill = data->bPatternFill; bGradientfill = data->bGradientFill; data->Color = clBlack, data->Brush = clBlack; data->bFill = false; data->bPatternFill = false; data->bGradientFill = false; } float *dashValues = NULL; gdp::Color penColor(GetRValue(data->Color), GetGValue(data->Color), GetBValue(data->Color)); gdp::Color FillColor(GetRValue(data->Brush), GetGValue(data->Brush), GetBValue(data->Brush)); gdp::Pen ObjectPen(penColor, data->PenThick * Zoom); gdp::SolidBrush ObjectBrush(FillColor); gdp::GraphicsPath gFillPath; if (data->Kind == V_TEXTBOX) { pPoints = new gdp::PointF[5]; } else { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new gdp::PointF[(data->nCount + 1) * 3 + 1]; } else { pPoints = new gdp::PointF[data->nCount * 3 + 1]; } } if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int i = 0; i < data->nCount * 3 + 1; i++) { pPoints[i].X = (data->pList[i].x - PositionX) * Zoom - px; pPoints[i].Y = (data->pList[i].y - PositionY) * Zoom - py; } } if (data->Kind == V_TEXTBOX) { FontZoom = (double)Zoom; StartX = (data->StartPoint.x - PositionX) * Zoom - px; StartY = (data->StartPoint.y - PositionY) * Zoom - py; CenterX = (data->CenterPoint.x - PositionX) * Zoom - px; CenterY = (data->CenterPoint.y - PositionY) * Zoom - py; OffsetX = PositionX; OffsetY = PositionY; // by linuxjun for CurvedVectorText for (int i = 0; i < 5; i++) { pPoints[i].X = (data->pList[i].x - PositionX) * Zoom - px; pPoints[i].Y = (data->pList[i].y - PositionY) * Zoom - py; } } //////// Closed Path last point and for nicer close if (data->bClosed && data->PenStyle == P_SOLID) { // 2005 Vector Upgrade Shin 0315 pPoints[data->nCount * 3] = pPoints[0]; pPoints[data->nCount * 3 + 1] = pPoints[1]; pPoints[data->nCount * 3 + 2] = pPoints[2]; pPoints[data->nCount * 3 + 3] = pPoints[3]; } //////// nDrawMode = GetROP2(dcDst); nFillMode = GetPolyFillMode(dcDst); if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { // Text´Â Pen°ú Brush°¡ ÇÊ¿ä ¾ø´Ù logbrush.lbStyle = BS_SOLID; logbrush.lbColor = data->Brush; logbrush.lbHatch = 0; if (data->bPatternFill) { // PatternFill À϶§ int bltwidth, bltheight; HDC dcPattern = NULL, dcMask = NULL; if (!data->TBitmap) goto patternfail; if (!data->MaskBitmap) goto patternfail; if ((dcPattern = data->TBitmap->CreateDC()) == NULL) goto patternfail; if ((dcMask = data->MaskBitmap->CreateDC()) == NULL) goto patternfail; bltwidth = data->TBitmap->Width * Zoom; bltheight = data->TBitmap->Height * Zoom; // º¤ÅÍ ¿ÀºêÁ§Æ® ¾È¿¡ ä¿îºñÆ®¸Ê À̹ÌÁö Ãà¼Òº¸±â ÇßÀ» ¶§ Ä®¶ó³ª ÆÐÅÏÀÌ º¯ÁúµÇÁö ¾Êµµ·Ï ¼öÁ¤ - by monkman (2007.09.13) if (osVERSION < 2) { // 3.1, 95, 98 SetStretchBltMode(dcDst, COLORONCOLOR); } else { SetStretchBltMode(dcDst, HALFTONE); } StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcMask, 0, 0, data->MaskBitmap->Width, data->MaskBitmap->Height, SRCAND); StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcPattern, 0, 0, data->TBitmap->Width, data->TBitmap->Height, SRCPAINT); patternfail: if (dcPattern) { data->TBitmap->DeleteDC(dcPattern); dcPattern = NULL; } if (dcMask) { data->MaskBitmap->DeleteDC(dcMask); dcMask = NULL; } } else if (data->bFill) { // ColorFill À϶§ hBrush = CreateBrushIndirect(&logbrush); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); } else { // Fill X hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } // if (data->bWinding) SetPolyFillMode(dcDst, WINDING); // ä¿ì±â ¸ðµå ¼±Åà // else SetPolyFillMode(dcDst, ALTERNATE); if (data->bWinding) gFillPath.SetFillMode(gdp::FillModeWinding); else gFillPath.SetFillMode(gdp::FillModeAlternate); logbrush.lbColor = data->Color; // ÆæÀÇ color¸¦ À§Çؼ­... switch(data->PenStyle) { case 0: nPenStyle = int(PS_SOLID); break; case 1: nPenStyle = int(PS_DASH); break; case 2: nPenStyle = int(PS_DOT); break; case 3: nPenStyle = int(PS_DASHDOT); break; case 4: nPenStyle = int(PS_DASHDOTDOT); break; case 5: // 2005 Vector upgrade shin 0315 nPenStyle = P_USERSTYLE; int count = 0; double temp[6] = { 0, 0, 0, 0, 0, 0 }; CheckUserDashedLine(data, temp, count); dashValues = new float[count]; for (int i = 0; i < count; i++) { dashValues[i] = temp[i]; } // int count = data->DashValues[0]; // dashValues = new float[count]; // for (int i = 0; i < count; i++){ // dashValues[i] = data->DashValues[i+1]; // } ObjectPen.SetDashPattern(dashValues, count); break; // DashStyleCustom = 5 } if (osVERSION < 2) { // 3.1, 95, 98 hPen = CreatePen(psSolid, data->PenThick * Zoom, data->Color); } else { if (data->bRound) { // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù // hPen = ExtCreatePen(PS_GEOMETRIC | nPenStyle | PS_ENDCAP_ROUND | PS_JOIN_ROUND, // data->PenThick* Zoom, &logbrush, 0, NULL ); if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapRound); } } else { ObjectPen.SetStartCap(gdp::LineCapRound); ObjectPen.SetEndCap(gdp::LineCapRound); } ObjectPen.SetLineJoin(gdp::LineJoinRound); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapRound); } else { if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapFlat); } } else { ObjectPen.SetStartCap(gdp::LineCapFlat); ObjectPen.SetEndCap(gdp::LineCapFlat); } ObjectPen.SetLineJoin(gdp::LineJoinMiter); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapFlat); } } hOldPen = (HPEN)SelectObject(dcDst, hPen); } else { nTemp = data->Font.lfHeight; // FontÀÇ Å©±â Àӽà ÀúÀå data->Font.lfHeight = data->Font.lfHeight * Zoom + 0.5; if (data->Font.lfHeight == 0) data->Font.lfHeight = 1; } if (!(data->ParentTextBox || data->ChildList)) { // by linuxjun for CurvedVectorText PAINT_VECTOR; } if (data->ChildList) { // 090303 embakum motiveobjects // DrawMotiveObjects(dcDst, data, MainImageForm, 0, 0, 1); DrawMotiveObjects(dcDst, data, MainImageForm, 0, 0, 1, PositionX, PositionY, Zoom, -1, method); } if (pPoints) delete[]pPoints; pPoints = NULL; if (dashValues) delete[]dashValues; dashValues = NULL; if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { SelectObject(dcDst, hOldBrush); SelectObject(dcDst, hOldPen); } if (hBrush) DeleteObject(hBrush); hBrush = NULL; if (hPen) DeleteObject(hPen); hPen = NULL; hOldPen = NULL; hOldBrush = NULL; if (TempBitmap) { delete TempBitmap; TempBitmap = NULL; } // Àӽ÷Πó¸®ÇÑ ³»¿ëÀ» µÇµ¹¸®´Â ºÎºÐ if (method & 32) { data->Color = tColor, data->Brush = tBrush; data->bFill = bColorfill; data->bPatternFill = bPatternfill; data->bGradientFill = bGradientfill; } } // ÀÛ¾÷±¸¿ª¸¸Å­¸¸ ÀúÀåµÇµµ·Ï Çϰí, ³ª¸ÓÁö ¿µ¿ªÀº Èò»öÀ¸·Î ä¿öÁØ´Ù - by monkman (2009.04.16) gdp::Color FillColor(255, 255, 255); gdp::SolidBrush ObjectBrush(FillColor); if (w < 80 && h < 80) { graphics.FillRectangle(&ObjectBrush, w, 0, 79 - w, 99); graphics.FillRectangle(&ObjectBrush, 0, h, 79, 99 - h); } else if (w < 80) { graphics.FillRectangle(&ObjectBrush, w, 0, 79 - w, 99); } else if (h < 100) { graphics.FillRectangle(&ObjectBrush, 0, h, 79, 99 - h); } pPoints = NULL; return; fail: if (data) delete data; data = NULL; if (pPoints) delete[]pPoints; pPoints = NULL; } // --------------------------------------------------------------------------- TPException __fastcall TVecDraw::SaveVectorTag(HANDLE fh, TPalette *pPalette, TEXPIAFILEHEADER &src_tpfh, int method) { BEGIN_LOG(""); #ifdef TRIAL TEXPIAFILEHEADER_TRIAL tpfh; #else TEXPIAFILEHEADER tpfh; #endif DWORD dwWrite; TPException ec = EC_NONE; TRect src; TTexpiaBitmap *tag = NULL, *tb = NULL; HDC dcTmp = NULL, dcTmp2 = NULL; WORD bpp; RGBQUAD rgb[256]; int Version = 100; // ÀÛ¾÷±¸¿ªÀÌ ÀÖÀ» °æ¿ì ¼±ÅÃµÈ ¿µ¿ª¸¸Å­ Tag¸¦ ¸¸µç´Ù - by monkman (2005.08.02) if (MainImageForm->WorkArea->Mask) { src = MainImageForm->WorkArea->Range; } else { src.Left = 0; src.Top = 0; src.Right = MainImageForm->iMainImage->uBitmap->Width; src.Bottom = MainImageForm->iMainImage->uBitmap->Height; } ///////////////////////////////// Start of Standard Tag Format if ((tb = new TTexpiaBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { MainImageForm->iMainImage->uBitmap->GetColors(0, 256, rgb); if (!tb->Create(MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height, 8, rgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if (!tb->Create(MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height, 24)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } // if ((dcTmp = tb->CreateDC()) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } tb->FillRect(Rect(0, 0, MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height), clWhite); // iMainImage->FullViewPaint(dcTmp, 1, 1); // tb->DeleteDC(dcTmp); dcTmp = NULL; if ((tag = new TTexpiaBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } MakeTexpiaTag(tag, tb, src, 0); delete tb; ///// if ((dcTmp2 = tag->CreateDC()) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } TagDraw(dcTmp2, tag->Width, tag->Height, src, method); tag->DeleteDC(dcTmp2); dcTmp2 = NULL; ///// #ifdef TRIAL tpfh.Version = src_tpfh.Version; tpfh.CanvasInfor = src_tpfh.CanvasInfor; tpfh.BitsPerPixel = src_tpfh.BitsPerPixel; tpfh.Compress = src_tpfh.Compress; #else tpfh = src_tpfh; #endif WORD useColor; if (!WriteFile(fh, &tpfh, sizeof(TEXPIAFILEHEADER), &dwWrite, NULL)) return false; useColor = pPalette->UseColor; if (!WriteFile(fh, &useColor, sizeof(Word), &dwWrite, NULL)) return false; if (tpfh.Version.Number < 302) pPalette->SaveToFileHandle(fh, 1); else pPalette->SaveToFileHandle(fh, 2); bpp = tag->BitsPerPixel; if (!WriteFile(fh, &bpp, sizeof(WORD), &dwWrite, NULL)) return false; if (!tag->SaveToTexpiaFile(fh, cmNone)) return false; delete tag; ///////////////////////////////// End of Standard Tag Format if (!WriteFile(fh, &Version, sizeof(int), &dwWrite, NULL)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); goto fail; } // bmSim->SaveToTexpiaFile(fh, tpfh.Compress); // bmBot->SaveToTexpiaFile(fh, tpfh.Compress); // if ((ec = SaveDataToFile(fh))!=EC_NONE) goto fail; END_LOG; return EC_NONE; fail: if (tag) delete tag; if (fh != INVALID_HANDLE_VALUE) CloseHandle(fh); END_LOG; return ec; } // --------------------------------------------------------------------------- RECT __fastcall TVecDraw::GetUnionVectorRect(TList *DataList, int InstNum, bool bSelected) { // ¸®½ºÆ® ¾ÈÀÇ ¸ðµçÀÇ º¤ÅÍÀÇ µÑ·¹ - by monkman (2011.04.11) TVecData *data = NULL; TTexpiaBitmap *tpRegion = NULL; HDC dcRegion = NULL; HRGN rgnCurrent = NULL, rgnUnion = NULL; RECT rtRegion = TRect(0, 0, 0, 0); int nFillMode; tpRegion = new TTexpiaBitmap; if (tpRegion) { tpRegion->Create(MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height, 1); if (0 < tpRegion->Width && 0 < tpRegion->Height) { dcRegion = tpRegion->CreateDC(); if (dcRegion) { rgnUnion = CreateRectRgn(0, 0, 0, 0); for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (data && (data->GetInstNum() == InstNum || InstNum == -1)) { if (bSelected == false || (bSelected == true && data->bSelected == true)) { rgnCurrent = data->GetRegion(dcRegion); } } CombineRgn(rgnUnion, rgnCurrent, rgnUnion, RGN_OR); DeleteObject(rgnCurrent); } GetRgnBox(rgnUnion, &rtRegion); DeleteObject(rgnUnion); tpRegion->DeleteDC(dcRegion); } } delete tpRegion; } return rtRegion; } // --------------------------------------------------------------------------- // dc¿¡ º¤ÅÍ ±×¸®±â - by monkman (2011.04.07) double __fastcall TVecDraw::DrawVector(HDC dcDst, TList *DataList, int InstNum, int X, int Y, int W, int H, double Zoom, bool bCenter) { HPEN hOldPen = NULL, hPen = NULL; HBRUSH hOldBrush = NULL, hBrush = NULL; int nDrawMode, nFillMode, nTemp, nPenStyle; LOGBRUSH logbrush; Graphics::TBitmap *TempBitmap = NULL; int PositionX, PositionY; int px = 0, py = 0, w, h; double rx, ry; long minx = MaxInt, miny = MaxInt, maxx = 0, maxy = 0; double maxthick = 0; TRect src; TVecData *data = NULL; HFONT font = NULL, oldfont = NULL; double CenterX, CenterY, FontZoom = 1.0; int OffsetX, OffsetY; // by linuxjun for CurvedVectorText int StartX, StartY; gdp::Graphics graphics(dcDst); // using GDI+ gdp::PointF *pPoints = NULL; graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); // antialiasing if (DataList == NULL) return Zoom; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (InstNum != -1) if (!data->Equal(InstNum)) continue; minx = min(minx, data->First.x); minx = min(minx, data->Second.x); maxx = max(maxx, data->First.x); maxx = max(maxx, data->Second.x); miny = min(miny, data->First.y); miny = min(miny, data->Second.y); maxy = max(maxy, data->First.y); maxy = max(maxy, data->Second.y); maxthick = max(maxthick, data->PenThick); } src = Rect(minx - maxthick, miny - maxthick, maxx + maxthick, maxy + maxthick); rx = (double)W / (src.Right - src.Left); ry = (double)H / (src.Bottom - src.Top); if (rx > ry) { w = (src.Right - src.Left) * ry; h = (src.Bottom - src.Top) * ry; if (Zoom == 0.0) Zoom = double(h) / double(src.Bottom - src.Top); } else { w = (src.Right - src.Left) * rx; h = (src.Bottom - src.Top) * rx; if (Zoom == 0.0) Zoom = double(w) / double(src.Right - src.Left); } // if ((0 >= W || 0 >= H) && Zoom == 0.0) Zoom = 1.0; PositionX = src.Left; PositionY = src.Top; // Áß¾Ó if (bCenter) { px = (w - W) / 2 - X; py = (h - H) / 2 - Y; } else { px = -X; py = -Y; PositionX = 0; PositionY = 0; } for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (InstNum != -1) if (!data->Equal(InstNum)) continue; int FirstX = (data->First.x - PositionX) * Zoom - px; int FirstY = (data->First.y - PositionY) * Zoom - py; int SecondX = (data->Second.x - PositionX) * Zoom - px; int SecondY = (data->Second.y - PositionY) * Zoom - py; int pw = data->PenThick / 2; gdp::Color penColor(GetRValue(data->Color), GetGValue(data->Color), GetBValue(data->Color)); gdp::Color FillColor; FillColor = gdp::Color(GetRValue(data->Brush), GetGValue(data->Brush), GetBValue(data->Brush)); gdp::Pen ObjectPen(penColor, data->PenThick * Zoom); gdp::SolidBrush ObjectBrush(FillColor); gdp::GraphicsPath gFillPath; float *dashValues = NULL; if (data->Kind == V_TEXTBOX) { pPoints = new gdp::PointF[5]; } else { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new gdp::PointF[(data->nCount + 1) * 3 + 1]; } else { pPoints = new gdp::PointF[data->nCount * 3 + 1]; } } if (data->Kind == V_TEXTBOX) { StartX = (data->StartPoint.x - PositionX) * Zoom - px; StartY = (data->StartPoint.y - PositionY) * Zoom - py; CenterX = (data->CenterPoint.x - PositionX) * Zoom - px; CenterY = (data->CenterPoint.y - PositionY) * Zoom - py; OffsetX = PositionX; OffsetY = PositionY; FontZoom = Zoom; for (int i = 0; i < 5; i++) { pPoints[i].X = (data->pList[i].x - PositionX) * Zoom - px; pPoints[i].Y = (data->pList[i].y - PositionY) * Zoom - py; } } else { for (int i = 0; i < data->nCount * 3 + 1; i++) { pPoints[i].X = (data->pList[i].x - PositionX) * Zoom - px; pPoints[i].Y = (data->pList[i].y - PositionY) * Zoom - py; } } if (data->bClosed && data->PenStyle == P_SOLID) { pPoints[data->nCount * 3] = pPoints[0]; pPoints[data->nCount * 3 + 1] = pPoints[1]; pPoints[data->nCount * 3 + 2] = pPoints[2]; pPoints[data->nCount * 3 + 3] = pPoints[3]; } nDrawMode = GetROP2(dcDst); nFillMode = GetPolyFillMode(dcDst); if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { // Text´Â Pen°ú Brush°¡ ÇÊ¿ä¾ø´Ù logbrush.lbStyle = BS_SOLID; logbrush.lbColor = data->Brush; logbrush.lbHatch = 0; if (data->bPatternFill) { // PatternFill À϶§ - by monkman (ÇöÀç´Â TagDraw() ¿¡ PatternFillÀÌ ¾øÀ½..) } else if (data->bFill) { // ColorFill À϶§ hBrush = CreateBrushIndirect(&logbrush); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); } else { // Fill X hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } if (data->bWinding) gFillPath.SetFillMode(gdp::FillModeWinding); else gFillPath.SetFillMode(gdp::FillModeAlternate); logbrush.lbColor = data->Color; // ÆæÀÇ color¸¦ À§Çؼ­... switch(data->PenStyle) { case 0: nPenStyle = int(PS_SOLID); break; case 1: nPenStyle = int(PS_DASH); break; case 2: nPenStyle = int(PS_DOT); break; case 3: nPenStyle = int(PS_DASHDOT); break; case 4: nPenStyle = int(PS_DASHDOTDOT); break; case 5: nPenStyle = P_USERSTYLE; // 2005 Vector upgrade shin 0330 int count = 0; double temp[6] = { 0, 0, 0, 0, 0, 0 }; VecDraw->CheckUserDashedLine(data, temp, count); dashValues = new float[count]; for (int i = 0; i < count; i++) { dashValues[i] = temp[i]; } ObjectPen.SetDashPattern(dashValues, count); break; // DashStyleCustom = 5 } if (VecDraw->osVERSION < 2) { // 3.1, 95, 98 hPen = CreatePen(psSolid, data->PenThick * Zoom, data->Color); } else { if (data->bRound) { // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapRound); } } else { ObjectPen.SetStartCap(gdp::LineCapRound); ObjectPen.SetEndCap(gdp::LineCapRound); } ObjectPen.SetLineJoin(gdp::LineJoinRound); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapRound); } else { if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapFlat); } } else { ObjectPen.SetStartCap(gdp::LineCapFlat); ObjectPen.SetEndCap(gdp::LineCapFlat); } ObjectPen.SetLineJoin(gdp::LineJoinMiter); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapFlat); } } hOldPen = (HPEN)SelectObject(dcDst, hPen); } else { nTemp = data->Font.lfHeight; data->Font.lfHeight = data->Font.lfHeight * Zoom + 0.5; if (data->Font.lfHeight == 0) data->Font.lfHeight = 1; } SetROP2(dcDst, R2_COPYPEN); switch(data->Kind) { case V_LINE: graphics.DrawPolygon(&ObjectPen, pPoints, data->nCount + 1); break; case V_CURVE: if (data->bClosed && data->PenStyle == P_SOLID) { if (data->CapStyle[0] == 0) graphics.DrawBeziers(&ObjectPen, pPoints, (data->nCount + 1) * 3 + 1); else graphics.DrawBeziers(&ObjectPen, pPoints, data->nCount* 3 + 1); } else { if (data->ChildList) { // 090303 embakum motiveobjects DrawVectorMotiveObjects(dcDst, data, px, py, PositionX, PositionY, Zoom); } else { graphics.DrawBeziers(&ObjectPen, pPoints, data->nCount * 3 + 1); } } if (data->bFill) { gFillPath.AddBeziers(pPoints, data->nCount * 3 + 1); graphics.FillPath(&ObjectBrush, &gFillPath); graphics.DrawPath(&ObjectPen, &gFillPath); } break; case V_TEXT: Char * tempstr; tempstr = (Char*)malloc(data->nCount); for (int k = 0; k < data->nCount; k++) tempstr[k] = char(data->TextString[k + 1]); SetTextAlign(dcDst, TA_BOTTOM); SetTextColor(dcDst, data->Color); SetBkMode(dcDst, TRANSPARENT); font = CreateFontIndirect(&data->Font); oldfont = (HFONT)SelectObject(dcDst, font); TextOut(dcDst, FirstX, FirstY, tempstr, data->nCount); SelectObject(dcDst, oldfont); DeleteObject(font); data->Font.lfHeight = nTemp; free(tempstr); break; case V_TEXTBOX: VecDraw->DrawTextBox(dcDst, data, StartX, StartY, CenterX, CenterY, FontZoom, OffsetX, OffsetY); break; } if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { if (dashValues) delete[]dashValues; dashValues = NULL; SetROP2(dcDst, nDrawMode); SetPolyFillMode(dcDst, nFillMode); SelectObject(dcDst, hOldBrush); SelectObject(dcDst, hOldPen); if (hBrush) DeleteObject(hBrush); if (hPen) DeleteObject(hPen); } if (pPoints) delete[]pPoints; pPoints = NULL; hOldPen = NULL; hOldBrush = NULL; hPen = NULL; hBrush = NULL; } pPoints = NULL; return Zoom; fail: if (pPoints) delete[]pPoints; pPoints = NULL; if (data) delete data; data = NULL; return 0; } // --------------------------------------------------------------------------- // DrawVector¿¡¼­ MotiveObject ±×¸®±â - by monkman (2011.04.07) void __fastcall TVecDraw::DrawVectorMotiveObjects(HDC dcDst, TVecData* ParentData, int px, int py, int PositionX, int PositionY, float Zoom) { TList *tDataList = ParentData->ChildList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) TList *DataList = new TList; TList * ResultBezierPointList; TPointList *tempPointList; bool bSelectedLine; DPOINT firstPoint, onPoint, normalPoint, tempCurpt, tempOldpt; DPOINT *pTempList = NULL; double dInterval; TBezierPointList * BezierPointList = new TBezierPointList(); // »ý¼º BezierPointList->Init(ParentData); double CurveLength = BezierPointList->GetCurveLength(); int nSegment; int quotient = int(CurveLength / ((ParentData->proportion) * (ParentData->childwidth))); if (quotient == 0) quotient = 1; switch(ParentData->mode) { case 0: // ²Ë ä¿ì±â nSegment = int(CurveLength / ((ParentData->proportion) * (ParentData->childwidth))); if (nSegment == 0) nSegment = 1; ParentData->gap = double(CurveLength / nSegment); ParentData->motivecount = nSegment; break; case 1: // °³¼ö ¼³Á¤ nSegment = StrToInt(ParentData->motivecount); if (nSegment == 0) nSegment = 1; ParentData->gap = double(CurveLength / nSegment); break; case 2: // °£°Ý ¼³Á¤ nSegment = int(CurveLength / ParentData->gap); if (nSegment == 0) nSegment = 1; ParentData->motivecount = nSegment; break; } int count = 1; ResultBezierPointList = BezierPointList->Calculate(ParentData, nSegment); if (!ResultBezierPointList) { delete DataList; DataList; delete BezierPointList; BezierPointList = NULL; return; } pTempList = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * (nSegment * 3 + 1)); double *tangentlist = new double[nSegment + 1]; // ±â¿ï±â¸¦ °¡Áö°í ÀÖ´Â ¹è¿­ firstPoint = VecDraw->FindingNormalOnBezier(&ParentData->pList[0], 0, 0, 0); pTempList[0].x = firstPoint.x; pTempList[0].y = firstPoint.y; pTempList[1].x = firstPoint.x; pTempList[1].y = firstPoint.y; tangentlist[0] = VecDraw->FindCurveTangent(&ParentData->pList[0], 0); for (int i = 0; i < ResultBezierPointList->Count; i++) { tempPointList = (TPointList*)ResultBezierPointList->Items[i]; for (tempPointList->First(); !tempPointList->IsDone(); tempPointList->Next()) { dInterval = tempPointList->CurrentDouble(); // BezierCurve À§ÀÇ Á¡À§Ä¡ // onPoint = FindingPointOnBezier(&tData->pList[i*3], dInterval); // ãÀº Á¡ÀÇ NormalÀÇ À§Ä¡ (ãÀº Á¡Àº ResultBezierPointList¾È¿¡ ÀÖÀ½) normalPoint = VecDraw->FindingNormalOnBezier(&ParentData->pList[i * 3], dInterval, 0, count % 2); tangentlist[count] = VecDraw->FindCurveTangent(&ParentData->pList[i * 3], dInterval); pTempList[count * 3 - 2] = pTempList[count * 3 - 3]; pTempList[count * 3 - 1].x = normalPoint.x; pTempList[count * 3 - 1].y = normalPoint.y; pTempList[count * 3].x = normalPoint.x; pTempList[count * 3].y = normalPoint.y; count++; tempOldpt = tempCurpt; } } if (ParentData->bClosed) { // ´ÝÈù ¿ÀºêÁ§Æ®ÀÇ °æ¿ì ³¡Á¡°ú ùÁ¡À» °°°Ô. pTempList[nSegment * 3] = pTempList[0]; pTempList[nSegment * 3 - 1] = pTempList[0]; } delete BezierPointList; BezierPointList = NULL; ///////////////////////////////////////////////////// HPEN hOldPen = NULL, hPen = NULL; HBRUSH hOldBrush = NULL, hBrush = NULL; int nDrawMode, nFillMode, nTemp, nPenStyle; LOGBRUSH logbrush; Graphics::TBitmap *TempBitmap = NULL; TRect src; gdp::Graphics graphics(dcDst); // using GDI+ gdp::PointF *pPoints = NULL; graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); // antialiasing ///////////////////////////////////////////////////// TVecData *tdata; // motive childÀÇ È®´ë Ãà¼Ò for (int i = 0; i < tDataList->Count; i++) { data = (TVecData*)tDataList->Items[i]; tdata = new TVecData(data->GetInstNum()); tdata->Copy(data); tdata->bSelected = data->bSelected; // º¹»ç ºÙ¿©³Ö±â ½Ã º¸¿©Áöµµ·Ï - by monkman (2009.04.02) for (int l = 0; l < data->nCount * 3 + 1; l++) { tdata->pList[l].x = (data->pList[l].x - ParentData->centerX) * ParentData->proportion + ParentData->centerX; tdata->pList[l].y = (data->pList[l].y - ParentData->centerY) * ParentData->proportion + ParentData->centerY; } DataList->Add(tdata); } ///////////////////////////////////////////////////// for (int k = 0; k < nSegment; k++) { for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; for (int l = 0; l < data->nCount * 3 + 1; l++) { data->pList[l].x = data->pList[l].x - ParentData->centerX + pTempList [3 * k].x; data->pList[l].y = data->pList[l].y - ParentData->centerY + pTempList [3 * k].y; } for (int l = 0; l < data->nCount * 3 + 1; l++) { double dx = data->pList[l].x - pTempList[3 * k].x; double dy = data->pList[l].y - pTempList[3 * k].y; data->pList[l].x = dx * cos(tangentlist[k]) - dy * sin(tangentlist[k]) + pTempList[3 * k].x; data->pList[l].y = dx * sin(tangentlist[k]) + dy * cos(tangentlist[k]) + pTempList[3 * k].y; } SET_RECT; // gradientfill int FirstX = (data->First.x - PositionX) * Zoom - px; int FirstY = (data->First.y - PositionY) * Zoom - py; int SecondX = (data->Second.x - PositionX) * Zoom - px; int SecondY = (data->Second.y - PositionY) * Zoom - py; int pw = data->PenThick / 2; gdp::Color penColor(GetRValue(data->Color), GetGValue(data->Color), GetBValue(data->Color)); gdp::Color FillColor; FillColor = gdp::Color(GetRValue(data->Brush), GetGValue(data->Brush), GetBValue(data->Brush)); gdp::Pen ObjectPen(penColor, data->PenThick * Zoom); gdp::SolidBrush ObjectBrush(FillColor); gdp::GraphicsPath gFillPath; float *dashValues = NULL; if (data->Kind == V_TEXTBOX) { pPoints = new gdp::PointF[5]; } else { if (data->bClosed) { pPoints = new gdp::PointF[(data->nCount + 1) * 3 + 1]; } else { pPoints = new gdp::PointF[data->nCount * 3 + 1]; } } // TEXTBOX ¼öÁ¤½Ã ÀÌ ºÎºÐÀ» ¼öÁ¤ - by monkman if (data->Kind != V_TEXTBOX) { for (int i = 0; i < data->nCount * 3 + 1; i++) { pPoints[i].X = (data->pList[i].x - PositionX) * Zoom - px; pPoints[i].Y = (data->pList[i].y - PositionY) * Zoom - py; } } if (data->bClosed && data->PenStyle == P_SOLID) { pPoints[data->nCount * 3] = pPoints[0]; pPoints[data->nCount * 3 + 1] = pPoints[1]; pPoints[data->nCount * 3 + 2] = pPoints[2]; pPoints[data->nCount * 3 + 3] = pPoints[3]; } nDrawMode = GetROP2(dcDst); nFillMode = GetPolyFillMode(dcDst); logbrush.lbStyle = BS_SOLID; logbrush.lbColor = data->Brush; logbrush.lbHatch = 0; if (data->bPatternFill) { } else if (data->bFill) { // ColorFill À϶§ hBrush = CreateBrushIndirect(&logbrush); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); } else { // Fill X hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } if (data->bWinding) gFillPath.SetFillMode(gdp::FillModeWinding); else gFillPath.SetFillMode(gdp::FillModeAlternate); logbrush.lbColor = data->Color; // ÆæÀÇ color¸¦ À§Çؼ­... switch(data->PenStyle) { case 0: nPenStyle = int(PS_SOLID); break; case 1: nPenStyle = int(PS_DASH); break; case 2: nPenStyle = int(PS_DOT); break; case 3: nPenStyle = int(PS_DASHDOT); break; case 4: nPenStyle = int(PS_DASHDOTDOT); break; case 5: nPenStyle = P_USERSTYLE; // 2005 Vector upgrade shin 0330 int count = 0; double temp[6] = { 0, 0, 0, 0, 0, 0 }; VecDraw->CheckUserDashedLine(data, temp, count); dashValues = new float[count]; for (int i = 0; i < count; i++) { dashValues[i] = temp[i]; } ObjectPen.SetDashPattern(dashValues, count); break; // DashStyleCustom = 5 } if (VecDraw->osVERSION < 2) { // 3.1, 95, 98 hPen = CreatePen(psSolid, data->PenThick * Zoom, data->Color); } else { if (data->bRound) { // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù ObjectPen.SetStartCap(gdp::LineCapRound); ObjectPen.SetEndCap(gdp::LineCapRound); ObjectPen.SetLineJoin(gdp::LineJoinRound); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapRound); } else { ObjectPen.SetStartCap(gdp::LineCapFlat); ObjectPen.SetEndCap(gdp::LineCapFlat); ObjectPen.SetLineJoin(gdp::LineJoinMiter); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapFlat); } } hOldPen = (HPEN)SelectObject(dcDst, hPen); SetROP2(dcDst, R2_COPYPEN); switch(data->Kind) { case V_LINE: graphics.DrawPolygon(&ObjectPen, pPoints, data->nCount + 1); break; case V_CURVE: if (data->bClosed && data->PenStyle == P_SOLID) { graphics.DrawBeziers(&ObjectPen, pPoints, (data->nCount + 1) * 3 + 1); } else { graphics.DrawBeziers(&ObjectPen, pPoints, data->nCount * 3 + 1); } if (data->bFill) { gFillPath.AddBeziers(pPoints, data->nCount * 3 + 1); graphics.FillPath(&ObjectBrush, &gFillPath); graphics.DrawPath(&ObjectPen, &gFillPath); } break; } if (dashValues) delete[]dashValues; dashValues = NULL; if (pPoints) delete[]pPoints; pPoints = NULL; SetROP2(dcDst, nDrawMode); SetPolyFillMode(dcDst, nFillMode); SelectObject(dcDst, hOldBrush); SelectObject(dcDst, hOldPen); if (hBrush) DeleteObject(hBrush); if (hPen) DeleteObject(hPen); hOldPen = NULL; hOldBrush = NULL; hPen = NULL; hBrush = NULL; // 20090220 °¢µµº¯È¯ reverseÇÊ¿ä for (int l = 0; l < data->nCount * 3 + 1; l++) { double dx = data->pList[l].x - pTempList[3 * k].x; double dy = data->pList[l].y - pTempList[3 * k].y; data->pList[l].x = dx * cos(-tangentlist[k]) - dy * sin (-tangentlist[k]) + pTempList[3 * k].x; data->pList[l].y = dx * sin(-tangentlist[k]) + dy * cos (-tangentlist[k]) + pTempList[3 * k].y; } for (int l = 0; l < data->nCount * 3 + 1; l++) { data->pList[l].x = data->pList[l].x + ParentData->centerX - pTempList [3 * k].x; data->pList[l].y = data->pList[l].y + ParentData->centerY - pTempList [3 * k].y; } } } if (DataList) { for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (data) delete data; } DataList->Clear(); delete DataList; DataList = NULL; } if (tangentlist) delete[]tangentlist; tangentlist = NULL; // ¸Þ¸ð¸® ÇØÁ¦ - by monkman (2009.04.16) if (pTempList) { HeapFree(GetProcessHeap(), 0, pTempList); } pTempList = NULL; pPoints = NULL; return; fail: if (data) delete data; data = NULL; if (DataList) { for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (data) delete data; } DataList->Clear(); delete DataList; DataList = NULL; } if (tangentlist) delete[]tangentlist; tangentlist = NULL; // ¸Þ¸ð¸® ÇØÁ¦ - by monkman (2009.04.16) if (pTempList) { HeapFree(GetProcessHeap(), 0, pTempList); } pTempList = NULL; if (pPoints) delete[]pPoints; pPoints = NULL; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::ConvertToBitmap(TObject *Sender, HDC dcDst, bool bVectorDelete, int px, int py, bool isFinished) { TList *DataList = NVector->DataList; if (ConvertToBitmap(dcDst, DataList, MainImageForm, px, py, isFinished, bVectorDelete) == false) { if (dcDst) MainImageForm->iMainImage->uBitmap->DeleteDC(dcDst); } } // --------------------------------------------------------------------------- bool __fastcall TVecDraw::ConvertToBitmap(HDC dcDst, TList *DataList, TMainImageForm *mif, int px, int py, bool isFinished, bool bVectorDelete) { BEGIN_LOG(""); // TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) HPEN hOldPen = NULL, hPen = NULL; HBRUSH hOldBrush = NULL, hBrush = NULL; LOGBRUSH logbrush; int nDrawMode, nFillMode, nTemp, nPenStyle; HFONT font = NULL, oldfont = NULL; bool sw = true; int FirstX, FirstY, SecondX, SecondY; double CenterX, CenterY, FontZoom = 1.0; int OffsetX, OffsetY; // by linuxjun for CurvedVectorText int StartX, StartY; int pw; gdp::Graphics graphics(dcDst); // using GDI+ 2005 Vector Upgrade Shin 0315 gdp::PointF *pPoints = NULL; // È­¸é¿¡ º¸¿©Áö´Â´ë·Î º¯È¯ or ¸ðµÎ antialiasing ÇØÁ¦ ÈÄ º¯È¯ // 256 color¿¡¼­ µµ½ÄÈ­ÀÛ¾÷ÇÏ´Â °æ¿ì ¶óÀο¡ antialiasingÀû¿ëµÇ¸é ¶óÀλöÀÌ ÀÏÁ¤ÇÏÁö ¾ÊÀ¸¹Ç·Î // antialiasing ÇØÁ¦ÀÇ °æ¿ì V_TEXTBOXÀÇ bAntialiasing ¸ðµÎ false·Î º¯È¯. // if (!(*bCancelAntialiasing)){ // graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); // antialiasing // } for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(mif->Number)) continue; FirstX = data->First.x - px; FirstY = data->First.y - py; SecondX = data->Second.x - px; SecondY = data->Second.y - py; pw = data->PenThick / 2; float *dashValues = NULL; gdp::Color penColor(GetRValue(data->Color), GetGValue(data->Color), GetBValue(data->Color)); gdp::Color FillColor(GetRValue(data->Brush), GetGValue(data->Brush), GetBValue(data->Brush)); gdp::Pen ObjectPen(penColor, data->PenThick); gdp::SolidBrush ObjectBrush(FillColor); gdp::GraphicsPath gFillPath; if (!(NVector->bCancelAntialiasing) && data->bAntialiasing) { graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); // antialiasing } else { graphics.SetSmoothingMode(gdp::SmoothingModeNone); } // if (*bCancelAntialiasing && data->bAntialiasing) data->bAntialiasing = false; //20050222 shin if (data->Kind == V_TEXTBOX) { pPoints = new gdp::PointF[5]; } else { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new gdp::PointF[(data->nCount + 1) * 3 + 1]; } else { pPoints = new gdp::PointF[data->nCount * 3 + 1]; } } if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int i = 0; i < data->nCount * 3 + 1; i++) { pPoints[i].X = data->pList[i].x - px; pPoints[i].Y = data->pList[i].y - py; } } if (data->Kind == V_TEXTBOX) { StartX = data->StartPoint.x - px; StartY = data->StartPoint.y - py; CenterX = data->CenterPoint.x - px; CenterY = data->CenterPoint.y - py; OffsetX = px; OffsetY = py; // by linuxjun for CurvedVectorText for (int i = 0; i < 5; i++) { pPoints[i].X = data->pList[i].x - px; pPoints[i].Y = data->pList[i].y - py; } } //////// Closed Path last point and for nicer close if (data->bClosed && data->PenStyle == P_SOLID) { // 2005 Vector Upgrade Shin 0315 pPoints[data->nCount * 3] = pPoints[0]; pPoints[data->nCount * 3 + 1] = pPoints[1]; pPoints[data->nCount * 3 + 2] = pPoints[2]; pPoints[data->nCount * 3 + 3] = pPoints[3]; } //////// nDrawMode = GetROP2(dcDst); nFillMode = GetPolyFillMode(dcDst); if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { // Text´Â Pen°ú Brush°¡ ÇÊ¿ä ¾ø´Ù logbrush.lbStyle = BS_SOLID; logbrush.lbColor = data->Brush; logbrush.lbHatch = 0; if (data->bPatternFill) { // PatternFill À϶§ int bltwidth, bltheight; HDC dcPattern, dcMask; bltwidth = data->TBitmap->Width; bltheight = data->TBitmap->Height; // PatternFillµÈ BitmapÀÇ »çÀÌÁî°¡ 0ÀÌ µÇ¾î¹ö¸®¸é fail·Î ºüÁö°í FullViewDraw¿¡¼­ Access°¡ ¹ß»ýÇϹǷΠ// BitmapÀÇ »çÀÌÁ °Ë»çÇÑ´Ù - by monkman (2005.02.19) if (bltwidth > 0 && bltheight > 0) { if ((dcPattern = data->TBitmap->CreateDC()) == NULL) goto fail; if ((dcMask = data->MaskBitmap->CreateDC()) == NULL) goto fail; StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcMask, 0, 0, data->MaskBitmap->Width, data->MaskBitmap->Height, SRCAND); StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcPattern, 0, 0, data->TBitmap->Width, data->TBitmap->Height, SRCPAINT); data->TBitmap->DeleteDC(dcPattern); dcPattern = NULL; data->MaskBitmap->DeleteDC(dcMask); dcMask = NULL; } } else if (data->bFill) { // ColorFill À϶§ hBrush = CreateBrushIndirect(&logbrush); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); } else { // Fill X hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } // if (data->bWinding) SetPolyFillMode(dcDst, WINDING); // ä¿ì±â ¸ðµå ¼±Åà // else SetPolyFillMode(dcDst, ALTERNATE); if (data->bWinding) gFillPath.SetFillMode(gdp::FillModeWinding); else gFillPath.SetFillMode(gdp::FillModeAlternate); logbrush.lbColor = data->Color; // ÆæÀÇ color¸¦ À§Çؼ­... switch(data->PenStyle) { case 0: nPenStyle = int(PS_SOLID); break; case 1: nPenStyle = int(PS_DASH); break; case 2: nPenStyle = int(PS_DOT); break; case 3: nPenStyle = int(PS_DASHDOT); break; case 4: nPenStyle = int(PS_DASHDOTDOT); break; case 5: // 2005 Vector upgrade shin 0303 nPenStyle = P_USERSTYLE; int count = 0; double temp[6] = { 0, 0, 0, 0, 0, 0 }; CheckUserDashedLine(data, temp, count); dashValues = new float[count]; for (int i = 0; i < count; i++) { dashValues[i] = temp[i]; } // int count = data->DashValues[0]; // dashValues = new float[count]; // for (int i = 0; i < count; i++){ // dashValues[i] = data->DashValues[i+1]; // } ObjectPen.SetDashPattern(dashValues, count); break; // DashStyleCustom = 5 } if (osVERSION < 2) { // 3.1, 95, 98 hPen = CreatePen(psSolid, data->PenThick, data->Color); } else { if (data->bRound) { // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapRound); } } // À̽´ ÃßÀû¹øÈ£ - 191001 [MeasurementArrowCap] else if (data->CapStyle[0] == 2 && data->CapStyle[1] == 2){ double CapWidth = data->ArrowCap->LineCapWidth * data->ArrowCap->LineCapWidthScale; // Cap Æø ºñÀ² double CapHeight = data->ArrowCap->LineCapHeight * data->ArrowCap->LineCapWidthScale; double LineCapWidth = 0.5 * data->ArrowCap->LineCapLine; double LineCapWidthPositive = LineCapWidth; double LineCapWidthNegative = 0.5; double LineMiddlePointWidth = 1; if(LineCapWidthPositive < 0.5){ LineCapWidthNegative -= (0.5 - LineCapWidthPositive); LineCapWidthPositive = 0.5; } gdp::PointF ArrowShape[8] = {gdp::PointF(-(CapWidth),(LineCapWidthPositive)), gdp::PointF(-(CapWidth),-(LineCapWidthNegative)), gdp::PointF(-LineMiddlePointWidth, -(LineCapWidthNegative)), gdp::PointF(-(CapWidth), -(CapHeight)), gdp::PointF((CapWidth), -(CapHeight)), gdp::PointF(LineMiddlePointWidth, -(LineCapWidthNegative)), gdp::PointF((CapWidth), -(LineCapWidthNegative)), gdp::PointF((CapWidth),(LineCapWidthPositive))}; gdp::GraphicsPath capPath; capPath.AddPolygon(ArrowShape,8); gdp::CustomLineCap arrowLineCap(&capPath,NULL); ObjectPen.SetCustomStartCap(&arrowLineCap); if (data->ArrowCap->bShowArrowBoth){ ObjectPen.SetCustomEndCap(&arrowLineCap); } } else { ObjectPen.SetStartCap(gdp::LineCapRound); ObjectPen.SetEndCap(gdp::LineCapRound); } ObjectPen.SetLineJoin(gdp::LineJoinRound); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapRound); } else { if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapFlat); } } else { ObjectPen.SetStartCap(gdp::LineCapFlat); ObjectPen.SetEndCap(gdp::LineCapFlat); } ObjectPen.SetLineJoin(gdp::LineJoinMiter); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapFlat); } } hOldPen = (HPEN)SelectObject(dcDst, hPen); } else { nTemp = data->Font.lfHeight; data->Font.lfHeight = data->Font.lfHeight; } if (!(data->ParentTextBox || data->ChildList)) { // by linuxjun for CurvedVectorText PAINT_VECTOR; } if (data->ChildList) { // 090303 embakum motiveobjects // ±×¸®´Â °Í ¿©±â¼­ ±¸Çö. by embakum 20090217 ¸ðƼºê DrawMotiveObjects(dcDst, data, mif, px, py, 3); } if (pPoints) delete[]pPoints; pPoints = NULL; if (dashValues) delete[]dashValues; dashValues = NULL; if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { SelectObject(dcDst, hOldBrush); SelectObject(dcDst, hOldPen); } if (hBrush) DeleteObject(hBrush); if (hPen) DeleteObject(hPen); hOldPen = NULL; hOldBrush = NULL; hPen = NULL; hBrush = NULL; if (isFinished && bVectorDelete) { // convert by celberus // -->by linuxjun for CurvedVectorText if (!data->ParentTextBox) { if (data->ListOfAllLine) { int seqNum; UndoSave(VU_TEXTDELETE, i, sw); sw = false; if (data->ListOfAllLine->CurveData) { seqNum = DataList->Remove(data->ListOfAllLine->CurveData); delete data->ListOfAllLine->CurveData; data->ListOfAllLine->CurveData = NULL; if (seqNum <= i) { i--; } } DataList->Delete(i); if (data->Bitmap) { delete data->Bitmap; data->Bitmap = NULL; } if (data) delete data; data = NULL; i--; } else { // <--by linuxjun for CurvedVectorText UndoSave(VU_DELETE, i, sw); sw = false; DataList->Delete(i); if (data->Bitmap) { delete data->Bitmap; data->Bitmap = NULL; } if (data) delete data; data = NULL; i--; } } } } pPoints = NULL; // MainImageForm->iMainImage->Repaint(); convert by celberus END_LOG; return true; fail: // if (dcDst) // MainImageForm->iMainImage->uBitmap->DeleteDC(dcDst); // delete data; // data = NULL; if (pPoints) delete[]pPoints; pPoints = NULL; END_LOG; return false; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::ConvertToBitmapMask(TObject *Sender, HDC dcDst, int px, int py) { TList *DataList = NVector->DataList; if (ConvertToBitmapMask(dcDst, DataList, MainImageForm, px, py) == false) { if (dcDst) MainImageForm->iMainImage->uBitmap->DeleteDC(dcDst); } } // --------------------------------------------------------------------------- bool __fastcall TVecDraw::ConvertToBitmapMask(HDC dcDst, TList *DataList, TMainImageForm *mif, int px, int py) { BEGIN_LOG(""); // TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) HPEN hOldPen = NULL, hPen = NULL; HBRUSH hOldBrush = NULL, hBrush = NULL; LOGBRUSH logbrush; int nDrawMode, nFillMode, nTemp, nPenStyle; HFONT font = NULL, oldfont = NULL; bool sw = true; int FirstX, FirstY, SecondX, SecondY; double CenterX, CenterY, FontZoom = 1.0; int OffsetX, OffsetY; // by linuxjun for CurvedVectorText int StartX, StartY; int pw; // MainImageForm->iMainImage->Repaint(); convert by celberus gdp::Graphics graphics(dcDst); // using GDI+ gdp::PointF *pPoints = NULL; // È­¸é¿¡ º¸¿©Áö´Â´ë·Î º¯È¯ or ¸ðµÎ antialiasing ÇØÁ¦ ÈÄ º¯È¯ // 256 color¿¡¼­ µµ½ÄÈ­ÀÛ¾÷ÇÏ´Â °æ¿ì ¶óÀο¡ antialiasingÀû¿ëµÇ¸é ¶óÀλöÀÌ ÀÏÁ¤ÇÏÁö ¾ÊÀ¸¹Ç·Î // antialiasing ÇØÁ¦ÀÇ °æ¿ì V_TEXTBOXÀÇ bAntialiasing ¸ðµÎ false·Î º¯È¯. for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(mif->Number)) continue; float *dashValues = NULL; gdp::Color penColor(0, 0, 0); gdp::Color FillColor(0, 0, 0); gdp::Pen ObjectPen(penColor, data->PenThick); gdp::SolidBrush ObjectBrush(FillColor); gdp::GraphicsPath gFillPath; if (!(NVector->bCancelAntialiasing) && data->bAntialiasing) { graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); // antialiasing } else { graphics.SetSmoothingMode(gdp::SmoothingModeNone); } FirstX = data->First.x - px; FirstY = data->First.y - py; SecondX = data->Second.x - px; SecondY = data->Second.y - py; pw = data->PenThick / 2; // if (*bCancelAntialiasing && data->bAntialiasing) data->bAntialiasing = false; //20050222 shin if (data->Kind == V_TEXTBOX) { pPoints = new gdp::PointF[5]; } else { if (data->bClosed) { pPoints = new gdp::PointF[(data->nCount + 1) * 3 + 1]; } else { pPoints = new gdp::PointF[data->nCount * 3 + 1]; } } if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int i = 0; i < data->nCount * 3 + 1; i++) { pPoints[i].X = data->pList[i].x - px; pPoints[i].Y = data->pList[i].y - py; } } if (data->Kind == V_TEXTBOX) { StartX = data->StartPoint.x - px; StartY = data->StartPoint.y - py; CenterX = data->CenterPoint.x - px; CenterY = data->CenterPoint.y - py; OffsetX = px; OffsetY = py; // by linuxjun for CurvedVectorText for (int i = 0; i < 5; i++) { pPoints[i].X = data->pList[i].x - px; pPoints[i].Y = data->pList[i].y - py; } } //////// Closed Path last point and for nicer close if (data->bClosed && data->PenStyle == P_SOLID) { pPoints[data->nCount * 3] = pPoints[0]; pPoints[data->nCount * 3 + 1] = pPoints[1]; pPoints[data->nCount * 3 + 2] = pPoints[2]; pPoints[data->nCount * 3 + 3] = pPoints[3]; } //////// nDrawMode = GetROP2(dcDst); nFillMode = GetPolyFillMode(dcDst); if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { // Text´Â Pen°ú Brush°¡ ÇÊ¿ä ¾ø´Ù logbrush.lbStyle = BS_SOLID; // logbrush.lbColor = data->Brush; logbrush.lbColor = clBlack; logbrush.lbHatch = 0; if (data->bPatternFill) { // PatternFill À϶§ int bltwidth, bltheight; HDC dcPattern, dcMask; bltwidth = data->TBitmap->Width; bltheight = data->TBitmap->Height; // PatternFillµÈ BitmapÀÇ »çÀÌÁî°¡ 0ÀÌ µÇ¾î¹ö¸®¸é fail·Î ºüÁö°í FullViewDraw¿¡¼­ Access°¡ ¹ß»ýÇϹǷΠ// BitmapÀÇ »çÀÌÁ °Ë»çÇÑ´Ù - by monkman (2005.02.19) if (bltwidth > 0 && bltheight > 0) { // if ((dcPattern = data->TBitmap->CreateDC())==NULL) goto fail; if ((dcMask = data->MaskBitmap->CreateDC()) == NULL) goto fail; StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcMask, 0, 0, data->MaskBitmap->Width, data->MaskBitmap->Height, SRCAND); // StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcPattern, 0,0, // data->TBitmap->Width, data->TBitmap->Height, SRCPAINT); // data->TBitmap->DeleteDC(dcPattern); dcPattern = NULL; data->MaskBitmap->DeleteDC(dcMask); dcMask = NULL; } } else if (data->bFill || data->bGradientFill) { // ColorFill À϶§ hBrush = CreateBrushIndirect(&logbrush); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); } else { // Fill X hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } // if (data->bWinding) SetPolyFillMode(dcDst, WINDING); // ä¿ì±â ¸ðµå ¼±Åà // else SetPolyFillMode(dcDst, ALTERNATE); if (data->bWinding) gFillPath.SetFillMode(gdp::FillModeWinding); else gFillPath.SetFillMode(gdp::FillModeAlternate); // logbrush.lbColor = data->Color; // ÆæÀÇ color¸¦ À§Çؼ­... logbrush.lbColor = clBlack; // ÆæÀÇ color¸¦ À§Çؼ­... switch(data->PenStyle) { case 0: nPenStyle = int(PS_SOLID); break; case 1: nPenStyle = int(PS_DASH); break; case 2: nPenStyle = int(PS_DOT); break; case 3: nPenStyle = int(PS_DASHDOT); break; case 4: nPenStyle = int(PS_DASHDOTDOT); break; case 5: // 2005 Vector upgrade shin 0317 nPenStyle = P_USERSTYLE; int count = 0; double temp[6] = { 0, 0, 0, 0, 0, 0 }; CheckUserDashedLine(data, temp, count); dashValues = new float[count]; for (int i = 0; i < count; i++) { dashValues[i] = temp[i]; } // int count = data->DashValues[0]; // dashValues = new float[count]; // for (int i = 0; i < count; i++){ // dashValues[i] = data->DashValues[i+1]; // } ObjectPen.SetDashPattern(dashValues, count); break; // DashStyleCustom = 5 } if (osVERSION < 2) { // 3.1, 95, 98 hPen = CreatePen(psSolid, data->PenThick, data->Color); } else { if (data->bRound) { // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapRound); } } else { ObjectPen.SetStartCap(gdp::LineCapRound); ObjectPen.SetEndCap(gdp::LineCapRound); } ObjectPen.SetLineJoin(gdp::LineJoinRound); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapRound); } else { if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapFlat); } } else { ObjectPen.SetStartCap(gdp::LineCapFlat); ObjectPen.SetEndCap(gdp::LineCapFlat); } ObjectPen.SetLineJoin(gdp::LineJoinMiter); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapFlat); } } hOldPen = (HPEN)SelectObject(dcDst, hPen); } else { nTemp = data->Font.lfHeight; data->Font.lfHeight = data->Font.lfHeight; } // PAINT_VECTOR; SetROP2(dcDst, R2_COPYPEN); switch(data->Kind) { case V_LINE: graphics.DrawPolygon(&ObjectPen, pPoints, data->nCount + 1); break; case V_CURVE: if (data->bClosed && data->PenStyle == P_SOLID) graphics.DrawBeziers(&ObjectPen, pPoints, (data->nCount + 1) * 3 + 1); else graphics.DrawBeziers(&ObjectPen, pPoints, data->nCount * 3 + 1); if (data->bFill || data->bGradientFill) { gFillPath.AddBeziers(pPoints, data->nCount * 3 + 1); graphics.FillPath(&ObjectBrush, &gFillPath); graphics.DrawPath(&ObjectPen, &gFillPath); } break; case V_RECT: if (data->bRound) RoundRect(dcDst, FirstX, FirstY, SecondX, SecondY, pw, pw); else Rectangle(dcDst, FirstX, FirstY, SecondX, SecondY); break; case V_ELLIPSE: Ellipse(dcDst, FirstX, FirstY, SecondX, SecondY); break; case V_TEXT: Char * tempstr; tempstr = (Char*)malloc(data->nCount); for (int k = 0; k < data->nCount; k++) tempstr[k] = Char(data->TextString[k + 1]); SetTextAlign(dcDst, TA_BOTTOM); // SetTextColor(dcDst, data->Color); SetTextColor(dcDst, clBlack); SetBkMode(dcDst, TRANSPARENT); font = CreateFontIndirect(&data->Font); oldfont = (HFONT)SelectObject(dcDst, font); TextOut(dcDst, FirstX, FirstY, tempstr, data->nCount); SelectObject(dcDst, oldfont); DeleteObject(font); data->Font.lfHeight = nTemp; free(tempstr); break; case V_TEXTBOX: DrawMaskTextBox(dcDst, data, StartX, StartY, CenterX, CenterY, FontZoom, OffsetX, OffsetY); break; } SetROP2(dcDst, nDrawMode); SetPolyFillMode(dcDst, nFillMode); if (!(data->ParentTextBox || data->ChildList)) { // by linuxjun for CurvedVectorText // PAINT_VECTOR; PAINT_VECTOR_MASK; } if (data->ChildList) { // 090303 embakum motiveobjects // ±×¸®´Â °Í ¿©±â¼­ ±¸Çö. by embakum 20090217 ¸ðƼºê DrawMotiveObjectsMask(dcDst, data, mif, px, py, 2); } if (pPoints) delete[]pPoints; pPoints = NULL; if (dashValues) delete[]dashValues; dashValues = NULL; if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { SelectObject(dcDst, hOldBrush); SelectObject(dcDst, hOldPen); } if (hBrush) DeleteObject(hBrush); if (hPen) DeleteObject(hPen); hOldPen = NULL; hOldBrush = NULL; hPen = NULL; hBrush = NULL; // UndoSave(VU_DELETE, i, sw); // sw = false; } // */ pPoints = NULL; END_LOG; return true; fail: // if (dcDst) // MainImageForm->iMainImage->uBitmap->DeleteDC(dcDst); // delete data; // data = NULL; if (pPoints) delete[]pPoints; pPoints = NULL; END_LOG; return false; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::ConvertRectToBitmap(HDC dcDst, int nLeft, int nTop, int nRight, int nBottom) { BEGIN_LOG(""); // UnionBitmap¿¡¼­ ÀÏÁ¤ºÎºÐ¸¸Å­¾¿¸¸ º¤Å͸¦ À̹ÌÁöÈ­ ½Ã۱â À§ÇØ.. - by monkman (2006.06.02) TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) HPEN hOldPen = NULL, hPen = NULL; HBRUSH hOldBrush = NULL, hBrush = NULL; LOGBRUSH logbrush; int nDrawMode, nFillMode, nTemp, nPenStyle; HFONT font = NULL, oldfont = NULL; bool sw = false; int FirstX, FirstY, SecondX, SecondY; double CenterX, CenterY, FontZoom = 1.0; int OffsetX, OffsetY; // by linuxjun for CurvedVectorText int StartX, StartY; int pw; RECT rtVector, rtDst, tRect; gdp::Graphics graphics(dcDst); // using GDI+ 2005 Vector Upgrade Shin 0315 gdp::PointF *pPoints = NULL; // È­¸é¿¡ º¸¿©Áö´Â´ë·Î º¯È¯ or ¸ðµÎ antialiasing ÇØÁ¦ ÈÄ º¯È¯ // 256 color¿¡¼­ µµ½ÄÈ­ÀÛ¾÷ÇÏ´Â °æ¿ì ¶óÀο¡ antialiasingÀû¿ëµÇ¸é ¶óÀλöÀÌ ÀÏÁ¤ÇÏÁö ¾ÊÀ¸¹Ç·Î // antialiasing ÇØÁ¦ÀÇ °æ¿ì V_TEXTBOXÀÇ bAntialiasing ¸ðµÎ false·Î º¯È¯. for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; FirstX = data->First.x - nLeft; FirstY = data->First.y - nTop; SecondX = data->Second.x - nLeft; SecondY = data->Second.y - nTop; pw = data->PenThick / 2; rtVector = Rect(data->First.x, data->First.y, data->Second.x, data->Second.y); rtDst = Rect(nLeft, nTop, nRight, nBottom); // ¿µ¿ª¾È¿¡ µé¾î¿Â º¤Å͸¸ ±×¸°´Ù - by monkman (2006.06.02) sw = false; //IntersectRect returns true if the two rectangles have a nonempty intersection. //If R1 and R2 do not overlap, IntersectRect returns false. //Rect ¿µ¿ªÀÌ °ãÄ¡´Â ºÎºÐÀÌ ÀÖ´ÂÁö ¸ÕÀú °Ë»ç¸¦ ÇÑ´Ù. if (IntersectRect(&tRect, &rtVector, &rtDst)) sw = true; //Rect ¿µ¿ª °ãÄ¡´Â ºÎºÐÀÌ ¾ø°Å³ª Rect°¡ ¾Æ´Ñ Á÷¼±ÀÏ °æ¿ì ¾Æ·¡ ¹æ½ÄÀ¸·Î ó¸®ÇÑ´Ù. //objectÀÇ rectÀÇ Áß½ÉÀ» ¿øÀÇ Áß½ÉÀ¸·Î ÇÏ¿© ¿øÀ» ±×¸®°í union bitmapÀÇ rect Áß½ÉÀ¸·Î ÇÏ´Â //¿ø°ú ºñ±³ÇÏ¿© µÎ ¿øÀÇ Á߽ɰúÀÇ °Å¸®°¡ µÎ ¿øÀÇ ¹ÝÁö¸§ÀÇ ÇÕº¸´Ù ÀÛÀ¸¸é °ãÄ£´Ù´Â °ÍÀ» ÀÌ¿ë if (!sw) { //¿øÁ¡±âÁØ x1,y1ÀÇ Áß½É, r1 ¹ÝÁö¸§ double o_x1 = rtDst.left + (rtDst.right - rtDst.left) / 2.0; double o_y1 = rtDst.top + (rtDst.bottom - rtDst.top) / 2.0; //¿øÁ¡±âÁØ x2,y2ÀÇ Áß½É, r2 ¹ÝÁö¸§ double o_x2 = rtVector.left + (rtVector.right - rtVector.left) / 2.0; double o_y2 = rtVector.top + (rtVector.bottom - rtVector.top) / 2.0; double r1, r2; r1 = sqrt((o_x1-rtDst.left)*(o_x1-rtDst.left) + (o_y1-rtDst.top)*(o_y1-rtDst.top)); r2 = sqrt((o_x2-rtVector.left)*(o_x2-rtVector.left) + (o_y2-rtVector.top)*(o_y2-rtVector.top)); if (sqrt((o_x2-o_x1)*(o_x2-o_x1)+(o_y2-o_y1)*(o_y2-o_y1)) <= (r1+r2)) sw = true; } if (!sw) continue; float *dashValues = NULL; gdp::Color penColor(GetRValue(data->Color), GetGValue(data->Color), GetBValue(data->Color)); gdp::Color FillColor(GetRValue(data->Brush), GetGValue(data->Brush), GetBValue(data->Brush)); gdp::Pen ObjectPen(penColor, data->PenThick); gdp::SolidBrush ObjectBrush(FillColor); gdp::GraphicsPath gFillPath; if (!(NVector->bCancelAntialiasing) && data->bAntialiasing) { graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); // antialiasing } else { graphics.SetSmoothingMode(gdp::SmoothingModeNone); } if (data->Kind == V_TEXTBOX) { pPoints = new gdp::PointF[5]; } else { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new gdp::PointF[(data->nCount + 1) * 3 + 1]; } else { pPoints = new gdp::PointF[data->nCount * 3 + 1]; } } if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int i = 0; i < data->nCount * 3 + 1; i++) { pPoints[i].X = data->pList[i].x - nLeft; pPoints[i].Y = data->pList[i].y - nTop; } } if (data->Kind == V_TEXTBOX) { StartX = data->StartPoint.x - nLeft; StartY = data->StartPoint.y - nTop; CenterX = data->CenterPoint.x - nLeft; CenterY = data->CenterPoint.y - nTop; OffsetX = nLeft; OffsetY = nTop; // by linuxjun for CurvedVectorText for (int i = 0; i < 5; i++) { pPoints[i].X = data->pList[i].x - nLeft; pPoints[i].Y = data->pList[i].y - nTop; } } //////// Closed Path last point and for nicer close if (data->bClosed && data->PenStyle == P_SOLID) { // 2005 Vector Upgrade Shin 0315 pPoints[data->nCount * 3] = pPoints[0]; pPoints[data->nCount * 3 + 1] = pPoints[1]; pPoints[data->nCount * 3 + 2] = pPoints[2]; pPoints[data->nCount * 3 + 3] = pPoints[3]; } nDrawMode = GetROP2(dcDst); nFillMode = GetPolyFillMode(dcDst); if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { // Text´Â Pen°ú Brush°¡ ÇÊ¿ä ¾ø´Ù logbrush.lbStyle = BS_SOLID; logbrush.lbColor = data->Brush; logbrush.lbHatch = 0; if (data->bPatternFill) { // PatternFill À϶§ int bltwidth, bltheight; HDC dcPattern, dcMask; bltwidth = data->TBitmap->Width; bltheight = data->TBitmap->Height; // PatternFillµÈ BitmapÀÇ »çÀÌÁî°¡ 0ÀÌ µÇ¾î¹ö¸®¸é fail·Î ºüÁö°í FullViewDraw¿¡¼­ Access°¡ ¹ß»ýÇϹǷΠ// BitmapÀÇ »çÀÌÁ °Ë»çÇÑ´Ù - by monkman (2005.02.19) if (bltwidth > 0 && bltheight > 0) { if ((dcPattern = data->TBitmap->CreateDC()) == NULL) goto fail; if ((dcMask = data->MaskBitmap->CreateDC()) == NULL) goto fail; StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcMask, 0, 0, data->MaskBitmap->Width, data->MaskBitmap->Height, SRCAND); StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcPattern, 0, 0, data->TBitmap->Width, data->TBitmap->Height, SRCPAINT); data->TBitmap->DeleteDC(dcPattern); dcPattern = NULL; data->MaskBitmap->DeleteDC(dcMask); dcMask = NULL; } } else if (data->bFill) { // ColorFill À϶§ hBrush = CreateBrushIndirect(&logbrush); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); } else { // Fill X hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } if (data->bWinding) gFillPath.SetFillMode(gdp::FillModeWinding); else gFillPath.SetFillMode(gdp::FillModeAlternate); logbrush.lbColor = data->Color; // ÆæÀÇ color¸¦ À§Çؼ­... switch(data->PenStyle) { case 0: nPenStyle = int(PS_SOLID); break; case 1: nPenStyle = int(PS_DASH); break; case 2: nPenStyle = int(PS_DOT); break; case 3: nPenStyle = int(PS_DASHDOT); break; case 4: nPenStyle = int(PS_DASHDOTDOT); break; case 5: // 2005 Vector upgrade shin 0303 nPenStyle = P_USERSTYLE; int count = 0; double temp[6] = { 0, 0, 0, 0, 0, 0 }; CheckUserDashedLine(data, temp, count); dashValues = new float[count]; for (int i = 0; i < count; i++) { dashValues[i] = temp[i]; } ObjectPen.SetDashPattern(dashValues, count); break; // DashStyleCustom = 5 } if (osVERSION < 2) { // 3.1, 95, 98 hPen = CreatePen(psSolid, data->PenThick, data->Color); } else { if (data->bRound) { // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapRound); } } //À̽´ ÃßÀû¹øÈ£ - 191001 [MeasurementArrowCap] else if (data->CapStyle[0] == 2 && data->CapStyle[1] == 2){ double CapWidth = data->ArrowCap->LineCapWidth * data->ArrowCap->LineCapWidthScale; // Cap Æø ºñÀ² double CapHeight = data->ArrowCap->LineCapHeight * data->ArrowCap->LineCapWidthScale; double LineCapWidth = 0.5 * data->ArrowCap->LineCapLine; double LineCapWidthPositive = LineCapWidth; double LineCapWidthNegative = 0.5; double LineMiddlePointWidth = 1; if(LineCapWidthPositive < 0.5){ LineCapWidthNegative -= (0.5 - LineCapWidthPositive); LineCapWidthPositive = 0.5; } gdp::PointF ArrowShape[8] = {gdp::PointF(-(CapWidth),(LineCapWidthPositive)), gdp::PointF(-(CapWidth),-(LineCapWidthNegative)), gdp::PointF(-LineMiddlePointWidth, -(LineCapWidthNegative)), gdp::PointF(-(CapWidth), -(CapHeight)), gdp::PointF((CapWidth), -(CapHeight)), gdp::PointF(LineMiddlePointWidth, -(LineCapWidthNegative)), gdp::PointF((CapWidth), -(LineCapWidthNegative)), gdp::PointF((CapWidth),(LineCapWidthPositive))}; gdp::GraphicsPath capPath; capPath.AddPolygon(ArrowShape,8); gdp::CustomLineCap arrowLineCap(&capPath,NULL); ObjectPen.SetCustomStartCap(&arrowLineCap); if (data->ArrowCap->bShowArrowBoth){ ObjectPen.SetCustomEndCap(&arrowLineCap); } } else { ObjectPen.SetStartCap(gdp::LineCapRound); ObjectPen.SetEndCap(gdp::LineCapRound); } ObjectPen.SetLineJoin(gdp::LineJoinRound); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapRound); } else { if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapFlat); } } else { ObjectPen.SetStartCap(gdp::LineCapFlat); ObjectPen.SetEndCap(gdp::LineCapFlat); } ObjectPen.SetLineJoin(gdp::LineJoinMiter); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapFlat); } } hOldPen = (HPEN)SelectObject(dcDst, hPen); } else { nTemp = data->Font.lfHeight; data->Font.lfHeight = data->Font.lfHeight; } if (!(data->ParentTextBox || data->ChildList)) { // by linuxjun for CurvedVectorText PAINT_VECTOR; } if (data->ChildList) { // 090303 embakum motiveobjects DrawMotiveObjects(dcDst, data, MainImageForm, nLeft, nTop, 3, nRight, nBottom); } if (pPoints) delete[]pPoints; pPoints = NULL; if (dashValues) delete[]dashValues; dashValues = NULL; if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { SelectObject(dcDst, hOldBrush); SelectObject(dcDst, hOldPen); } if (hBrush) DeleteObject(hBrush); if (hPen) DeleteObject(hPen); hOldPen = NULL; hOldBrush = NULL; hPen = NULL; hBrush = NULL; } pPoints = NULL; END_LOG; return; fail: if (data) delete data; data = NULL; if (pPoints) delete[]pPoints; pPoints = NULL; END_LOG; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::FullViewBitmapDraw(int px, int py, int vw, int vh) { // ¼Óµµ °³¼± - VectorÀÇ FullView¸¦ FullViewBitmap¿¡ ±×·ÁÁØ´Ù - by monkman (2005.07.20) RGBQUAD rgb[256]; int FullViewWidth = 0, FullViewHeight = 0, BitsPerPixel = 0; HDC dcFullView = NULL, dcFullViewMask = NULL; COLORREF BgColor; COLORREF MaskColor; if (!MainImageForm) return; FullViewWidth = MainImageForm->iMainImage->bmFullView->Width; FullViewHeight = MainImageForm->iMainImage->bmFullView->Height; BitsPerPixel = MainImageForm->iMainImage->uBitmap->BitsPerPixel; // MainImageForm->FormDestroy()¿¡¼­ MainImageFormÀÌ ¾ø´Â »óÅ¿¡¼­ Palette¸¦ ¼±ÅÃÇϹǷΠ// AccessViolationÀÌ ¹ß»ýÇÏ´Â °ÍÀ» ¸·±âÀ§ÇØ try-catch¹®À» »ç¿ë - by monkman (2005.08.01) try { // BgColor = PaletteForm->DIB256Palette->GetBGCOLORREF(BitsPerPixel); // ÀÌ ºÎºÐ¿¡¼­ AccessVilolationÀÌ ¹ß»ý if (FullViewBitmap) { delete FullViewBitmap; FullViewBitmap = NULL; } if (FullViewBitmapMask) { delete FullViewBitmapMask; FullViewBitmapMask = NULL; } FullViewBitmap = new TTexpiaBitmap; FullViewBitmapMask = new TTexpiaBitmap; // 256 Color¿Í FullColor ¸¶½ºÅ© ºñÆ®¸Ê ¸¸µé±â - thanks to celberus switch(BitsPerPixel) { case 8: MaskColor = PALETTEINDEX(0xFF); MainImageForm->iMainImage->uBitmap->GetColors(0, 256, rgb); FullViewBitmap->Create(FullViewWidth, FullViewHeight, BitsPerPixel, rgb); FullViewBitmapMask->Create(FullViewWidth, FullViewHeight, BitsPerPixel, rgb); break; case 24: MaskColor = clWhite; FullViewBitmap->Create(FullViewWidth, FullViewHeight, BitsPerPixel); FullViewBitmapMask->Create(FullViewWidth, FullViewHeight, 1); break; } if (px < 0 && py < 0 && vw < 0 && vh < 0) { FullViewBitmap->FillRect(Rect(0, 0, FullViewBitmap->Width, FullViewBitmap->Height), 0x000000); // BitsPerPixel¿¡ ¸¶½ºÅ©ÀÇ ÃʱâÈ­ ¹æ½ÄÀÌ ´Ù¸£´Ù FullViewBitmapMask->FillRect(Rect(0, 0, FullViewBitmapMask->Width, FullViewBitmapMask->Height), MaskColor); } else { FullViewBitmap->FillRect(Rect(px, py, vw, vh), 0x000000); // BitsPerPixel¿¡ ¸¶½ºÅ©ÀÇ ÃʱâÈ­ ¹æ½ÄÀÌ ´Ù¸£´Ù FullViewBitmapMask->FillRect(Rect(px, py, vw, vh), MaskColor); } if ((dcFullView = FullViewBitmap->CreateDC()) == NULL) goto fail; if ((dcFullViewMask = FullViewBitmapMask->CreateDC()) == NULL) goto fail; // VectorÀÇ FullView¸¦ ±×¸°´Ù if (px < 0 && py < 0 && vw < 0 && vh < 0) { FullViewDraw(dcFullView, 0, 0, FullViewWidth, FullViewHeight); FullViewDrawMask(dcFullViewMask, 0, 0, FullViewWidth, FullViewHeight); } else { FullViewDraw(dcFullView, px, py, vw, vh); FullViewDrawMask(dcFullViewMask, 0, 0, FullViewWidth, FullViewHeight); } } catch(...) { // FormDestroy() ½Ã AccessViolationÀ» ¸·±âÀ§ÇÑ try-catch¹® - by monkman (2005.08.01) } if (dcFullView) FullViewBitmap->DeleteDC(dcFullView); dcFullView = NULL; if (dcFullViewMask) FullViewBitmapMask->DeleteDC(dcFullViewMask); dcFullViewMask = NULL; return; fail: if (dcFullView) FullViewBitmap->DeleteDC(dcFullView); dcFullView = NULL; if (dcFullViewMask) FullViewBitmapMask->DeleteDC(dcFullViewMask); dcFullViewMask = NULL; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::FullViewBitmapToFullView(HDC dcDst, int px, int py, int vw, int vh) { // ¼Óµµ °³¼± - VectorÀÇ FullViewBitmap¿¡ ±×·ÁÁ®ÀÖ´Â ³»¿ëÀ» FullView¿¡ ±×·ÁÁØ´Ù - by monkman (2005.07.20) // ¼±¸íÇÏ°Ô ³ª¿À°Ô Çϱâ À§ÇØ ¸ðµå º¯°æ int FullViewWidth = 0, FullViewHeight = 0, BitsPerPixel = 0; HDC dcFullView = NULL, dcFullViewMask = NULL, dcTemp = NULL; if (!MainImageForm) return; FullViewWidth = MainImageForm->iMainImage->bmFullView->Width; FullViewHeight = MainImageForm->iMainImage->bmFullView->Height; BitsPerPixel = MainImageForm->iMainImage->uBitmap->BitsPerPixel; if (FullViewBitmap && FullViewBitmapMask) { if (FullViewBitmap->Width != FullViewWidth || FullViewBitmap->Height != FullViewHeight || FullViewBitmapMask->Width != FullViewWidth || FullViewBitmapMask->Height != FullViewHeight) { FullViewBitmapDraw(px, py, vw, vh); } } else if (FullViewBitmap == NULL || FullViewBitmapMask == NULL) { FullViewBitmapDraw(px, py, vw, vh); } if ((dcFullView = FullViewBitmap->CreateDC()) == NULL) goto fail; if ((dcFullViewMask = FullViewBitmapMask->CreateDC()) == NULL) goto fail; if (osVERSION < 2) { // 3.1, 95, 98 SetStretchBltMode(dcDst, COLORONCOLOR); } else { // ¼±¸íÇϱ⠺¸¿©ÁÖ±â À§ÇØ ¸ðµå¸¦ ¹Ù²Û´Ù SetStretchBltMode(dcDst, HALFTONE); } if (px < 0 && py < 0 && vw < 0 && vh < 0) { BitBlt(dcDst, 0, 0, FullViewWidth, FullViewHeight, dcFullViewMask, 0, 0, SRCAND); BitBlt(dcDst, 0, 0, FullViewWidth, FullViewHeight, dcFullView, 0, 0, SRCPAINT); } else { StretchBlt(dcDst, px, py, vw, vh, dcFullViewMask, px, py, vw, vh, SRCAND); StretchBlt(dcDst, px, py, vw, vh, dcFullView, px, py, vw, vh, SRCPAINT); } if (dcFullView) FullViewBitmap->DeleteDC(dcFullView); dcFullView = NULL; if (dcFullViewMask) FullViewBitmapMask->DeleteDC(dcFullViewMask); dcFullViewMask = NULL; return; fail: if (dcFullView) FullViewBitmap->DeleteDC(dcFullView); dcFullView = NULL; if (dcFullViewMask) FullViewBitmapMask->DeleteDC(dcFullViewMask); dcFullViewMask = NULL; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::ChangeRGBColors(RGBQUAD *rgb) { FullViewBitmap->PutColors(0, 256, rgb); FullViewBitmapMask->PutColors(0, 256, rgb); } // --------------------------------------------------------------------------- void __fastcall TVecDraw::ColorChange(int index, RGBQUAD *rgb) { FullViewBitmap->PutColors(index, 1, &rgb[index]); FullViewBitmapMask->PutColors(index, 1, &rgb[index]); } // --------------------------------------------------------------------------- void __fastcall TVecDraw::DrawVCurve(POINT pFst, POINT pScd, POINT pCrt) { if (!(NVector->bFirst)) DrawCurrentCurve(pFst, pScd, pBak); DrawCurrentCurve(pFst, pScd, pCrt); pBak = pCrt; NVector->bFirst = false; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::DrawCurrentCurve(POINT pFst, POINT pScd, POINT pCrt) { TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) HDC formDC = MainImageForm->iMainImage->Canvas->Handle; HPEN hOldPen = NULL, hPen = NULL; // HBRUSH hOldBrush=NULL, hBrush=NULL; int nDrawMode; RGBQUAD rgb; POINT pTan1, pTan2; int ZoomIn = MainImageForm->iMainImage->ZoomIn; int ZoomOut = MainImageForm->iMainImage->ZoomOut; int PositionX = MainImageForm->sbHorz->Position; int PositionY = MainImageForm->sbVert->Position; if (!(NVector->bFstLine)) { data = (TVecData*)DataList->Items[DataList->Count - 1]; if (data->Color != PenManagerForm->PenShape->Pen->Color || data->bRound == PenManagerForm->Pen->Shape || data->PenThick != PenManagerForm->Pen->Thick) NVector->bFstLine = true; } if (NVector->bFstLine) pTan1 = pFst; else { pTan1.x = data->pList[data->nCount * 3].x * 2 - data->pList [data->nCount * 3 - 1].x; pTan1.y = data->pList[data->nCount * 3].y * 2 - data->pList [data->nCount * 3 - 1].y; } pTan2.x = pScd.x * 2 - pCrt.x; pTan2.y = pScd.y * 2 - pCrt.y; pFst.x = (pFst.x - PositionX) * ZoomIn / ZoomOut; pFst.y = (pFst.y - PositionY) * ZoomIn / ZoomOut; pTan1.x = (pTan1.x - PositionX) * ZoomIn / ZoomOut; pTan1.y = (pTan1.y - PositionY) * ZoomIn / ZoomOut; pTan2.x = (pTan2.x - PositionX) * ZoomIn / ZoomOut; pTan2.y = (pTan2.y - PositionY) * ZoomIn / ZoomOut; pCrt.x = (pCrt.x - PositionX) * ZoomIn / ZoomOut; pCrt.y = (pCrt.y - PositionY) * ZoomIn / ZoomOut; pScd.x = (pScd.x - PositionX) * ZoomIn / ZoomOut; pScd.y = (pScd.y - PositionY) * ZoomIn / ZoomOut; POINT pts[] = { { pFst.x, pFst.y }, { pTan1.x, pTan1.y }, { pTan2.x, pTan2.y }, { pScd.x, pScd.y } }; hPen = CreatePen(psSolid, 1, clBlack); hOldPen = (HPEN)SelectObject(formDC, hPen); nDrawMode = GetROP2(formDC); SetROP2(formDC, R2_NOT); PolyBezier(formDC, pts, 4); MoveToEx(formDC, pFst.x, pFst.y, NULL); LineTo(formDC, pTan1.x, pTan1.y); MoveToEx(formDC, pCrt.x, pCrt.y, NULL); LineTo(formDC, pTan2.x, pTan2.y); if (!(NVector->bFstLine)) Rectangle(formDC, pFst.x - 2, pFst.y - 2, pFst.x + 2, pFst.y + 2); Rectangle(formDC, pTan1.x - 2, pTan1.y - 2, pTan1.x + 2, pTan1.y + 2); Rectangle(formDC, pTan2.x - 2, pTan2.y - 2, pTan2.x + 2, pTan2.y + 2); Rectangle(formDC, pCrt.x - 2, pCrt.y - 2, pCrt.x + 2, pCrt.y + 2); Rectangle(formDC, pScd.x - 2, pScd.y - 2, pScd.x + 2, pScd.y + 2); SetROP2(formDC, nDrawMode); SelectObject(formDC, hOldPen); DeleteObject(hPen); hPen = NULL; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::DrawCurrentObject(HDC dcDst, int px, int py) { TList *DataList = NULL; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) HPEN hOldPen = NULL, hPen = NULL; HBRUSH hOldBrush = NULL; int nDrawMode; LOGBRUSH logbrush; int ZoomIn = MainImageForm->iMainImage->ZoomIn; int ZoomOut = MainImageForm->iMainImage->ZoomOut; int PositionX = MainImageForm->sbHorz->Position; int PositionY = MainImageForm->sbVert->Position; // ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Ê±â À§ÇØ ¾Æ·¡¿Í °°ÀÌ ¼öÁ¤ - by monkman (2011.04.20) DataList = NVector->DataList; if (0 < DataList->Count) data = (TVecData*)DataList->Last(); else if ((DataList->Count == 0) && (NVector->bFstLine == true) && (NVector->bExtend == false) && NVector->step > 0){ // óÀ½ ±×·ÁÁö´Â vector object } else return;//data = new TVecData(MainImageForm->Number); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) int ReflectionIndex = -1; if (NVector->bVectorReflectionMode && ((NVector->ReflectionVH == 1 && NVector->ReflectionVIndex >= 0) || (NVector->ReflectionVH == 2 && NVector->ReflectionHIndex >= 0))) { // ¼öÁ÷ ±âÁؼ± if (NVector->ReflectionVH == 1) { ReflectionIndex = (NVector->ReflectionVIndex - PositionX) * ZoomIn / ZoomOut - px; // ¹ÝÀü °Å¿ï ±â´É - 'J'۸¦ ´©¸£°í ¼± ±×¸®±â½Ã ¹ÝÀü ±âÁؼ± ³» 5px ¹üÀ§¿¡ µé¾î¿À¸é ´Þ¶óºÙµµ·Ï ÇÑ´Ù - by monkman (2009.11.27) if ((VectorForm->V_Item == M_D_LINE || VectorForm->V_Item == M_D_CURVE) && bJKeyState == true) { if (NVector->bFstLine && (NVector->Lsx - 5 <= NVector->ReflectionVIndex && NVector->ReflectionVIndex <= NVector->Lsx + 5)) { NVector->Lsx = NVector->ReflectionVIndex; } else if (NVector->Cux - 5 <= NVector->ReflectionVIndex && NVector->ReflectionVIndex <= NVector->Cux + 5) { NVector->Cux = NVector->ReflectionVIndex; } } } // ¼öÆò ±âÁؼ± if (NVector->ReflectionVH == 2) { ReflectionIndex = (NVector->ReflectionHIndex - PositionY) * ZoomIn / ZoomOut - py; // ¹ÝÀü °Å¿ï ±â´É - 'J'۸¦ ´©¸£°í ¼± ±×¸®±â½Ã ¹ÝÀü ±âÁؼ± ³» 5px ¹üÀ§¿¡ µé¾î¿À¸é ´Þ¶óºÙµµ·Ï ÇÑ´Ù - by monkman (2009.11.27) if ((VectorForm->V_Item == M_D_LINE || VectorForm->V_Item == M_D_CURVE) && bJKeyState == true) { if (NVector->bFstLine && (NVector->Lsy - 5 <= NVector->ReflectionHIndex && NVector->ReflectionHIndex <= NVector->Lsy + 5)) { NVector->Lsy = NVector->ReflectionHIndex; } else if (NVector->Cuy - 5 <= NVector->ReflectionHIndex && NVector->ReflectionHIndex <= NVector->Cuy + 5) { NVector->Cuy = NVector->ReflectionHIndex; } } } } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- int Lex = ((NVector->Lex) - PositionX) * ZoomIn / ZoomOut - px; int Ley = ((NVector->Ley) - PositionY) * ZoomIn / ZoomOut - py; int Lsx = ((NVector->Lsx) - PositionX) * ZoomIn / ZoomOut - px; int Lsy = ((NVector->Lsy) - PositionY) * ZoomIn / ZoomOut - py; int Cux = ((NVector->Cux) - PositionX) * ZoomIn / ZoomOut - px; int Cuy = ((NVector->Cuy) - PositionY) * ZoomIn / ZoomOut - py; // -----------------------------> 2005 Vector Upgrade Shin 0315 gdp::Graphics graphics(dcDst); graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); // antialiasing gdp::Color penColor(GetRValue(PenManagerForm->PenShape->Pen->Color), GetGValue(PenManagerForm->PenShape->Pen->Color), GetBValue(PenManagerForm->PenShape->Pen->Color)); gdp::Color pathColor(GetRValue(PathColor), GetGValue(PathColor), GetBValue(PathColor)); gdp::Pen ObjectPen(penColor, VectorForm->DrawingThick * ZoomIn / ZoomOut); gdp::Pen pathPen(pathColor, 1); gdp::Rect rect; int penstyle = VectorForm->PenStyle; // 0317 shin double thick = VectorForm->DrawingThick; float *dashValues = NULL; int count = 0; if (penstyle == P_USERSTYLE) { if (dashcount == 2) { count = 2; dashValues = new float[count]; dashValues[0] = dset[0] / thick; dashValues[1] = dset[1] / thick; } else if (dashcount == 4) { if ((dset[0] > 0) && (dset[1] > 0) && (dset[2] > 0) && (dset[3] > 0)) { count = 4; dashValues = new float[count]; dashValues[0] = dset[0] / thick; dashValues[1] = dset[1] / thick; dashValues[2] = dset[2] / thick; dashValues[3] = dset[3] / thick; } else { count = 2; dashValues = new float[count]; dashValues[0] = dset[0] / thick + dset[2] / thick; dashValues[1] = dset[1] / thick + dset[3] / thick; } } else if (dashcount == 6) { if ((dset[0] > 0) && (dset[1] > 0) && (dset[2] > 0) && (dset[3] > 0) && (dset[4] > 0) && (dset[5] > 0)) { count = 6; dashValues = new float[count]; dashValues[0] = dset[0] / thick; dashValues[1] = dset[1] / thick; dashValues[2] = dset[2] / thick; dashValues[3] = dset[3] / thick; dashValues[4] = dset[4] / thick; dashValues[5] = dset[5] / thick; } else { if ((dset[0] > 0) && (dset[1] > 0)) { if (((dset[2] > 0) && (dset[3] > 0)) && ((dset[4] <= 0) || (dset[5] <= 0))) { count = 4; dashValues = new float[count]; dashValues[0] = dset[0] / thick; dashValues[1] = dset[1] / thick; if (dset[4] <= 0) { dashValues[2] = dset[2] / thick; dashValues[3] = dset[3] / thick + dset[5] / thick; } else { dashValues[2] = dset[2] / thick; dashValues[3] = dset[3] / thick; dashValues[0] += dset[4] / thick; } } else if (((dset[2] <= 0) || (dset[3] <= 0)) && ((dset[4] <= 0) || (dset[5] <= 0))) { count = 2; dashValues = new float[count]; dashValues[0] = dset[0] / thick + dset[3] / thick + dset[4] / thick; dashValues[1] = dset[1] / thick + dset[3] / thick + dset[5] / thick; } else { if (dset[2] <= 0) { count = 4; dashValues = new float[count]; dashValues[0] = dset[0] / thick; dashValues[1] = dset[1] / thick + dset[3] / thick; dashValues[2] = dset[4] / thick; dashValues[3] = dset[5] / thick; } else { count = 4; dashValues = new float[count]; dashValues[0] = dset[0] / thick; dashValues[1] = dset[1] / thick; dashValues[2] = dset[2] / thick + dset[4] / thick; dashValues[3] = dset[5] / thick; } } } else { if ((dset[2] > 0) && (dset[3] > 0) && (dset[4] > 0) && (dset[5] > 0)) { count = 4; dashValues = new float[count]; if (dset[0] <= 0) { dashValues[0] = dset[2] / thick; dashValues[1] = dset[3] / thick; dashValues[2] = dset[4] / thick; dashValues[3] = dset[5] / thick + dset[1] / thick; } else { dashValues[0] = dset[0] / thick + dset[2] / thick; dashValues[1] = dset[3] / thick; dashValues[2] = dset[4] / thick; dashValues[3] = dset[5] / thick; } } else { count = 2; dashValues = new float[count]; dashValues[0] = dset[0] / thick + dset[2] / thick + dset[4] / thick; dashValues[1] = dset[1] / thick + dset[3] / thick + dset[5] / thick; } } } } ObjectPen.SetDashPattern(dashValues, count); } /* if (penstyle == P_USERSTYLE){ if (dashcount == 2){ dashValues = new float[dashcount]; dashValues[0] = dset[0]/thick; dashValues[1] = dset[1]/thick; } else if (dashcount == 4){ dashValues = new float[dashcount]; dashValues[0] = dset[0]/thick; dashValues[1] = dset[1]/thick; dashValues[2] = dset[2]/thick; dashValues[3] = dset[3]/thick; } else if (dashcount == 6){ dashValues = new float[dashcount]; dashValues[0] = dset[0]/thick; dashValues[1] = dset[1]/thick; dashValues[2] = dset[2]/thick; dashValues[3] = dset[3]/thick; dashValues[4] = dset[4]/thick; dashValues[5] = dset[5]/thick; } ObjectPen.SetDashPattern(dashValues, dashcount); } */ // ------------------------------------< nDrawMode = GetROP2(dcDst); logbrush.lbStyle = BS_SOLID; logbrush.lbColor = PenManagerForm->PenShape->Pen->Color; logbrush.lbHatch = 0; if (osVERSION < 2) { // 3.1, 95, 98 hPen = CreatePen(psSolid, PenManagerForm->Pen->Thick * ZoomIn / ZoomOut, PenManagerForm->PenShape->Pen->Color); } else { if (!PenManagerForm->Pen->Shape) { if ((VectorForm->CapStyle[0] == 1) && (NVector->bFstLine)){ // arrow gdp::AdjustableArrowCap arrowCap(VectorForm->LineCapHeight, VectorForm->LineCapWidth, VectorForm->bFillLineCap); arrowCap.SetWidthScale(VectorForm->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (VectorForm->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(VectorForm->LineCapHeight, VectorForm->LineCapWidth, VectorForm->bFillLineCap); arrowCap2.SetWidthScale(VectorForm->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapRound); } } else { ObjectPen.SetStartCap(gdp::LineCapRound); ObjectPen.SetEndCap(gdp::LineCapRound); } ObjectPen.SetLineJoin(gdp::LineJoinRound); ObjectPen.SetDashStyle((gdp::DashStyle)penstyle); ObjectPen.SetDashCap(gdp::DashCapRound); } else { if ((VectorForm->CapStyle[0] == 1) && (NVector->bFstLine)){ // arrow gdp::AdjustableArrowCap arrowCap(VectorForm->LineCapHeight, VectorForm->LineCapWidth, VectorForm->bFillLineCap); arrowCap.SetWidthScale(VectorForm->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (VectorForm->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(VectorForm->LineCapHeight, VectorForm->LineCapWidth, VectorForm->bFillLineCap); arrowCap2.SetWidthScale(VectorForm->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapFlat); } } else { ObjectPen.SetStartCap(gdp::LineCapFlat); ObjectPen.SetEndCap(gdp::LineCapFlat); } ObjectPen.SetLineJoin(gdp::LineJoinMiter); ObjectPen.SetDashStyle((gdp::DashStyle)penstyle); ObjectPen.SetDashCap(gdp::DashCapFlat); } } hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); hOldPen = (HPEN)SelectObject(dcDst, hPen); SetROP2(dcDst, R2_COPYPEN); switch(VectorForm->V_Item) { case M_D_LINE: // Line if (NVector->step == 1) { if (bZKey) { // ¼öÁ÷/¼öÆò ±×¸®±â if (abs(Cux - Lsx) > abs(Cuy - Lsy)) Cuy = Lsy; else Cux = Lsx; } // MoveToEx(dcDst, Lsx, Lsy, NULL); // LineTo(dcDst, Cux, Cuy); graphics.DrawLine(&ObjectPen, Lsx, Lsy, Cux, Cuy); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (NVector->bVectorReflectionMode) { if (NVector->ReflectionVH == 1) { // ¼öÁ÷ ±âÁؼ± graphics.DrawLine(&ObjectPen, ReflectionIndex * 2 - Lsx, Lsy, ReflectionIndex * 2 - Cux, Cuy); } if (NVector->ReflectionVH == 2) { // ¼öÆò ±âÁؼ± graphics.DrawLine(&ObjectPen, Lsx, ReflectionIndex * 2 - Lsy, Cux, ReflectionIndex * 2 - Cuy); } } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ============= RECT tr = Rect((NVector->Cux) - 3, (NVector->Cuy) - 3, (NVector->Cux) + 3, (NVector->Cuy) + 3); if (!(NVector->bFstLine)) { if (PtInRect(&tr, data->pList[0].P()) && bAltState && !CheckFirstLine() ) { MainImageForm->iMainImage->Cursor = crHandPoint; NVector->bClosedState = true; } else { // 2009 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É - 'J'۸¦ ´­·¶À» ¶§ Ä¿¼­¸¦ º¯°æÇÑ´Ù - by monkman (2009.11.27) if (bJKeyState == false) MainImageForm->iMainImage->Cursor = crDefault; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- NVector->bClosedState = false; } } else if (NVector->bExtend && data->bClosed == false && bAltState) { // º¤ÅÍÈ®ÀåÀÇ °æ¿ì // ±âÁ¸ º¤ÅÍ µ¥ÀÌÅÍ¿¡ ¼± Çϳª¸¸ Ãß°¡ ¿¬ÀåÇÏ¿© ¸¶°¨(Close)½Ãų °æ¿ì // ÇöÀç ÀÔ·ÂµÈ ¶óÀÎÀÌ ±âÁ¸ º¤ÅÍ µ¥ÀÌÅÍÀÇ ½ÃÀÛÁ¡, ³¡Á¡¿¡ ÀÖ´ÂÁö üũ - by monkman (2009.11.19) RECT sr = Rect(NVector->Lsx - 5, NVector->Lsy - 5, NVector->Lsx + 5, NVector->Lsy + 5); if ((PtInRect(&tr, data->pList[0].P()) && PtInRect(&sr, data->pList[data->nCount * 3].P())) || ((PtInRect(&tr, data->pList[data->nCount * 3].P()) && PtInRect(&sr, data->pList[0].P())))) { MainImageForm->iMainImage->Cursor = crHandPoint; NVector->bClosedState = true; } } // ============= } break; case M_D_CURVE: // Curve if (NVector->step == 1) { if (bZKey) { // ¼öÁ÷/¼öÆò ±×¸®±â if (abs(Cux - Lsx) > abs(Cuy - Lsy)) Cuy = Lsy; else Cux = Lsx; } // MoveToEx(dcDst, Lsx, Lsy, NULL); // LineTo(dcDst, Cux, Cuy); graphics.DrawLine(&ObjectPen, Lsx, Lsy, Cux, Cuy); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (NVector->bVectorReflectionMode) { if (NVector->ReflectionVH == 1) { // ¼öÁ÷ ±âÁؼ± graphics.DrawLine(&ObjectPen, ReflectionIndex * 2 - Lsx, Lsy, ReflectionIndex * 2 - Cux, Cuy); } if (NVector->ReflectionVH == 2) { // ¼öÆò ±âÁؼ± graphics.DrawLine(&ObjectPen, Lsx, ReflectionIndex * 2 - Lsy, Cux, ReflectionIndex * 2 - Cuy); } } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ============= RECT tr = Rect((NVector->Cux) - 3, (NVector->Cuy) - 3, (NVector->Cux) + 3, (NVector->Cuy) + 3); if (!(NVector->bFstLine)) { if (PtInRect(&tr, data->pList[0].P()) && bAltState) { MainImageForm->iMainImage->Cursor = crHandPoint; NVector->bClosedState = true; } else { // 2009 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É - 'J'۸¦ ´­·¶À» ¶§ Ä¿¼­¸¦ º¯°æÇÑ´Ù - by monkman (2009.11.27) if (bJKeyState == false) MainImageForm->iMainImage->Cursor = crDefault; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- NVector->bClosedState = false; } } else if (NVector->bExtend && data->bClosed == false && bAltState) { // º¤ÅÍÈ®ÀåÀÇ °æ¿ì // ±âÁ¸ º¤ÅÍ µ¥ÀÌÅÍ¿¡ ¼± Çϳª¸¸ Ãß°¡ ¿¬ÀåÇÏ¿© ¸¶°¨(Close)½Ãų °æ¿ì // ÇöÀç ÀÔ·ÂµÈ ¶óÀÎÀÌ ±âÁ¸ º¤ÅÍ µ¥ÀÌÅÍÀÇ ½ÃÀÛÁ¡, ³¡Á¡¿¡ ÀÖ´ÂÁö üũ - by monkman (2009.11.19) RECT sr = Rect(NVector->Lsx - 5, NVector->Lsy - 5, NVector->Lsx + 5, NVector->Lsy + 5); if ((PtInRect(&tr, data->pList[0].P()) && PtInRect(&sr, data->pList[data->nCount * 3].P())) || ((PtInRect(&tr, data->pList[data->nCount * 3].P()) && PtInRect(&sr, data->pList[0].P())))) { MainImageForm->iMainImage->Cursor = crHandPoint; NVector->bClosedState = true; } } // ============= } else if (NVector->step == 2) { POINT pTan1, pTan2; if (VectorForm->LineType == 1 || VectorForm->LineType == 2) { pTan1.x = Lsx; pTan1.y = Lsy; pTan2.x = Lex * 2 - Cux; pTan2.y = Ley * 2 - Cuy; } else if (VectorForm->LineType == 3) { if (NVector->bFstLine) { pTan1.x = Lsx; pTan1.y = Lsy; } else { pTan1.x = (pTan.x - PositionX) * ZoomIn / ZoomOut - px; pTan1.y = (pTan.y - PositionY) * ZoomIn / ZoomOut - py; } pTan2.x = Lex * 2 - Cux; pTan2.y = Ley * 2 - Cuy; } // POINT pts[] = {{Lsx ,Lsy}, {pTan1.x, pTan1.y}, {pTan2.x, pTan2.y}, {Lex, Ley}}; // PolyBezier (dcDst, pts, 4); gdp::PointF *ppts = NULL; ppts = new gdp::PointF[4]; ppts[0].X = Lsx; ppts[0].Y = Lsy; ppts[1].X = pTan1.x; ppts[1].Y = pTan1.y; ppts[2].X = pTan2.x; ppts[2].Y = pTan2.y; ppts[3].X = Lex; ppts[3].Y = Ley; graphics.DrawBeziers(&ObjectPen, ppts, 4); if (ppts) delete[]ppts; ppts = NULL; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (NVector->bVectorReflectionMode) { gdp::PointF *ppts2 = NULL; ppts2 = new gdp::PointF[4]; if (NVector->ReflectionVH == 1) { // ¼öÁ÷ ±âÁؼ± ppts2[0].X = ReflectionIndex * 2 - Lsx; ppts2[0].Y = Lsy; ppts2[1].X = ReflectionIndex * 2 - pTan1.x; ppts2[1].Y = pTan1.y; ppts2[2].X = ReflectionIndex * 2 - pTan2.x; ppts2[2].Y = pTan2.y; ppts2[3].X = ReflectionIndex * 2 - Lex; ppts2[3].Y = Ley; graphics.DrawBeziers(&ObjectPen, ppts2, 4); } if (NVector->ReflectionVH == 2) { // ¼öÆò ±âÁؼ± ppts2[0].X = Lsx; ppts2[0].Y = ReflectionIndex * 2 - Lsy; ppts2[1].X = pTan1.x; ppts2[1].Y = ReflectionIndex * 2 - pTan1.y; ppts2[2].X = pTan2.x; ppts2[2].Y = ReflectionIndex * 2 - pTan2.y; ppts2[3].X = Lex; ppts2[3].Y = ReflectionIndex * 2 - Ley; graphics.DrawBeziers(&ObjectPen, ppts2, 4); } if (ppts2) delete[]ppts2; ppts2 = NULL; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- DeleteObject(SelectObject(dcDst, hOldPen)); hPen = NULL; hPen = CreatePen(psSolid, 1, PathColor); hOldPen = (HPEN)SelectObject(dcDst, hPen); SetROP2(dcDst, R2_COPYPEN); graphics.DrawLine(&pathPen, pTan2.x, pTan2.y, Cux, Cuy); graphics.DrawRectangle(&pathPen, pTan2.x - 2, pTan2.y - 2, 5, 5); graphics.DrawRectangle(&pathPen, Cux - 2, Cuy - 2, 5, 5); } break; case M_D_SQUARE: // Square if (NVector->step == 1) { int vmin = min(abs(Lsx - Cux), abs(Lsy - Cuy)); int startx, starty, width, height; // if (Cux > Lsx) Cux = Lsx + vmin; else Cux = Lsx - vmin; // if (Cuy > Ley) Cuy = Ley + vmin; else Cuy = Ley - vmin; // Rectangle(dcDst, Lsx, Ley, Cux, Cuy); if (Cux > Lsx && Cuy > Ley) { startx = Lsx; starty = Lsy; width = vmin; height = vmin; } else { if (Cux < Lsx) { startx = Lsx - vmin; width = vmin; } else { startx = Lsx; width = vmin; } if (Cuy < Ley) { starty = Lsy - vmin; height = vmin; } else { starty = Lsy; height = vmin; } } graphics.DrawRectangle(&ObjectPen, startx, starty, width, height); // Cux - Lsx, Cuy - Ley); // graphics.DrawRectangle(&ObjectPen, startx, starty, Cux - Lsx, Cuy - Ley); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (NVector->bVectorReflectionMode) { ReflectionIndex = ReflectionIndex - vmin / 2; if (NVector->ReflectionVH == 1) { // ¼öÁ÷ ±âÁؼ± // graphics.DrawRectangle(&ObjectPen, ReflectionIndex*2-Lsx, Ley, Cux - Lsx, Cuy - Ley); graphics.DrawRectangle(&ObjectPen, ReflectionIndex * 2 - startx, starty, width, height); } if (NVector->ReflectionVH == 2) { // ¼öÆò ±âÁؼ± // graphics.DrawRectangle(&ObjectPen, Lsx, ReflectionIndex*2-Ley, Cux - Lsx, Cuy - Ley); graphics.DrawRectangle(&ObjectPen, startx, ReflectionIndex * 2 - starty, width, height); } } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } break; case M_D_RECT: // Rectangle if (NVector->step == 1) { // Rectangle(dcDst, Lsx, Lsy, Cux, Cuy); // graphics.DrawRectangle(&ObjectPen, Lsx, Lsy, abs(Cux - Lsx), abs(Cuy - Lsy)); int startx, starty; if (Cux > Lsx && Cuy > Ley) { startx = Lsx; starty = Lsy; } else { if (Cux < Lsx) startx = Cux; else startx = Lsx; if (Cuy < Ley) starty = Cuy; else starty = Ley; } graphics.DrawRectangle(&ObjectPen, startx, starty, abs(Cux - Lsx), abs(Cuy - Lsy)); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (NVector->bVectorReflectionMode) { if (NVector->ReflectionVH == 1) { // ¼öÁ÷ ±âÁؼ± // graphics.DrawRectangle(&ObjectPen, ReflectionIndex*2-Cux, Lsy, Cux - Lsx, Cuy - Lsy); graphics.DrawRectangle(&ObjectPen, ReflectionIndex * 2 - startx - abs(Cux - Lsx), starty, abs(Cux - Lsx), abs(Cuy - Lsy)); } if (NVector->ReflectionVH == 2) { // ¼öÆò ±âÁؼ± // graphics.DrawRectangle(&ObjectPen, Lsx, ReflectionIndex*2-Cuy, Cux - Lsx, Cuy - Lsy); graphics.DrawRectangle(&ObjectPen, startx, ReflectionIndex * 2 - starty - abs(Cuy - Lsy), abs(Cux - Lsx), abs(Cuy - Lsy)); } } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } break; case M_D_CIRCLE: // Circle if (NVector->step == 1) { int ra = sqrt((Cux - Lsx) * (Cux - Lsx) + (Cuy - Lsy) * (Cuy - Lsy)); // Ellipse(dcDst, Lsx-ra, Lsy-ra, Lsx+ra, Lsy+ra); gdp::Rect rect(Lsx - ra, Lsy - ra, ra * 2, ra * 2); graphics.DrawEllipse(&ObjectPen, rect); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (NVector->bVectorReflectionMode) { if (NVector->ReflectionVH == 1) { // ¼öÁ÷ ±âÁؼ± gdp::Rect rect((ReflectionIndex * 2 - Lsx) - ra, Lsy - ra, ra * 2, ra * 2); graphics.DrawEllipse(&ObjectPen, rect); } if (NVector->ReflectionVH == 2) { // ¼öÆò ±âÁؼ± gdp::Rect rect(Lsx - ra, (ReflectionIndex * 2 - Lsy) - ra, ra * 2, ra * 2); graphics.DrawEllipse(&ObjectPen, rect); } } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } break; case M_D_ELLIPSE: // Ellipse if (NVector->step == 1) { // Ellipse(dcDst, Lsx-abs(Lsx-Cux), Lsy-abs(Lsy-Cuy), Lsx+abs(Lsx-Cux), Lsy+abs(Lsy-Cuy)); gdp::Rect rect(Lsx - abs(Lsx - Cux), Lsy - abs(Lsy - Cuy), abs(Lsx - Cux) * 2, abs(Lsy - Cuy) * 2); graphics.DrawEllipse(&ObjectPen, rect); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (NVector->bVectorReflectionMode) { if (NVector->ReflectionVH == 1) { // ¼öÁ÷ ±âÁؼ± gdp::Rect rect((ReflectionIndex * 2 - Lsx) - abs(Lsx - Cux), Lsy - abs(Lsy - Cuy), abs(Lsx - Cux) * 2, abs(Lsy - Cuy) * 2); graphics.DrawEllipse(&ObjectPen, rect); } if (NVector->ReflectionVH == 2) { // ¼öÆò ±âÁؼ± gdp::Rect rect(Lsx - abs(Lsx - Cux), (ReflectionIndex * 2 - Lsy) - abs(Lsy - Cuy), abs(Lsx - Cux) * 2, abs(Lsy - Cuy) * 2); graphics.DrawEllipse(&ObjectPen, rect); } } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } break; } if (dashValues) delete[]dashValues; dashValues = NULL; SetROP2(dcDst, nDrawMode); SelectObject(dcDst, hOldPen); SelectObject(dcDst, hOldBrush); DeleteObject(hPen); hPen = NULL; // if (DataList->Count <= 0) { // if (data) delete data; // data = NULL; // } } // --------------------------------------------------------------------------- void __fastcall TVecDraw::ObjectSelect(TShiftState Shift, int X, int Y, bool bPoint) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) double MinDist = MaxInt, CurDist = MaxInt; int MinIndex = -1; int FirstX, FirstY, SecondX, SecondY; nSelPos = 0; ptNumber = -1; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (data->bLocked) { data->bSelected = false; continue; } if (!Shift.Contains(ssShift) && !Shift.Contains(ssAlt)) data->bSelected = false; if (data->Kind == V_TEXTBOX && !bPoint) { // V_TEXTBOXÀ϶§ (Point Edit menu¿¡¼­´Â ºÒ°¡) if (data->ListOfAllLine && data->ListOfAllLine->CurveData) continue; // DeSelectedTextProc(data); MakeTextBoxPointList(data); if (CursorInTextBox(X, Y, data)) MinIndex = i; continue; } else { if (data->Kind == V_TEXT) { FirstY = min(data->First.y, data->Second.y); SecondY = max(data->First.y, data->Second.y); FirstX = min(data->First.x, data->Second.x); SecondX = max(data->First.x, data->Second.x); } else { FirstX = data->First.x - data->PenThick; FirstY = data->First.y - data->PenThick; SecondX = data->Second.x + data->PenThick; SecondY = data->Second.y + data->PenThick; } if (X < FirstX || X > SecondX || Y < FirstY || Y > SecondY) continue; // »ç°¢Çü ¾È¿¡ ÀÖ´ÂÁö °Ë»ç if (data->Kind == V_LINE || data->Kind == V_CURVE) { // Á÷¼±, °î¼±¾ÈÀÇ ¿µ¿ª¿¡ ÀÖ´ÂÁö °Ë»ç // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // Vector Line ¼±Åà ±â´É - ±âÁ¸ÀÇ PointOnCurvePath ÇÔ¼ö¸¦ ´õ Á¤¹ÐÇÏ°Ô ¼öÁ¤ - by monkman (2005.03.21) if (data->bClosed && VectorForm->V_Item == M_O_EDIT && (data->bFill || data->bPatternFill)) { if (IsInObject(data, X, Y, true)) { //´ÝÈù object ¾ÈÀ» Ŭ¸¯ÇÒ ¶§¿¡µµ ¼±ÅÃµÇ°Ô Ã³¸® //¸¶¿ì½ºÅ¬¸¯ ptm°ú »ç°¢Çü ¿µ¿ª°úÀÇ °Å¸®¸¦ ÀÌ¿ëÇØ¼­ °¡Àå °¡±î¿î ¿ÀºêÁ§Æ®¸¦ //¼±ÅÃÇϵµ·Ï ¾Æ·¡¿Í °°ÀÌ Ã³¸®ÇÔ. my david 2014.08.21 VECTOR2D tt0, tt1; POINT pt0 = {FirstX, FirstY}; POINT pt1 = {SecondX, SecondY}; POINT ptM = {X, Y};; POINTS2VECTOR2D(ptM, pt0, tt0); //º¤Å͸¦ ±¸ÇÑ´Ù. POINTS2VECTOR2D(ptM, pt1, tt1); double dis0 = vVectorMagnitude(&tt0); //Å©±â¸¦ ±¸ÇÑ´Ù. double dis1 = vVectorMagnitude(&tt1); CurDist = dis0 < dis1 ? dis0 : dis1; //ÀÛÀº Å©±â¸¦ ¼±ÅÃÇÑ´Ù. //ÃÖ»óÀ§¿¡ ÀÖ´Â °ÍÀ» ¼±ÅÃÇÏ¸é µÇ±â ¶§¹®¿¡ Å©±â ºñ±³¸¦ ÇÒ Çʿ䰡 ¾ø´Ù. MinIndex = i; MinDist = CurDist; //¾Æ·¡ ºÎºÐÀº ¹«Á¶°Ç °¡Àå °¡±î¿î ¿ÀºêÁ§Æ®¸¦ ¼±ÅÃÇØ¾ß ÇÒ °æ¿ì¿¡¸¸ ÇÊ¿äÇÏ´Ù. //»ç¿ëÀÚ°¡ ÃÖ»óÀ§¿¡ ÀÖ´Â ¿ÀºêÁ§Æ®ºÎÅÍ ¼±ÅÃÇÒ ¼ö ÀÖµµ·Ï ¿äÃ»ÇØ¼­ ÁÖ¼®Ã³¸® /* if (CurDist >= 0 && MinDist >= CurDist) { MinIndex = i; MinDist = CurDist; } */ } } else { CurDist = PointOnCurvePath(data, X, Y); if (CurDist >= 0 && MinDist >= CurDist) { MinIndex = i; MinDist = CurDist; } } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // Vector Line ¼±Åà ±â´É - ¼±ÅõǾîÀÖÁö ¾ÊÀº °Í¸¸ pMask¸¦ ÃʱâÈ­ ½ÃŲ´Ù - by monkman (2005.03.21) if (!data->bSelected && data->pMask) { memset(data->pMask, 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } } if ((Shift.Contains(ssShift) || Shift.Contains(ssAlt)) && MinIndex == -1) { END_LOG; return; } else if (MinIndex == -1) { NVector->bSelected = false; END_LOG; return; } // ÇØ´çÇÏ´Â object°¡ ¾øÀ½ success: data = (TVecData*)DataList->Items[MinIndex]; if (Shift.Contains(ssAlt)) { data->bSelected = false; // ¾ËÆ®¸¦ ´©¸£°í ¼±ÅÃÇÏ¸é ¼±ÅÃÀÌ ÇØÁ¦µÈ´Ù // if ((data->GroupIndex & 0xfffffe00) && !bPoint) ModifyGroup(data, false); if ((data->GroupIndex - ((data->GroupIndex % 10000) & 0x000001ff)) && !bPoint) ModifyGroup(data, false); // by siuaa 080501 } else { data->bSelected = true; if (data->Kind == V_TEXTBOX) { // ¸¶¿ì½º ¿À¸¥ÂÊ ¹öư ´­·¶À»¶§ ¶ß´Â ÆË¾÷ ¸Þ´º¿¡¼­ ReverseCopy¸¦ ¸·À½ - by monkman (2004.11.08) VectorForm->ReverseCopy->Enabled = false; } else { VectorForm->ReverseCopy->Enabled = true; } // if ((data->GroupIndex & 0xfffffe00 && !bPoint)) ModifyGroup(data, true); if ((data->GroupIndex - ((data->GroupIndex % 10000) & 0x000001ff)) && !bPoint) ModifyGroup(data, true); } NVector->bSelected = true; Index = MinIndex; nSelPos = 5; // ´©¸£ÀÚ ¸¶ÀÚ À̵¿½Ãų ¼ö ÀÖÀ½ // Antialiasing üũ¹Ú½º ¼³Á¤ 20050211 shin bool bTemp = VectorForm->bUserChange; VectorForm->bUserChange = false; if (data->bAntialiasing) VectorForm->cbObjAntialiasing2->Checked = true; else VectorForm->cbObjAntialiasing2->Checked = false; VectorForm->bUserChange = bTemp; VectorForm->PenThick = data->PenThick; // VectorForm->VectorPenComboBox->ItemIndex = 0; // VectorForm->VectorPenComboBox->Items->Strings[0] = FloatToStr(data->PenThick); // if (*bSelected && !MainImageForm->tempRadioButton->Focused()) MainImageForm->tempRadioButton->SetFocus(); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::DrawSelectedLine(HDC dcDst, int px, int py, TMainImageForm *form) { TList *DataList = form->V_DATA; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) HPEN hOldPen = NULL, hPen = NULL; HBRUSH hOldBrush = NULL; POINT *pPoints = NULL; // pPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) POINT ptTemp; int nDrawMode; int ZoomIn = form->iMainImage->ZoomIn; int ZoomOut = form->iMainImage->ZoomOut; int PositionX = form->sbHorz->Position; int PositionY = form->sbVert->Position; int FirstX, FirstY, SecondX, SecondY; RECT ScreenCanvasRect; RECT VectorRect; // hPen = CreatePen(psSolid , 1, clBlack); hPen = CreatePen(psSolid, 1, PathColor); hOldPen = (HPEN)SelectObject(dcDst, hPen); nDrawMode = GetROP2(dcDst); SetROP2(dcDst, R2_COPYPEN); // SetROP2(dcDst, R2_NOT); hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); // ¼Óµµ °³¼± - ÇöÀç º¸¿©Áö´Â ĵ¹ö½ºÀÇ ¿µ¿ªÀ» ±¸ÇÑ´Ù - by monkman (2005.07.12) ScreenCanvasRect.left = 0; ScreenCanvasRect.top = 0; ScreenCanvasRect.right = form->iMainImage->Width; ScreenCanvasRect.bottom = form->iMainImage->Height; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(form->Number)) continue; // -->by linuxjun for CurvedVectorText if (!(BeReadyEdit && CurrentTextBox == i)) { if (!data->bSelected) continue; } else { if (data->Kind != V_TEXTBOX) continue; if (data->bSelected) { if (data->ListOfAllLine->CurveData) { data = data->ListOfAllLine->CurveData; } } else { if (!data->ListOfAllLine->CurveData) continue; if (data->ListOfAllLine->CurveData) { data = data->ListOfAllLine->CurveData; } } } // <--by linuxjun for CurvedVectorText FirstX = (data->First.x - PositionX) * ZoomIn / ZoomOut - px; FirstY = (data->First.y - PositionY) * ZoomIn / ZoomOut - py; SecondX = (data->Second.x - PositionX) * ZoomIn / ZoomOut - px; SecondY = (data->Second.y - PositionY) * ZoomIn / ZoomOut - py; if (data->Kind == V_TEXTBOX) { if (data->ListOfAllLine && data->ListOfAllLine->CurveData) { TVecData *CurveData; CurveData = data->ListOfAllLine->CurveData; int Margin; try { Margin = data->ListOfAllLine->GetLineTextBox(0)->lineHeight * 3; } catch(...) { Margin = 0; } VectorRect.left = ((CurveData->First.x - Margin) - PositionX) * ZoomIn / ZoomOut - px; VectorRect.right = ((CurveData->Second.x + Margin) - PositionX) * ZoomIn / ZoomOut - px; VectorRect.top = ((CurveData->First.y - Margin) - PositionY) * ZoomIn / ZoomOut - py; VectorRect.bottom = ((CurveData->Second.y + Margin) - PositionY) * ZoomIn / ZoomOut - py; } else { VectorRect.left = FirstX; VectorRect.right = SecondX; VectorRect.top = FirstY; VectorRect.bottom = SecondY; for (int j = 0; j < 5; j++) { VectorRect.left = min(VectorRect.left, (data->pList[j].x - PositionX) * ZoomIn / ZoomOut - px); VectorRect.right = max(VectorRect.right, (data->pList[j].x - PositionX) * ZoomIn / ZoomOut - px); VectorRect.top = min(VectorRect.top, (data->pList[j].y - PositionY) * ZoomIn / ZoomOut - py); VectorRect.bottom = max(VectorRect.bottom, (data->pList[j].y - PositionY) * ZoomIn / ZoomOut - py); } } } else { VectorRect.left = FirstX; VectorRect.right = SecondX; VectorRect.top = FirstY; VectorRect.bottom = SecondY; } // ¼Óµµ °³¼± - ¿µ¿ª¾È¿¡ µé¾î¿Â º¤Å͸¸ ±×¸°´Ù - by monkman (2005.07.08) if (!(NVector->bMergeMode) && ((VectorRect.left < ScreenCanvasRect.left && VectorRect.right < ScreenCanvasRect.left) || (VectorRect.top < ScreenCanvasRect.top && VectorRect.bottom < ScreenCanvasRect.top) || (VectorRect.left > ScreenCanvasRect.right && VectorRect.right > ScreenCanvasRect.right) || (VectorRect.top > ScreenCanvasRect.bottom && VectorRect.bottom > ScreenCanvasRect.bottom))) continue; if (data->Kind == V_TEXTBOX) { pPoints = new POINT[5]; } else { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new POINT[(data->nCount + 1) * 3 + 1]; } else { pPoints = new POINT[data->nCount * 3 + 1]; } } if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int j = 0; j < data->nCount * 3 + 1; j++) { pPoints[j].x = (data->pList[j].x - PositionX) * ZoomIn / ZoomOut - px; pPoints[j].y = (data->pList[j].y - PositionY) * ZoomIn / ZoomOut - py; } } if (data->Kind == V_TEXTBOX && !data->ListOfAllLine->CurveData) { if (NVector->bRotation) continue; for (int j = 0; j < 5; j++) { pPoints[j].x = (data->pList[j].x - PositionX) * ZoomIn / ZoomOut - px; pPoints[j].y = (data->pList[j].y - PositionY) * ZoomIn / ZoomOut - py; } } //////// Closed Path if (data->bClosed) pPoints[data->nCount * 3] = pPoints[0]; //////// if (data->Kind == V_TEXT) { int height = data->Font.lfHeight * ZoomIn / ZoomOut; double angle = 2 * M_PI * data->Font.lfEscapement / 10 / 360; if (angle < M_PI / 2 || (angle > M_PI && angle < M_PI * 3 / 2)) { // 1, 3»çºÐ¸é¿¡¼­ FirstX = FirstX - height * sin(angle); SecondX = SecondX + height * sin(angle); } else { // 2, 4»çºÐ¸é¿¡¼­ FirstY = FirstY - height * cos(angle); SecondY = SecondY + height * cos(angle); } } switch(data->Kind) { case V_LINE: for (int j = 0; j < data->nCount + 1; j++) { SmallRect(dcDst, pPoints[j]); if ((data->pMask[j / 8] >> j % 8) & 0x01) SmallRect2(dcDst, pPoints[j]); } Polyline(dcDst, pPoints, data->nCount + 1); ptTemp = Point((FirstX + SecondX) / 2, (FirstY + SecondY) / 2); SmallRect(dcDst, ptTemp); break; case V_TEXTBOX: if (data->ListOfAllLine->CurveData) break; for (int j = 0; j < 5; j++) { SmallRect(dcDst, pPoints[j]); if ((data->pMask[j / 8] >> j % 8) & 0x01) SmallRect2(dcDst, pPoints[j]); } Polyline(dcDst, pPoints, 5); ptTemp = Point((pPoints[0].x + pPoints[2].x) / 2, (pPoints[0].y + pPoints[2].y) / 2); SmallRect(dcDst, ptTemp); break; case V_CURVE: PolyBezier(dcDst, pPoints, data->nCount * 3 + 1); for (int j = 0; j < data->nCount * 3 + (!data->bClosed); j += 3) { SmallRect(dcDst, pPoints[j]); if ((data->pMask[j / 8] >> j % 8) & 0x01) { SmallRect2(dcDst, pPoints[j]); } } for (int j = 0; j < data->nCount * 3 + (!data->bClosed); j++) { if ((data->pMask[j / 8] >> j % 8) & 0x01) { switch(j % 3) { case 0: // ½ÇÁ¦ Á¡ if (j == data->nCount * 3) { // ¸¶Áö¸· Á¡Àΰæ¿ì!~ SmallRect(dcDst, pPoints[j - 1]); MoveToEx(dcDst, pPoints[j - 1].x, pPoints[j - 1].y, NULL); LineTo(dcDst, pPoints[j].x, pPoints[j].y); } else { if (j == 0) { if (data->bClosed) { // for Closed path SmallRect(dcDst, pPoints[data->nCount * 3 - 1]); SmallRect(dcDst, pPoints[j + 1]); MoveToEx(dcDst, pPoints[data->nCount * 3 - 1].x, pPoints[data->nCount * 3 - 1].y, NULL); LineTo(dcDst, pPoints[j].x, pPoints[j].y); LineTo(dcDst, pPoints[j + 1].x, pPoints[j + 1].y); } else { // when j equal zero SmallRect(dcDst, pPoints[j + 1]); MoveToEx(dcDst, pPoints[j].x, pPoints[j].y, NULL); LineTo(dcDst, pPoints[j + 1].x, pPoints[j + 1].y); } } else { // ordinary SmallRect(dcDst, pPoints[j - 1]); SmallRect(dcDst, pPoints[j + 1]); MoveToEx(dcDst, pPoints[j - 1].x, pPoints[j - 1].y, NULL); LineTo(dcDst, pPoints[j].x, pPoints[j].y); LineTo(dcDst, pPoints[j + 1].x, pPoints[j + 1].y); } } break; case 1: if (j == 1) { if (data->bClosed) { SmallRect(dcDst, pPoints[data->nCount * 3 - 1]); SmallRect(dcDst, pPoints[j]); MoveToEx(dcDst, pPoints[data->nCount * 3 - 1].x, pPoints[data->nCount * 3 - 1].y, NULL); LineTo(dcDst, pPoints[j - 1].x, pPoints[j - 1].y); LineTo(dcDst, pPoints[j].x, pPoints[j].y); } else { SmallRect(dcDst, pPoints[j]); MoveToEx(dcDst, pPoints[j - 1].x, pPoints[j - 1].y, NULL); LineTo(dcDst, pPoints[j].x, pPoints[j].y); } } else { SmallRect(dcDst, pPoints[j - 2]); SmallRect(dcDst, pPoints[j]); MoveToEx(dcDst, pPoints[j - 2].x, pPoints[j - 2].y, NULL); LineTo(dcDst, pPoints[j - 1].x, pPoints[j - 1].y); LineTo(dcDst, pPoints[j].x, pPoints[j].y); } break; case 2: if (j == data->nCount * 3 - 1) { // ¸¶Áö¸· Á¶ÀýÁ¡Àΰæ¿ì!~ if (data->bClosed) { SmallRect(dcDst, pPoints[j]); SmallRect(dcDst, pPoints[1]); MoveToEx(dcDst, pPoints[j].x, pPoints[j].y, NULL); LineTo(dcDst, pPoints[j + 1].x, pPoints[j + 1].y); LineTo(dcDst, pPoints[1].x, pPoints[1].y); } else { SmallRect(dcDst, pPoints[j]); MoveToEx(dcDst, pPoints[j].x, pPoints[j].y, NULL); LineTo(dcDst, pPoints[j + 1].x, pPoints[j + 1].y); } } else { SmallRect(dcDst, pPoints[j]); SmallRect(dcDst, pPoints[j + 2]); MoveToEx(dcDst, pPoints[j].x, pPoints[j].y, NULL); LineTo(dcDst, pPoints[j + 1].x, pPoints[j + 1].y); LineTo(dcDst, pPoints[j + 2].x, pPoints[j + 2].y); } break; } } } break; default: Rectangle(dcDst, FirstX, FirstY, SecondX, SecondY); ptTemp = Point(FirstX, FirstY); SmallRect(dcDst, ptTemp); ptTemp = Point(SecondX, SecondY); SmallRect(dcDst, ptTemp); ptTemp = Point(FirstX, SecondY); SmallRect(dcDst, ptTemp); ptTemp = Point(SecondX, FirstY); SmallRect(dcDst, ptTemp); ptTemp = Point((FirstX + SecondX) / 2, (FirstY + SecondY) / 2); SmallRect(dcDst, ptTemp); break; } if (pPoints) delete[]pPoints; pPoints = NULL; } SetROP2(dcDst, nDrawMode); SelectObject(dcDst, hOldPen); SelectObject(dcDst, hOldBrush); DeleteObject(hPen); hPen = NULL; if (pPoints) delete[]pPoints; pPoints = NULL; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::DrawProportionLine(HDC dcDst, int px, int py) { TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) HPEN hOldPen = NULL, hPen = NULL; HBRUSH hOldBrush = NULL; POINT *pPoints = NULL; // pPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) int nDrawMode; int ZoomIn = MainImageForm->iMainImage->ZoomIn; int ZoomOut = MainImageForm->iMainImage->ZoomOut; int PositionX = MainImageForm->sbHorz->Position; int PositionY = MainImageForm->sbVert->Position; int StartX, StartY; double CenterX, CenterY; int cx = (sx + ex) / 2, cy = (sy + ey) / 2; // rotation objectµéÀÇ centerÁ¡µé hPen = CreatePen(psSolid, 2, PathColor); hOldPen = (HPEN)SelectObject(dcDst, hPen); nDrawMode = GetROP2(dcDst); SetROP2(dcDst, R2_COPYPEN); hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->Kind == V_TEXT) { data->bSelected = false; continue; } if (NVector->bProportion) { ProportionTransform(data); // È®´ëÃà¼Ò½Ã¿¡´Â Á¡µéÀÇ TransformÀÌ °¡ÇØÁü SET_RECT; } if (data->Kind == V_TEXTBOX) { pPoints = new POINT[5]; } else { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new POINT[(data->nCount + 1) * 3 + 1]; } else { pPoints = new POINT[data->nCount * 3 + 1]; } } if (data->Kind == V_TEXTBOX) { // by maxleo21c 04/10/19 StartX = (data->StartPoint.x - PositionX) * ZoomIn / ZoomOut - px; StartY = (data->StartPoint.y - PositionY) * ZoomIn / ZoomOut - py; CenterX = (data->CenterPoint.x - PositionX) * ZoomIn / ZoomOut - px; CenterY = (data->CenterPoint.y - PositionY) * ZoomIn / ZoomOut - py; // OffsetX = PositionX; // OffsetY = PositionY; // by linuxjun for CurvedVectorText // FontZoom = (double)ZoomIn / ZoomOut; for (int i = 0; i < 5; i++) { pPoints[i].x = (data->pList[i].x - PositionX) * ZoomIn / ZoomOut - px; pPoints[i].y = (data->pList[i].y - PositionY) * ZoomIn / ZoomOut - py; } } else { if (data->pList == NULL) continue; for (int i = 0; i < data->nCount * 3 + 1; i++) pPoints[i] = data->pList[i].P(); if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int i = 0; i < data->nCount * 3 + 1; i++) { pPoints[i].x = (pPoints[i].x - PositionX) * ZoomIn / ZoomOut - px; pPoints[i].y = (pPoints[i].y - PositionY) * ZoomIn / ZoomOut - py; } } if (data->bClosed) pPoints[data->nCount * 3] = pPoints[0]; } switch(data->Kind) { case V_LINE: Polyline(dcDst, pPoints, data->nCount + 1); break; case V_TEXTBOX: Polyline(dcDst, pPoints, 5); break; case V_CURVE: PolyBezier(dcDst, pPoints, data->nCount * 3 + 1); break; } if (NVector->bProportion) ProportionInverseTransform(data); // TransformÀÌ °¡ÇØÁø Á¡À» ´Ù½Ã µÇµ¹¸² if (NVector->bProportion && data->Kind == V_TEXTBOX) { data->ProportionFirst.x = (data->ProportionFirst.x - PositionX) * ZoomIn / ZoomOut - px; data->ProportionFirst.y = (data->ProportionFirst.y - PositionY) * ZoomIn / ZoomOut - py; for (int j = 0; j < 5; j++) { PropPoints[j].x = (PropPoints[j].x - PositionX) * ZoomIn / ZoomOut - px; PropPoints[j].y = (PropPoints[j].y - PositionY) * ZoomIn / ZoomOut - py; } DrawProportionTextBox(dcDst, data, CenterX, CenterY, px, py); // È®´ë/Ãà¼ÒµÇ´Â ±ÛÀÚ¸¦ º¸¿©ÁÖ±â À§Çؼ­ } if (pPoints) delete[]pPoints; pPoints = NULL; } SetROP2(dcDst, nDrawMode); SelectObject(dcDst, hOldPen); SelectObject(dcDst, hOldBrush); DeleteObject(hPen); hPen = NULL; pPoints = NULL; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::DrawRotationLine(HDC dcDst, int px, int py) { TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) HPEN hOldPen = NULL, hPen = NULL; HBRUSH hOldBrush = NULL; POINT *pPoints = NULL; // pPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) int nDrawMode; int ZoomIn = MainImageForm->iMainImage->ZoomIn; int ZoomOut = MainImageForm->iMainImage->ZoomOut; int PositionX = MainImageForm->sbHorz->Position; int PositionY = MainImageForm->sbVert->Position; int cx = (sx + ex) / 2, cy = (sy + ey) / 2; // rotation objectµéÀÇ centerÁ¡µé hPen = CreatePen(psSolid, 2, PathColor); hOldPen = (HPEN)SelectObject(dcDst, hPen); nDrawMode = GetROP2(dcDst); SetROP2(dcDst, R2_COPYPEN); hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->Kind == V_TEXT) { data->bSelected = false; continue; } if (data->Kind == V_TEXTBOX) { pPoints = new POINT[5]; } else { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new POINT[(data->nCount + 1) * 3 + 1]; } else { pPoints = new POINT[data->nCount * 3 + 1]; } } if (data->Kind == V_TEXTBOX) { // by maxleo21c 04/10/19 for (int i = 0; i < 5; i++) pPoints[i] = data->pList[i].P(); for (int j = 0; j < 5; j++) { int tx = pPoints[j].x - cx; int ty = cy - pPoints[j].y; pPoints[j].x = tx * cos(-RotationAngle) + ty * sin(-RotationAngle) + cx; pPoints[j].y = cy - (-tx * sin(-RotationAngle) + ty * cos (-RotationAngle)); } for (int k = 0; k < 5; k++) { pPoints[k].x = (pPoints[k].x - PositionX) * ZoomIn / ZoomOut - px; pPoints[k].y = (pPoints[k].y - PositionY) * ZoomIn / ZoomOut - py; } } else { if (data->pList == NULL) continue; for (int i = 0; i < data->nCount * 3 + 1; i++) pPoints[i] = data->pList[i].P(); for (int j = 0; j < data->nCount * 3 + 1; j++) { int tx = pPoints[j].x - cx; int ty = cy - pPoints[j].y; pPoints[j].x = tx * cos(-RotationAngle) + ty * sin(-RotationAngle) + cx; pPoints[j].y = cy - (-tx * sin(-RotationAngle) + ty * cos (-RotationAngle)); } // -->by linuxjun for CurvedVectorText if (data->ParentTextBox) { MakeTextBoxPointList(data->ParentTextBox); TSWordData * tsWordData; for (int i = 0; i < data->ParentTextBox->ListOfAllLine->Count; i++) { tsWordData = (TSWordData*)data->ParentTextBox->ListOfAllLine->Items (i); double tx = tsWordData->px - cx; double ty = cy - tsWordData->py; tsWordData->px = tx * cos(-RotationAngle) + ty * sin(-RotationAngle) + cx; tsWordData->py = cy - (-tx * sin(-RotationAngle) + ty * cos (-RotationAngle)); tx = tsWordData->tx; ty = tsWordData->ty; tsWordData->tx = tx * cos(RotationAngle) + ty * sin(RotationAngle); tsWordData->ty = (-tx * sin(RotationAngle) + ty * cos(RotationAngle)); tx = tsWordData->nx; ty = tsWordData->ny; tsWordData->nx = tx * cos(RotationAngle) + ty * sin(RotationAngle); tsWordData->ny = (-tx * sin(RotationAngle) + ty * cos(RotationAngle)); } } // <--by linuxjun for CurvedVectorText if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int i = 0; i < data->nCount * 3 + 1; i++) { pPoints[i].x = (pPoints[i].x - PositionX) * ZoomIn / ZoomOut - px; pPoints[i].y = (pPoints[i].y - PositionY) * ZoomIn / ZoomOut - py; } } if (data->bClosed) pPoints[data->nCount * 3] = pPoints[0]; } switch(data->Kind) { case V_LINE: Polyline(dcDst, pPoints, data->nCount + 1); break; case V_TEXTBOX: Polyline(dcDst, pPoints, 5); break; case V_CURVE: PolyBezier(dcDst, pPoints, data->nCount * 3 + 1); break; } if (pPoints) delete[]pPoints; pPoints = NULL; } SetROP2(dcDst, nDrawMode); SelectObject(dcDst, hOldPen); SelectObject(dcDst, hOldBrush); DeleteObject(hPen); hPen = NULL; pPoints = NULL; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::DrawSpreadObject(HDC dcDst, int px, int py) { TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) HPEN hOldPen = NULL, hPen = NULL; HBRUSH hOldBrush = NULL, hBrush = NULL; HFONT font = NULL, oldfont = NULL; LOGBRUSH logbrush; int nDrawMode, nFillMode, nTemp, nPenStyle; double movx, movy; int count = 0; RGBQUAD rgb; int ZoomIn = MainImageForm->iMainImage->ZoomIn; int ZoomOut = MainImageForm->iMainImage->ZoomOut; int PositionX = MainImageForm->sbHorz->Position; int PositionY = MainImageForm->sbVert->Position; double Cux = NVector->Cux; double Cuy = NVector->Cuy; double Lex = NVector->Lex; double Ley = NVector->Ley; double tangent = Cuy - Ley != 0 && Cux - Lex != 0 ? double(Cuy - Ley) / double (Cux - Lex) : 0; int FirstX, FirstY, SecondX, SecondY; double CenterX = 0.0, CenterY = 0.0, FontZoom = 1.0, PulsNum = 0.0; int OffsetX, OffsetY; // by linuxjun for CurvedVectorText int StartX, StartY; int pw; gdp::Graphics graphics(dcDst); // using GDI+ graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); // antialiasing gdp::PointF *pPoints = NULL; Draw: switch(SpreadStep) { case 1: movx = Cux - (PasteRange.left + PasteRange.right) / 2; movy = Cuy - (PasteRange.top + PasteRange.bottom) / 2; break; case 2: movx = Lex - (PasteRange.left + PasteRange.right) / 2; movy = Ley - (PasteRange.top + PasteRange.bottom) / 2; break; } for (int i = 0; i < CopyList->Count; i++) { data = (TVecData*)CopyList->Items[i]; if (data->Kind == V_TEXT) continue; FirstX = (data->First.x - PositionX + movx) * ZoomIn / ZoomOut - px; FirstY = (data->First.y - PositionY + movy) * ZoomIn / ZoomOut - py; SecondX = (data->Second.x - PositionX + movx) * ZoomIn / ZoomOut - px; SecondY = (data->Second.y - PositionY + movy) * ZoomIn / ZoomOut - py; pw = data->PenThick / 2; float *dashValues = NULL; gdp::Color penColor(GetRValue(data->Color), GetGValue(data->Color), GetBValue(data->Color)); gdp::Pen ObjectPen(penColor, data->PenThick * ZoomIn / ZoomOut); gdp::Color brushColor(GetRValue(data->Brush), GetGValue(data->Brush), GetBValue(data->Brush)); gdp::SolidBrush ObjectBrush(brushColor); gdp::GraphicsPath gFillPath; if (data->Kind == V_CURVE || data->Kind == V_LINE) { if (data->bClosed) { pPoints = new gdp::PointF[(data->nCount + 1) * 3 + 1]; } else { pPoints = new gdp::PointF[data->nCount * 3 + 1]; } for (int i = 0; i < data->nCount * 3 + 1; i++) { pPoints[i].X = (data->pList[i].x - PositionX + movx) * ZoomIn / ZoomOut - px; pPoints[i].Y = (data->pList[i].y - PositionY + movy) * ZoomIn / ZoomOut - py; } } if (data->Kind == V_TEXTBOX) { StartX = (data->StartPoint.x - PositionX + movx) * ZoomIn / ZoomOut - px; StartY = (data->StartPoint.y - PositionY + movy) * ZoomIn / ZoomOut - py; OffsetX = PositionX - movx; OffsetY = PositionY - movy; // by linuxjun for CurvedVectorText pPoints = new gdp::PointF[5]; for (int i = 0; i < 5; i++) { pPoints[i].X = (data->pList[i].x - PositionX + movx) * ZoomIn / ZoomOut - px; pPoints[i].Y = (data->pList[i].y - PositionY + movy) * ZoomIn / ZoomOut - py; } } if (data->bClosed) { pPoints[data->nCount * 3] = pPoints[0]; if (data->PenStyle == P_SOLID) { pPoints[data->nCount * 3 + 1] = pPoints[1]; pPoints[data->nCount * 3 + 2] = pPoints[2]; pPoints[data->nCount * 3 + 3] = pPoints[3]; } } nDrawMode = GetROP2(dcDst); nFillMode = GetPolyFillMode(dcDst); logbrush.lbStyle = BS_SOLID; logbrush.lbColor = data->Brush; logbrush.lbHatch = 0; if (data->bFill) { // ColorFill À϶§ hBrush = CreateBrushIndirect(&logbrush); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); } else { // Fill X hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } if (data->bWinding) gFillPath.SetFillMode(gdp::FillModeWinding); else gFillPath.SetFillMode(gdp::FillModeAlternate); logbrush.lbColor = data->Color; // ÆæÀÇ color¸¦ À§Çؼ­... switch(data->PenStyle) { case 0: nPenStyle = int(PS_SOLID); break; case 1: nPenStyle = int(PS_DASH); break; case 2: nPenStyle = int(PS_DOT); break; case 3: nPenStyle = int(PS_DASHDOT); break; case 4: nPenStyle = int(PS_DASHDOTDOT); break; case 5: nPenStyle = P_USERSTYLE; int count = 0; double temp[6] = { 0, 0, 0, 0, 0, 0 }; CheckUserDashedLine(data, temp, count); dashValues = new float[count]; for (int i = 0; i < count; i++) { dashValues[i] = temp[i]; } ObjectPen.SetDashPattern(dashValues, count); break; // DashStyleCustom = 5 } if (data->bRound) { // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapRound); } } else { ObjectPen.SetStartCap(gdp::LineCapRound); ObjectPen.SetEndCap(gdp::LineCapRound); } ObjectPen.SetLineJoin(gdp::LineJoinRound); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapRound); } else { if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapFlat); } } else { ObjectPen.SetStartCap(gdp::LineCapFlat); ObjectPen.SetEndCap(gdp::LineCapFlat); } ObjectPen.SetLineJoin(gdp::LineJoinMiter); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapFlat); } hOldPen = (HPEN)SelectObject(dcDst, hPen); if (!(data->ParentTextBox || data->ChildList)) { // by linuxjun for CurvedVectorText PAINT_VECTOR; } if (data->ChildList) { // 090303 embakum motiveobjects DrawMotiveObjects(dcDst, data, MainImageForm, px, py, 6, PositionX - movx, PositionY - movy); // Selected LineÀ» ±×¸®Áö ¾ÊÀ½ - by monkman (2009.04.10) } if (pPoints) delete[]pPoints; pPoints = NULL; if (dashValues) delete[]dashValues; dashValues = NULL; SelectObject(dcDst, hOldBrush); SelectObject(dcDst, hOldPen); if (hBrush) DeleteObject(hBrush); if (hPen) DeleteObject(hPen); hOldPen = NULL; hOldBrush = NULL; hPen = NULL; hBrush = NULL; } if (SpreadStep == 2) { if (((Lex - Cux) * (Lex - Cux) + (Ley - Cuy) * (Ley - Cuy)) > SpreadGap * SpreadGap) { double dx = SpreadGap / sqrt(1 + tangent * tangent); double dy = dx * tangent; if (Lex == Cux && Ley != Cuy) { Ley = Cuy > Ley ? Ley + SpreadGap : Ley - SpreadGap; } else if (Lex != Cux && Ley == Cuy) { Lex = Cux > Lex ? Lex + SpreadGap : Lex - SpreadGap; } else if (Lex != Cux && Ley != Cuy) { if (Cux > Lex) { Lex += dx; Ley += dy; } else { Lex -= dx; Ley -= dy; } } else goto End; if (++count < 100) goto Draw; else goto End; } } End: if (pPoints) delete[]pPoints; pPoints = NULL; return; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::DrawSubBitmap(HDC dcDst, int px, int py) { HDC dcSrc = NULL, dcTemp = NULL; RECT src = MainImageForm->WorkArea->Range; int FirstX, FirstY; int bltwidth, bltheight; TTexpiaBitmap *temp = NULL; double angle; int ZoomIn = MainImageForm->iMainImage->ZoomIn; int ZoomOut = MainImageForm->iMainImage->ZoomOut; int PositionX = MainImageForm->sbHorz->Position; int PositionY = MainImageForm->sbVert->Position; int Cux = NVector->Cux; int Cuy = NVector->Cuy; int Lex = NVector->Lex; int Ley = NVector->Ley; if ((dcSrc = SubBitmap->CreateDC()) == NULL) goto next; switch(NVector->PatternStep) { case 1: // Å©±â Á¶Àý »óÅ FirstX = (src.left - PositionX) * ZoomIn / ZoomOut - px; FirstY = (src.top - PositionY) * ZoomIn / ZoomOut - py; bltwidth = abs(src.left - Cux) * ZoomIn / ZoomOut; bltheight = abs(src.top - Cuy) * ZoomIn / ZoomOut; StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcSrc, 0, 0, SubBitmap->Width, SubBitmap->Height, SRCCOPY); break; case 2: // ȸÀü Àü À̵¿ »óÅ FirstX = (Cux - SubBitmap->Width / 2 - PositionX) * ZoomIn / ZoomOut - px; FirstY = (Cuy - SubBitmap->Height / 2 - PositionY) * ZoomIn / ZoomOut - py; bltwidth = SubBitmap->Width * ZoomIn / ZoomOut; bltheight = SubBitmap->Height * ZoomIn / ZoomOut; StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcSrc, 0, 0, SubBitmap->Width, SubBitmap->Height, SRCCOPY); break; case 3: // ȸÀü »óÅ angle = ArcTan2(double(Cux - Lex), double(Ley - Cuy)); temp = new TTexpiaBitmap; temp->Create(SubBitmap->Width, SubBitmap->Height, SubBitmap->BitsPerPixel); // temp->FillRect(Rect(0,0,temp->Width, temp->Height), clWhite); // temp->Copy(0,0, temp->Width, temp->Height, SubBitmap, 0,0, SRCCOPY); if ((dcTemp = temp->CreateDC()) == NULL) goto next; BitBlt(dcTemp, 0, 0, temp->Width, temp->Height, dcSrc, 0, 0, SRCCOPY); temp->DeleteDC(dcTemp); dcTemp = NULL; temp->Rotate(angle > 0 ? int(angle * 180 / M_PI) * 100 : int (angle * 180 / M_PI + 360) * 100, true, clWhite); FirstX = (Lex - temp->Width / 2 - PositionX) * ZoomIn / ZoomOut - px; FirstY = (Ley - temp->Height / 2 - PositionY) * ZoomIn / ZoomOut - py; bltwidth = temp->Width * ZoomIn / ZoomOut; bltheight = temp->Height * ZoomIn / ZoomOut; if ((dcTemp = temp->CreateDC()) == NULL) goto next; StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcTemp, 0, 0, temp->Width, temp->Height, SRCCOPY); temp->DeleteDC(dcTemp); dcTemp = NULL; delete temp; temp = NULL; break; case 4: // ºÙÀ̱⠻óÅ FirstX = (Cux - SubBitmap->Width / 2 - PositionX) * ZoomIn / ZoomOut - px; FirstY = (Cuy - SubBitmap->Height / 2 - PositionY) * ZoomIn / ZoomOut - py; bltwidth = SubBitmap->Width * ZoomIn / ZoomOut; bltheight = SubBitmap->Height * ZoomIn / ZoomOut; StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcSrc, 0, 0, SubBitmap->Width, SubBitmap->Height, SRCCOPY); break; } SubBitmap->DeleteDC(dcSrc); dcSrc = NULL; next: if (temp) { delete temp; temp = NULL; } } // --------------------------------------------------------------------------- void __fastcall TVecDraw::AddSpreadObject() { TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) double Cux = NVector->Cux; double Cuy = NVector->Cuy; double Lex = NVector->Lsx; double Ley = NVector->Lsy; double tangent = Cuy - Ley != 0 && Cux - Lex != 0 ? double(Cuy - Ley) / double (Cux - Lex) : 0; double movx, movy; double dx, dy; TVecData *cdata; bool sw = true, sw2 = true; int index = 0; // ======= index Á¤Çϱâ (group number Á¤Çϱâ) /* for (int i = 0; i < DataList->Count; i++) { data = (TVecData *)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->GroupIndex) continue; index |= data->GroupIndex; } for (int i = 10; i < 32; i++) { if (index & (1 << i)) continue; index = i; break; } */ // by siuaa 080506 // ¹øÈ£°¡ ¾ø´Â groupÀÇ index´Â global·Î º¯¼ö¸¦ Àâ¾Æ¼­ 10000ºÎÅÍ Â÷·Ê·Î Áõ°¡ ½ÃÄÑ index¸¦ ºÎ¿© ÇÑ´Ù. MainImageForm->GroupIndexState += 10000; index = MainImageForm->GroupIndexState; while (sw2) { movx = Lex - (PasteRange.left + PasteRange.right) / 2; movy = Ley - (PasteRange.top + PasteRange.bottom) / 2; for (int i = 0; i < CopyList->Count; i++) { data = (TVecData*)CopyList->Items[i]; if (data->Kind == V_TEXT) continue; cdata = new TVecData(MainImageForm->Number); cdata->Copy(data); cdata->First.x += movx; cdata->First.y += movy; cdata->Second.x += movx; cdata->Second.y += movy; if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int i = 0; i < data->nCount * 3 + 1; i++) { cdata->pList[i].x += movx; cdata->pList[i].y += movy; } } // cdata->GroupIndex = 1<GroupIndex = index; DataList->Add(cdata); UndoSave(VU_CREATE, DataList->Count - 1, sw); sw = false; } sw2 = ((Lex - Cux) * (Lex - Cux) + (Ley - Cuy) * (Ley - Cuy)) > SpreadGap * SpreadGap ? true : false; dx = SpreadGap / sqrt(1 + tangent * tangent); dy = dx * tangent; if (Lex == Cux && Ley != Cuy) { Ley = Cuy > Ley ? Ley + SpreadGap : Ley - SpreadGap; } else if (Lex != Cux && Ley == Cuy) { Lex = Cux > Lex ? Lex + SpreadGap : Lex - SpreadGap; } else if (Lex != Cux && Ley != Cuy) { if (Cux > Lex) { Lex += dx; Ley += dy; } else { Lex -= dx; Ley -= dy; } } else return; } if (CopyList) { for (int i = 0; i < CopyList->Count; i++) { cdata = (TVecData*)CopyList->Items[i]; if (cdata) delete cdata; cdata = NULL; } CopyList->Clear(); } } // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // Mouse Handling Part // --------------------------------------------------------------------------- void __fastcall TVecDraw::TextBoxOnMouseMove(int X, int Y) { int mouseCursor = 0; if (ExistAnyTextBox(X, Y) >= 0) mouseCursor = 1; switch(mouseCursor) { // Ä¿¼­ÀÇ À§Ä¡¿¡ µû¸¥ Ä¿¼­ ¸ð¾ç º¯È­ case 0: MainImageForm->iMainImage->Cursor = crDefault; break; case 1: MainImageForm->iMainImage->Cursor = crIBeam; break; } } // --------------------------------------------------------------------------- void __fastcall TVecDraw::OnMouseMove(int X, int Y) { TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) int FirstX, FirstY, SecondX, SecondY; nSelPos = 0; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->Kind == V_TEXTBOX) { // by maxleo21c (04.10.22) if (CursorInTextBox(X, Y, data)) { nSelPos = 5; break; } } else { if (data->Kind == V_TEXT) { FirstY = min(data->First.y, data->Second.y); SecondY = max(data->First.y, data->Second.y); FirstX = min(data->First.x, data->Second.x); SecondX = max(data->First.x, data->Second.x); } else { FirstX = data->First.x - data->PenThick; FirstY = data->First.y - data->PenThick; SecondX = data->Second.x + data->PenThick; SecondY = data->Second.y + data->PenThick; } if (X < FirstX || X > SecondX || Y < FirstY || Y > SecondY) continue; if (data->Kind == V_LINE || data->Kind == V_CURVE) { if (PointOnCurvePath(data, X, Y) >= 0) { nSelPos = 5; break; } } else { nSelPos = 5; break; } // ¿µ¿ª ¾È¿¡¸¸ À־ À̵¿ °¡´É if (data->Kind == V_LINE || data->Kind == V_CURVE) continue; // Line°ú curve´Â ¸ð¼­¸®Á¡ Ŭ¸¯ ¾ø´Ù if (abs(X - data->First.x) < 3 && abs(Y - data->First.y) < 3) { nSelPos = 1; break; } if (abs(X - data->Second.x) < 3 && abs(Y - data->First.y) < 3) { nSelPos = 2; break; } if (abs(X - data->First.x) < 3 && abs(Y - data->Second.y) < 3) { nSelPos = 3; break; } if (abs(X - data->Second.x) < 3 && abs(Y - data->Second.y) < 3) { nSelPos = 4; break; } if (abs(X - (data->First.x + data->Second.x) / 2) < 3 && abs (Y - (data->First.y + data->Second.y) / 2) < 3) { nSelPos = 5; break; } } } switch(nSelPos) { // Ä¿¼­ÀÇ À§Ä¡¿¡ µû¸¥ Ä¿¼­ ¸ð¾ç º¯È­ case 1: case 4: MainImageForm->iMainImage->Cursor = crSizeNWSE; break; case 2: case 3: MainImageForm->iMainImage->Cursor = crSizeNESW; break; case 5: MainImageForm->iMainImage->Cursor = crSizeAll; break; case 0: MainImageForm->iMainImage->Cursor = crDefault; break; } } // --------------------------------------------------------------------------- void __fastcall TVecDraw::OnMousePointMove(int X, int Y) { TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) nSelPos = 0; DRECT rc; double rg; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->Kind != V_LINE && data->Kind != V_CURVE) continue; // Line°ú curve¿¡¼­¸¸ Point Edit °¡´É // rg = data->PenThick > 3 ? 3 : 2; // rc = Rect(X-rg, Y-rg, X+rg, Y+rg); // ±ÙÁ¢Á¡ ã±âÀÇ Á¤È®µµ¸¦ ³ôÀ̱â À§ÇØ - by monkman (2007.10.05) rg = (double)(3 * MainImageForm->iMainImage->ZoomOut) / MainImageForm->iMainImage->ZoomIn; rc.DRect(MainImageForm->iMainImage->RealPosX - rg, MainImageForm->iMainImage->RealPosY - rg, MainImageForm->iMainImage->RealPosX + rg, MainImageForm->iMainImage->RealPosY + rg); if (PointOnCurvePath(data, X, Y) >= 0) { nSelPos = 5; } for (int i = 0; i < data->nCount * 3 + 1; i++) { if (rc.DPtInRect(data->pList[i].x, data->pList[i].y)) { nSelPos = 10; // Á¡À§¿¡ ÀÖ°ÔµÇ¸é °ªÀº 10ÀÌ´Ù ptNumber = i; if (ptNumber % 3 == 0) goto next; // Á¶ÀýÁ¡ º¸´Ù´Â ½ÇÁ¦ Á¡ÀÌ ¿ì¼±Çϵµ·Ï ÇÑ´Ù } } if (nSelPos) break; } next: switch(nSelPos) { // Ä¿¼­ÀÇ À§Ä¡¿¡ µû¸¥ Ä¿¼­ ¸ð¾ç º¯È­ case 10: MainImageForm->iMainImage->Cursor = crDrag; break; case 0: MainImageForm->iMainImage->Cursor = crDefault; break; } } // --------------------------------------------------------------------------- void __fastcall TVecDraw::OnArrowKeyObjectMove(int MoveX, int MoveY) { // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹æÇâŰ·Î Obect ¹Ì¼¼ À̵¿ - by monkman (2005.02.21) TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) RECT rc = Rect(MaxInt, MaxInt, 0, 0), TextBoxRC; bool sw = true; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->ListOfAllLine && data->ListOfAllLine->CurveData) { MakeTextBoxPointList(data); // by linuxjun for Undo continue; } // À̵¿ Àü ¿µ¿ª int plusRange = data->PenThick*2; if (data->ArrowCap){ plusRange = data->PenThick*data->ArrowCap->LineCapWidthScale*(data->ArrowCap->LineCapWidth + 1)/2; } rc.left = min(rc.left, (data->First.x - plusRange) - 5); rc.top = min(rc.top, (data->First.y - plusRange) - 5); rc.right = max(rc.right, (data->Second.x + plusRange) + 5); rc.bottom = max(rc.bottom, (data->Second.y + plusRange) + 5); if (data->Kind == V_TEXTBOX) { UndoSave(VU_TEXTMODIFY, i, sw); // by linuxjun for Undo sw = false; // by linuxjun for Undo data->StartPoint.x += MoveX; data->StartPoint.y += MoveY; for (int i = 0; i < 5; i++) { data->pList[i].x += MoveX; data->pList[i].y += MoveY; } data->CenterPoint.x += MoveX; data->CenterPoint.y += MoveY; data->First.x = data->First.x + MoveX; data->First.y = data->First.y + MoveY; data->Second.x = data->Second.x + MoveX; data->Second.y = data->Second.y + MoveY; // È®½ÇÇÏ°Ô È®ÀÎÇϱâ À§Çؼ­ ½ÇÇà MakeTextBoxPointList(data); // ¼±ÅÃµÈ ¿ÀºêÁ§Æ®µéÀÇ ¿µ¿ª¸¸Å­¸¸ RectPaintÇϱâ À§ÇØ.. GetRectForMouseMove(data, TextBoxRC); // ½ÇÁ¦ ¿µ¿ªº¸´Ù Á¶±Ý Å©°Ô Àâ¾ÆÁÖ¾î¾ßÇÑ´Ù TextBoxRC.left -= 20; TextBoxRC.top -= 20; TextBoxRC.right += 20; TextBoxRC.bottom += 20; rc.left = min(rc.left, TextBoxRC.left); rc.top = min(rc.top, TextBoxRC.top); rc.right = max(rc.right, TextBoxRC.right); rc.bottom = max(rc.bottom, TextBoxRC.bottom); } else { UndoSave(VU_MODIFY, i, sw); // by linuxjun for Undo sw = false; // by linuxjun for Undo 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++) { data->pList[i].x += MoveX; data->pList[i].y += MoveY; // ¼±ÅÃµÈ ¿ÀºêÁ§Æ®µéÀÇ ¿µ¿ª¸¸Å­¸¸ RectPaintÇϱâ À§ÇØ.. data->First.x = min(data->First.x, data->pList[i].x); data->First.y = min(data->First.y, data->pList[i].y); data->Second.x = max(data->Second.x, data->pList[i].x); data->Second.y = max(data->Second.y, data->pList[i].y); } // À̵¿ ÈÄ ¿µ¿ª rc.left = min(rc.left, (data->First.x - plusRange) - 5); rc.top = min(rc.top, (data->First.y - plusRange) - 5); rc.right = max(rc.right, (data->Second.x + plusRange) + 5); rc.bottom = max(rc.bottom, (data->Second.y + plusRange) + 5); } } // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - ¹ÝÀü °Å¿ïÀÇ º¤ÅÍ ¿µ¿ªÀ» °°ÀÌ ±¸ÇÑ´Ù - by monkman(2005.03.16) if (NVector->bVectorReflectionMode) { GetRealAndReflectionRect(&rc); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- MainImageForm->iMainImage->RectPaint(rc); } // --------------------------------------------------------------------------- void __fastcall TVecDraw::OnArrowKeyPointMove(int MoveX, int MoveY, bool bControlPoint) { // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹æÇâŰ·Î Point ¹Ì¼¼ À̵¿ - by monkman (2005.01.31) // bControlPoint°¡ trueÀ̸é Á¶ÀýÁ¡µµ °°ÀÌ À̵¿ TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) RECT rc = Rect(MaxInt, MaxInt, 0, 0), TextBoxRC; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (data->ParentTextBox || (data->ListOfAllLine && data->ListOfAllLine->CurveData)) continue; // À̵¿ Àü ¿µ¿ª int plusRange = data->PenThick*2; if (data->ArrowCap){ plusRange = data->PenThick*data->ArrowCap->LineCapWidthScale*(data->ArrowCap->LineCapWidth + 1)/2; } rc.left = min(rc.left, (data->First.x - plusRange) - 5); // ¼±ÅÃµÈ ¿ÀºêÁ§Æ®µéÀÇ ¿µ¿ª¸¸Å­¸¸ RectPaintÇϱâ À§ÇØ.. rc.top = min(rc.top, (data->First.y - plusRange) - 5); rc.right = max(rc.right, (data->Second.x + plusRange) + 5); rc.bottom = max(rc.bottom, (data->Second.y + plusRange) + 5); if (data->Kind == V_TEXTBOX && data->bSelected) { if (data->pMask[0] == 0x09) { data->StartPoint.x += MoveX; data->StartPoint.y += MoveY; for (int i = 0; i < 5; i++) { data->pList[i].x += MoveX; data->pList[i].y += MoveY; } data->CenterPoint.x += MoveX; data->CenterPoint.y += MoveY; data->First.x = data->First.x + MoveX; data->First.y = data->First.y + MoveY; data->Second.x = data->Second.x + MoveX; data->Second.y = data->Second.y + MoveY; // È®½ÇÇÏ°Ô È®ÀÎÇϱâ À§Çؼ­ ½ÇÇà MakeTextBoxPointList(data); // ¼±ÅÃµÈ ¿ÀºêÁ§Æ®µéÀÇ ¿µ¿ª¸¸Å­¸¸ RectPaintÇϱâ À§ÇØ.. GetRectForMouseMove(data, TextBoxRC); // ½ÇÁ¦ ¿µ¿ªº¸´Ù Á¶±Ý Å©°Ô Àâ¾ÆÁÖ¾î¾ßÇÑ´Ù TextBoxRC.left -= 20; TextBoxRC.top -= 20; TextBoxRC.right += 20; TextBoxRC.bottom += 20; rc.left = min(rc.left, TextBoxRC.left); rc.top = min(rc.top, TextBoxRC.top); rc.right = max(rc.right, TextBoxRC.right); rc.bottom = max(rc.bottom, TextBoxRC.bottom); } } else { if (data->bSelected) { 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->pMask[i / 8] >> i % 8) & 0x01) { // ¼±ÅÃµÈ Æ÷ÀÎÆ®Àΰ¡? if (bControlPoint) { // Á¶ÀýÁ¡µµ À̵¿ÇÒ °æ¿ì if (i != 0) { data->pList[i - 1].x += MoveX; data->pList[i - 1].y += MoveY; } if (i != data->nCount * 3) { data->pList[i + 1].x += MoveX; data->pList[i + 1].y += MoveY; } } data->pList[i].x += MoveX; // ¼±ÅÃµÈ Á¡¸¸ À̵¿ÇÒ °æ¿ì data->pList[i].y += MoveY; } // ¼±ÅÃµÈ ¿ÀºêÁ§Æ®µéÀÇ ¿µ¿ª¸¸Å­¸¸ RectPaintÇϱâ À§ÇØ.. data->First.x = min(data->First.x, data->pList[i].x); data->First.y = min(data->First.y, data->pList[i].y); data->Second.x = max(data->Second.x, data->pList[i].x); data->Second.y = max(data->Second.y, data->pList[i].y); } } // À̵¿ ÈÄ ¿µ¿ª rc.left = min(rc.left, (data->First.x - plusRange) - 5); // ¼±ÅÃµÈ ¿ÀºêÁ§Æ®µéÀÇ ¿µ¿ª¸¸Å­¸¸ RectPaintÇϱâ À§ÇØ.. rc.top = min(rc.top, (data->First.y - plusRange) - 5); rc.right = max(rc.right, (data->Second.x + plusRange) + 5); rc.bottom = max(rc.bottom, (data->Second.y + plusRange) + 5); } } // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - ¹ÝÀü °Å¿ïÀÇ º¤ÅÍ ¿µ¿ªÀ» °°ÀÌ ±¸ÇÑ´Ù - by monkman(2005.03.16) if (NVector->bVectorReflectionMode) { GetRealAndReflectionRect(&rc); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- MainImageForm->iMainImage->RectPaint(rc); } // --------------------------------------------------------------------------- bool __fastcall TVecDraw::OnMouseDrawMove(int X, int Y) { TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) nSelPos = 0; RECT rc; int rg; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (data->Kind != V_LINE && data->Kind != V_CURVE) continue; // Line°ú curve¿¡¼­¸¸ Point Edit °¡´É if (data->bClosed) continue; rg = (data->PenThick > 5) ? 5 : (data->PenThick); if (rg == 0) rg = 1; rc = Rect(X - rg, Y - rg, X + rg, Y + rg); if (PtInRect(&rc, data->pList[0].P())) { nSelPos = 10; // Á¡À§¿¡ ÀÖ°ÔµÇ¸é °ªÀº 10ÀÌ´Ù NVector->bExtendFirst = true; Index = i; goto success; } else if (PtInRect(&rc, data->pList[data->nCount * 3].P())) { nSelPos = 10; // Á¡À§¿¡ ÀÖ°ÔµÇ¸é °ªÀº 10ÀÌ´Ù NVector->bExtendFirst = false; Index = i; goto success; } } MainImageForm->iMainImage->Cursor = crDefault; return false; success: MainImageForm->iMainImage->Cursor = crDrag; return true; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::OnMouseDrag(int &Lsx, int &Lsy, int X, int Y) { TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) RECT rtCur, rtUnion, rect; // RECT rc, rc2 = Rect(MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height, 0, 0); int nMaxThick = 0; bool bFirst = true; int MoveX = X - Lsx; int MoveY = Y - Lsy; Lsx = X; Lsy = Y; bool sw = true; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (NVector->bUndosw && (MoveX || MoveY)) { // -->by linuxjun for CurvedVectorText 7¿ù¸» if (data->ListOfAllLine && data->ListOfAllLine->CurveData) { continue; // <--by linuxjun for CurvedVectorText 7¿ù¸» } else { UndoSave(VU_MODIFY, i, sw); } } sw = false; // ÀÌÀü Rect¸¦ ÀúÀåÇÑ´Ù - by monkman (2009.05.06) rtCur = Rect(data->First.x - data->PenThick / 2, data->First.y - data->PenThick / 2, data->Second.x + data->PenThick / 2, data->Second.y + data->PenThick / 2); if (bFirst) { rtUnion = rtCur; bFirst = false; } else { UnionRect(&rtUnion, &rtUnion, &rtCur); } data->First.x += MoveX; data->First.y += MoveY; data->Second.x += MoveX; data->Second.y += MoveY; switch(data->Kind) { case V_LINE: for (int i = 0; i < data->nCount + 1; i++) { data->pList[i].x += MoveX; data->pList[i].y += MoveY; } break; case V_CURVE: for (int i = 0; i < data->nCount * 3 + 1; i++) { data->pList[i].x += MoveX; data->pList[i].y += MoveY; } break; case V_TEXTBOX: // by maxleo21c (04.10.19) data->StartPoint.x += MoveX; data->StartPoint.y += MoveY; for (int i = 0; i < 5; i++) { data->pList[i].x += MoveX; data->pList[i].y += MoveY; } data->CenterPoint.x += MoveX; data->CenterPoint.y += MoveY; break; default: break; } // rtUnion¸¦ »ç¿ëÇÏ¿© ÄÚµå Á¤¸® - by monkman (2009.05.07) /* // TextBox¿¡¼­´Â SET_RECT¸¦ ¾²¸é ¾ÈµÇ´Âµ¥ À߸ø »ç¿ëÇØ¼­ ÁÖ¼®À¸·Î ¸·°í º¯°æ // by maxleo21c (06.06.17) if ((data->Kind == V_TEXTBOX && data->ParentTextBox) || data->Kind != V_TEXTBOX) { SET_RECT_ORIGIN; } if (data->Kind == V_CURVE) { POINT Temp1, Temp2; Temp1.x = 19999; Temp1.y = 19999; Temp2.x = 0; Temp2.y = 0; for (int i = 0; i < data->nCount*3+1; i++) { if (Temp1.x > data->pList[i].x) Temp1.x = data->pList[i].x; if (Temp1.y > data->pList[i].y) Temp1.y = data->pList[i].y; if (Temp2.x < data->pList[i].x) Temp2.x = data->pList[i].x; if (Temp2.y < data->pList[i].y) Temp2.y = data->pList[i].y; } rc.top = MoveY > 0 ? Temp1.y - MoveY - data->PenThick - 5: Temp1.y - data->PenThick - 5; rc.bottom = MoveY > 0 ? Temp2.y + data->PenThick + 5: Temp2.y - MoveY + data->PenThick + 5; rc.left = MoveX > 0 ? Temp1.x - MoveX - data->PenThick - 5: Temp1.x - data->PenThick - 5; rc.right = MoveX > 0 ? Temp2.x + data->PenThick + 5: Temp2.x - MoveX + data->PenThick + 5; } else if (data->Kind == V_TEXT) { POINT fst,snd; fst.x = min(data->First.x, data->Second.x) - data->Font.lfHeight; fst.y = min(data->First.y, data->Second.y) - data->Font.lfHeight; snd.x = max(data->First.x, data->Second.x) + data->Font.lfHeight; snd.y = max(data->First.y, data->Second.y) + data->Font.lfHeight; rc.top = MoveY > 0 ? fst.y - MoveY : fst.y; rc.bottom = MoveY > 0 ? snd.y : snd.y - MoveY; rc.left = MoveX > 0 ? fst.x - MoveX : fst.x; rc.right = MoveX > 0 ? snd.x : snd.x - MoveX; }else if (data->Kind == V_TEXTBOX) { // by maxleo21c (04.10.19) MakeTextBoxPointList(data); // È®½ÇÇÏ°Ô È®ÀÎÇϱâ À§Çؼ­ ½ÇÇà GetRectForMouseMove(data, rect); rc.top = (MoveY > 0 ? rect.top - MoveY : rect.top) - 20; rc.bottom = (MoveY > 0 ? rect.bottom : rect.bottom - MoveY) + 20; rc.left = (MoveX > 0 ? rect.left - MoveX : rect.left) - 20; rc.right = (MoveX > 0 ? rect.right : rect.right - MoveX) + 20; } else { rc.top = MoveY > 0 ? data->First.y - MoveY - data->PenThick - 20: data->First.y - data->PenThick - 20; rc.bottom = MoveY > 0 ? data->Second.y + data->PenThick + 20: data->Second.y - MoveY + data->PenThick + 20; rc.left = MoveX > 0 ? data->First.x - MoveX - data->PenThick - 20: data->First.x - data->PenThick - 20; rc.right = MoveX > 0 ? data->Second.x + data->PenThick + 20: data->Second.x - MoveX + data->PenThick + 20; } //-->by linuxjun for CurvedVectorText if(data->ParentTextBox) { MakeTextBoxPointList(data->ParentTextBox); GetRectForMouseMove(data->ParentTextBox, rect);//by david 090506 Rect°è»ê Ãß°¡ rc.top = rc.top < rect.top ? rc.top : rect.top; rc.bottom = rc.bottom > rect.bottom ? rc.bottom : rect.bottom; rc.left = rc.left < rect.left ? rc.left : rect.left; rc.right = rc.right > rect.right ? rc.right : rect.right; } //<--by linuxjun for CurvedVectorText if (data->bMotive) {//by david 090506 Rect°è»ê Ãß°¡ GetRectForMouseMove(data, rect); rc.top = rc.top - rect.Height()/2; rc.left = rc.left - rect.Width()/2; rc.bottom = rc.bottom + rect.Height()/2; rc.right = rc.right + rect.Width()/2; } rc2.top = min(rc2.top, rc.top); // ÃÖÀûÀÇ »ç°¢Çü ¸¸µé±â (ÇѹøÀÇ rectpaint¸¸ Çϵµ·Ï) rc2.bottom = max(rc2.bottom, rc.bottom); rc2.left = min(rc2.left, rc.left); rc2.right = max(rc2.right, rc.right); */ // -->by linuxjun for CurvedVectorText if (data->ParentTextBox) { MakeTextBoxPointList(data->ParentTextBox); GetRectForMouseMove(data->ParentTextBox, rect); UnionRect(&rtUnion, &rtUnion, &rect); } // <--by linuxjun for CurvedVectorText if (data->bMotive) { GetRectForMouseMove(data, rect); rtUnion.top = rtUnion.top - (rect.bottom - rect.top) / 2; rtUnion.left = rtUnion.left - (rect.right - rect.left) / 2; rtUnion.bottom = rtUnion.bottom + (rect.bottom - rect.top) / 2; rtUnion.right = rtUnion.right + (rect.right - rect.left) / 2; } if (data->Kind == V_TEXTBOX) { // rtUnionÀ» ó¸®Çϸ鼭 TextBox¿¡ ´ëÇØ¼­´Â Ãß°¡ÇÏÁö ¾Ê¾Æ ´Ù½Ã Ãß°¡ Çß´Ù. // TextBox´Â First, Second¸¦ °¡Áö°í Rect¸¦ ±¸ÇÏÁö ¾Ê°í 5°³ÀÇ Point·Î Rect¸¦ // ±¸ÇØ¾ß ÇÑ´Ù. µû¶ó¼­ ÀÏ¹Ý Object¿Í °°Àº ¹æ½ÄÀ¸·Î ó¸®ÇÏ¸é ¾ÈµÈ´Ù. by david 100503 MakeTextBoxPointList(data); GetRectForMouseMove(data, rect); rect.top = (MoveY > 0 ? rect.top - MoveY : rect.top); rect.bottom = (MoveY > 0 ? rect.bottom : rect.bottom - MoveY); rect.left = (MoveX > 0 ? rect.left - MoveX : rect.left); rect.right = (MoveX > 0 ? rect.right : rect.right - MoveX); UnionRect(&rtUnion, &rtUnion, &rect); // rtUnion.top = (MoveY > 0 ? rect.top - MoveY : rect.top) - 20; // rtUnion.bottom = (MoveY > 0 ? rect.bottom : rect.bottom - MoveY) + 20; // rtUnion.left = (MoveX > 0 ? rect.left - MoveX : rect.left) - 20; // rtUnion.right = (MoveX > 0 ? rect.right : rect.right - MoveX) + 20; } // ÇöÀç Rect¸¦ ÀúÀåÇÑ´Ù - by monkman (2009.05.06) // rtCur = Rect(data->First.x, data->First.y, data->Second.x, data->Second.y); rtCur = Rect(data->First.x - data->PenThick / 2, data->First.y - data->PenThick / 2, data->Second.x + data->PenThick / 2, data->Second.y + data->PenThick / 2); UnionRect(&rtUnion, &rtUnion, &rtCur); int plusRange = data->PenThick + 1; if (data->ArrowCap){ plusRange = data->PenThick*data->ArrowCap->LineCapWidthScale*(data->ArrowCap->LineCapWidth + 1)/2; } nMaxThick = max(nMaxThick, plusRange); } // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - ¹ÝÀü °Å¿ïÀÇ º¤ÅÍ ¿µ¿ªÀ» °°ÀÌ ±¸ÇÑ´Ù - by monkman(2005.03.16) if (NVector->bVectorReflectionMode) { // GetRealAndReflectionRect(&rc2); GetRealAndReflectionRect(&rtUnion); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // rtUnion¸¦ »ç¿ëÇÏ¿© ÄÚµå Á¤¸® - by monkman (2009.05.07) /* // ĵ¹ö½ºÀÇ ¹üÀ§¸¦ ³ÑÁö ¾Êµµ·Ï ¼öÁ¤ - by monkman (2004.10.01) if (rc2.left < 0) rc2.left = 0; if (rc2.top < 0) rc2.top = 0; if (rc2.right > MainImageForm->iMainImage->uBitmap->Width) rc2.right = MainImageForm->iMainImage->uBitmap->Width; if (rc2.bottom > MainImageForm->iMainImage->uBitmap->Height) rc2.bottom = MainImageForm->iMainImage->uBitmap->Height; */ // 10Àº Margin rtUnion.left -= (nMaxThick + 10); rtUnion.top -= (nMaxThick + 10); rtUnion.right += (nMaxThick + 10); rtUnion.bottom += (nMaxThick + 10); if (rtUnion.left < 0) rtUnion.left = 0; if (rtUnion.top < 0) rtUnion.top = 0; if (rtUnion.right > MainImageForm->iMainImage->uBitmap->Width) rtUnion.right = MainImageForm->iMainImage->uBitmap->Width; if (rtUnion.bottom > MainImageForm->iMainImage->uBitmap->Height) rtUnion.bottom = MainImageForm->iMainImage->uBitmap->Height; NVector->bSelectedVectorMove = true; NVector->bVectorMove = true; MainImageForm->iMainImage->bVectorModify = true; MainImageForm->iMainImage->RectPaint(rtUnion); if (MoveX || MoveY) NVector->bUndosw = false; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::OnMousePointDrag(int &Lsx, int &Lsy, int X, int Y, TShiftState Shift) { TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) // ¸¶¿ì½º ¿À¸¥ÂÊ ¹öư ´­·¶À»¶§ ¶ß´Â ÆË¾÷ ¸Þ´º¿¡¼­ ReverseCopy¸¦ ¸·À½ - by monkman (2004.11.09) bool bReverseCopy; RECT rc1, rc2, rc3; double MoveX = X - Lsx; double MoveY = Y - Lsy; double TempMoveX, TempMoveY; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¼±ÅÃµÈ ¿ÀºêÁ§Æ®ÀÇ Æ÷ÀÎÆ®¸¦ À̵¿ÇÒ¶§ ´Ù¸¥ ¿ÀºêÁ§Æ®ÀÇ Æ÷ÀÎÆ®µµ ÇÔ²² ¼±ÅõǾîÀÖ´Ù¸é ÇÔ²² À̵¿ÇÑ´Ù - by monkman (2005.03.25) // RECT ÃʱâÈ­ bool bMultiSelected = true; // (Shift.Contains(ssAlt) || Shift.Contains(ssShift)); rc1 = Rect(MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height, 0, 0); rc3 = rc2 = rc1; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Lsx = X; Lsy = Y; bReverseCopy = true; bool bSelectedPoint = false; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; data->bModified = true; // PatternFill µî¿¡¼­´Â modify°¡ ³¡³ª°í Çѹø¿¡ ¼öÁ¤ÇØ¾ß ÇÏ´Ï ¿É¼ÇÀ» µÐ´Ù if (NVector->bUndosw && (MoveX || MoveY)) UndoSave(VU_MODIFY, i); if (data->Kind == V_LINE || data->Kind == V_CURVE) { for (int j = 0; j < data->nCount * 3 + 1; j++) { if (((data->pMask[j / 8] >> j % 8) & 0x01)) { // 2009 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï¿¡¼­ ùÁ¡°ú ³¡Á¡ÀÌ ¿¬°áµÇ´Â °ÍÀÎÁö üũ - by monkman (2009.11.27) // ùÁ¡°ú ³¡Á¡ÀÏ °æ¿ì¸¸ À̵¿ ½ÃÅ´ // ¼öÁ÷ ±âÁؼ± if (j == 0 || j == data->nCount * 3) { if (bJKeyState && NVector->bVectorReflectionMode && NVector->ReflectionVH == 1 && X - 5 <= NVector->ReflectionVIndex && NVector->ReflectionVIndex <= X + 5 && data->pList[j].x - 5 <= NVector->ReflectionVIndex && NVector->ReflectionVIndex <= data->pList[j].x + 5) { TempMoveX = NVector->ReflectionVIndex - data->pList[j].x; TempMoveY = MoveY; } // ¼öÆò ±âÁؼ± else if (bJKeyState && NVector->bVectorReflectionMode && NVector->ReflectionVH == 2 && Y - 5 <= NVector->ReflectionHIndex && NVector->ReflectionHIndex <= Y + 5 && data->pList[j].y - 5 <= NVector->ReflectionHIndex && NVector->ReflectionHIndex <= data->pList[j].y + 5) { TempMoveX = MoveX; TempMoveY = NVector->ReflectionHIndex - data->pList[j].y; } else { TempMoveX = MoveX; TempMoveY = MoveY; } } else { TempMoveX = MoveX; TempMoveY = MoveY; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- data->pList[j].x += TempMoveX; data->pList[j].y += TempMoveY; switch(j % 3) { double vx, vy, d; case 0: if (j == 0) { if (data->bClosed) { // closed path¿¡¼­ÀÇ Ã³¸® data->pList[data->nCount * 3 - 1].x += TempMoveX; data->pList[data->nCount * 3 - 1].y += TempMoveY; data->pList[data->nCount * 3] = data->pList[j]; } data->pList[j + 1].x += TempMoveX; data->pList[j + 1].y += TempMoveY; } else if (j == data->nCount * 3) { if (data->bClosed) { } else { data->pList[j - 1].x += TempMoveX; data->pList[j - 1].y += TempMoveY; } } else { data->pList[j - 1].x += TempMoveX; data->pList[j - 1].y += TempMoveY; data->pList[j + 1].x += TempMoveX; data->pList[j + 1].y += TempMoveY; } break; case 1: vx = data->pList[j].x - data->pList[j - 1].x; vy = data->pList[j].y - data->pList[j - 1].y; d = sqrt(vx * vx + vy * vy); if (d == 0) break; vx = vx / d * (-1); vy = vy / d * (-1); if (j == 1) { d = sqrt(pow(data->pList[data->nCount * 3 - 1].x - data->pList[j - 1] .x, 2) + pow(data->pList[data->nCount * 3 - 1].y - data->pList [j - 1].y, 2)); if (data->bClosed) { // closed path¿¡¼­ÀÇ Ã³¸® data->pList[data->nCount * 3 - 1].x = data->pList[j - 1] .x + vx * d; data->pList[data->nCount * 3 - 1].y = data->pList[j - 1] .y + vy * d; } } else { d = sqrt(pow(data->pList[j - 2].x - data->pList[j - 1].x, 2) + pow(data->pList[j - 2].y - data->pList[j - 1].y, 2)); data->pList[j - 2].x = data->pList[j - 1].x + vx * d; data->pList[j - 2].y = data->pList[j - 1].y + vy * d; } break; case 2: if (j == data->nCount * 3 - 1) { vx = data->pList[j].x - data->pList[0].x; vy = data->pList[j].y - data->pList[0].y; d = sqrt(vx * vx + vy * vy); if (d == 0) break; vx = vx / d * (-1); vy = vy / d * (-1); d = sqrt(pow(data->pList[1].x - data->pList[0].x, 2) + pow(data->pList[1].y - data->pList[0].y, 2)); if (data->bClosed) { // closed path¿¡¼­ÀÇ Ã³¸® data->pList[1].x = data->pList[0].x + vx * d; data->pList[1].y = data->pList[0].y + vy * d; } } else { vx = data->pList[j].x - data->pList[j + 1].x; vy = data->pList[j].y - data->pList[j + 1].y; d = sqrt(vx * vx + vy * vy); if (d == 0) break; vx = vx / d * (-1); vy = vy / d * (-1); d = sqrt(pow(data->pList[j + 2].x - data->pList[j + 1].x, 2) + pow(data->pList[j + 2].y - data->pList[j + 1].y, 2)); data->pList[j + 2].x = data->pList[j + 1].x + vx * d; data->pList[j + 2].y = data->pList[j + 1].y + vy * d; } break; } bSelectedPoint = true; } } // 2009 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É - 'J'۸¦ ´­·¶À» ¶§ ùÁ¡ÀÌ ¹ÝÀü ±âÁؼ±¿¡ ´Þ¶ó ºÙµµ·Ï ÇÑ´Ù - by monkman (2009.11.27) if (bJKeyState && ((NVector->ReflectionVH == 1 && data->pList[0] .x == NVector->ReflectionVIndex) || (NVector->ReflectionVH == 2 && data->pList[0] .y == NVector->ReflectionHIndex))) { data->bFirstJoin = true; bJoinState = false; // ´Ù½Ã ÃʱâÈ­½ÃÄÑÁØ´Ù } else if (data->bFirstJoin && ((NVector->ReflectionVH == 1 && data->pList[0] .x == NVector->ReflectionVIndex) || (NVector->ReflectionVH == 2 && data->pList[0] .y == NVector->ReflectionHIndex))) {; // Skip } else { data->bFirstJoin = false; bJoinState = false; } if (bJKeyState && ((NVector->ReflectionVH == 1 && data->pList[data->nCount * 3] .x == NVector->ReflectionVIndex) || (NVector->ReflectionVH == 2 && data->pList [data->nCount * 3].y == NVector->ReflectionHIndex))) { data->bLastJoin = true; bJoinState = false; // ´Ù½Ã ÃʱâÈ­½ÃÄÑÁØ´Ù } else if (data->bLastJoin && ((NVector->ReflectionVH == 1 && data->pList[data->nCount * 3] .x == NVector->ReflectionVIndex) || (NVector->ReflectionVH == 2 && data->pList [data->nCount * 3].y == NVector->ReflectionHIndex))) {; // Skip } else { data->bLastJoin = false; bJoinState = false; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü º¹»ç ¸øÇϵµ·Ï ¸·À½ - by monkman (2009.05.11) if (data->ParentTextBox) { bReverseCopy = false; } } else if (data->Kind == V_TEXTBOX) { // todo : ¹®Á¦°¡ À־ ¾ÆÁ÷Àº »ç¿ëÇÏÁö ¾Ê´Â´Ù ³ªÁß¿¡ ¼öÁ¤Çؼ­ »ç¿ëÇØ¾ßÇÒ µí.. - by monkman (2005.06.22) // if (data->bSelected) { // data->StartPoint.x += MoveX; // data->StartPoint.y += MoveY; // for (int i = 0; i < 5; i++) { // data->pList[i].x += MoveX; // data->pList[i].y += MoveY; // } // data->CenterPoint.x += MoveX; // data->CenterPoint.y += MoveY; // // data->First.x = data->First.x + MoveX; // data->First.y = data->First.y + MoveY; // data->Second.x = data->Second.x + MoveX; // data->Second.y = data->Second.y + MoveY; // // // È®½ÇÇÏ°Ô È®ÀÎÇϱâ À§Çؼ­ ½ÇÇà // MakeTextBoxPointList(data); // GetRectForMouseMove(data, rc1); // } // goto next; // ¹ÝÀü º¹»ç ¸øÇϵµ·Ï ¸·À½ - by monkman (2009.05.11) bReverseCopy = false; } // data->pList[ptNumber].x += MoveX; // data->pList[ptNumber].y += MoveY; // ============ Point Drag·Î Alt ´©¸£°í Closed path ¸¸µé±â if (ptNumber == data->nCount * 3 && Shift.Contains(ssAlt) && !data->bClosed) { RECT rt = Rect(X - 3, Y - 3, X + 3, Y + 3); if (PtInRect(&rt, data->pList[0].P())) { data->bClosed = true; data->pList[data->nCount * 3 - 1].x += data->pList[0].x - data->pList [data->nCount * 3].x; data->pList[data->nCount * 3 - 1].y += data->pList[0].y - data->pList [data->nCount * 3].y; ptNumber = 0; MoveX = 0; MoveY = 0; } } else if (ptNumber == 0 && Shift.Contains(ssAlt) && !data->bClosed) { RECT rt = Rect(X - 3, Y - 3, X + 3, Y + 3); if (PtInRect(&rt, data->pList[data->nCount * 3].P())) { data->bClosed = true; data->pList[data->nCount * 3 - 1].x += data->pList[0].x - data->pList [data->nCount * 3].x; data->pList[data->nCount * 3 - 1].y += data->pList[0].y - data->pList [data->nCount * 3].y; ptNumber = 0; MoveX = 0; MoveY = 0; } } // ============ /* if (ptNumber == data->nCount*3 && !data->bClosed) { RECT rt = Rect(X-3, Y-3, X+3, Y+3); if (PtInRect(&rt, data->pList[0])) { MainImageForm->iMainImage->Cursor = crHandPoint; Application->ProcessMessages(); // MoveX = 0; MoveY = 0; } }else if (ptNumber == 0 && !data->bClosed) { RECT rt = Rect(X-3, Y-3, X+3, Y+3); if (PtInRect(&rt, data->pList[data->nCount*3])) { MainImageForm->iMainImage->Cursor = crHandPoint; Application->ProcessMessages(); // MoveX = 0; MoveY = 0; } } */ ///////////////////////»õ·Î¿î ¹æ½Ä // -->by linuxjun for CurvedVectorText if (data->ParentTextBox) { MakeTextBoxPointList(data->ParentTextBox); } // <--by linuxjun for CurvedVectorText next: // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¼±ÅÃµÈ ¿ÀºêÁ§Æ®ÀÇ Æ÷ÀÎÆ®¸¦ À̵¿ÇÒ¶§ ´Ù¸¥ ¿ÀºêÁ§Æ®ÀÇ Æ÷ÀÎÆ®µµ ÇÔ²² ¼±ÅõǾîÀÖ´Ù¸é ÇÔ²² À̵¿ÇÑ´Ù - by monkman (2005.03.25) // min, max·Î ÃÖ´ë ÃÖ¼Ò°ªÀ» ºñ±³Çϸ鼭 ¿µ¿ª °ªÀ» ´ëÀÔÇÑ´Ù if (bSelectedPoint) { int plusRange = data->PenThick * 2 + 10; if (data->ArrowCap){ plusRange = data->PenThick *(data->ArrowCap->LineCapWidthScale+1)*data->ArrowCap->LineCapWidth/2; } rc1.top = min(rc1.top, data->First.y - plusRange); rc1.bottom = max(rc1.bottom, data->Second.y + plusRange); rc1.left = min(rc1.left, data->First.x - plusRange); rc1.right = max(rc1.right, data->Second.x + plusRange); SET_RECT_ORIGIN; rc2.top = min(rc2.top, data->First.y - plusRange); rc2.bottom = max(rc2.bottom, data->Second.y + plusRange); rc2.left = min(rc2.left, data->First.x - plusRange); rc2.right = max(rc2.right, data->Second.x + plusRange); // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¼±ÅÃµÈ ¿ÀºêÁ§Æ®ÀÇ Æ÷ÀÎÆ®¸¦ À̵¿ÇÒ¶§ ´Ù¸¥ ¿ÀºêÁ§Æ®ÀÇ Æ÷ÀÎÆ®µµ ÇÔ²² ¼±ÅõǾîÀÖ´Ù¸é ÇÔ²² À̵¿ÇÑ´Ù - by monkman (2005.03.25) if (!bMultiSelected) break; // ´ÙÁß ¼±ÅÃÀÌ ¾Æ´Ò °æ¿ì UnionRect(&rc3, &rc1, &rc2); // µÎ rect¸¦ Æ÷ÇÔÇÏ´Â °¡Àå ÀÛÀº rect rc3 // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - ¹ÝÀü °Å¿ïÀÇ º¤ÅÍ ¿µ¿ªÀ» °°ÀÌ ±¸ÇÑ´Ù - by monkman(2005.03.16) if (NVector->bVectorReflectionMode) { GetRealAndReflectionRect(&rc3); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- if (data->bMotive) { TRect trect; GetRectForMouseMove(data, trect); rc3.top = rc3.top - trect.Height() / 2; rc3.left = rc3.left - trect.Width() / 2; rc3.bottom = rc3.bottom + trect.Height() / 2; rc3.right = rc3.right + trect.Width() / 2; } MainImageForm->iMainImage->RectPaint(rc3); } bSelectedPoint = false; } NVector->bSelectedVectorMove = true; NVector->bVectorMove = true; if (MoveX || MoveY) NVector->bUndosw = false; // ¸¶¿ì½º ¿À¸¥ÂÊ ¹öư ´­·¶À»¶§ ¶ß´Â ÆË¾÷ â°ú À̵¿/º¹»ç ¸Þ´º¿¡¼­ ReverseCopy¸¦ ¸·À½ - by monkman (2004.11.09) if (bReverseCopy) { VectorForm->ReverseCopy->Enabled = true; VectorForm->btReverseCopy->Enabled = true; } else { VectorForm->ReverseCopy->Enabled = false; VectorForm->btReverseCopy->Enabled = false; } } // --------------------------------------------------------------------------- void __fastcall TVecDraw::OnMouseConvertDown(int &Lsx, int &Lsy, int X, int Y) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) // ¸¶¿ì½º ¿À¸¥ÂÊ ¹öư ´­·¶À»¶§ ¶ß´Â ÆË¾÷ ¸Þ´º¿¡¼­ ReverseCopy¸¦ ¸·À½ - by monkman (2004.11.09) bool bReverseCopy; RECT rc1, rc2, rc3; // ±ÙÁ¢Á¡ ã±âÀÇ Á¤È®µµ¸¦ ³ôÀ̱â À§ÇØ - by monkman (2007.10.02) DRECT rt; double rg = 0; rg = (double)(3 * MainImageForm->iMainImage->ZoomOut) / MainImageForm->iMainImage->ZoomIn; rt.DRect(MainImageForm->iMainImage->RealPosX - rg, MainImageForm->iMainImage->RealPosY - rg, MainImageForm->iMainImage->RealPosX + rg, MainImageForm->iMainImage->RealPosY + rg); rg = 1.0; // data->First, data->Second¸¦ ã±â À§ÇØ 1.0À¸·Î ´Ã·ÁÁØ´Ù (data->First, data->Second´Â Á¤¼öÀ̱⠶§¹®) - by monkman (2009.09.15) bReverseCopy = true; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; // ¼Óµµ °³¼± - »ç°¢ ¿µ¿ª¾È¿¡ µé¾î¿Â ¿ÀºêÁ§Æ®¸¸ °Ë»ö - by monkman (2005.07.11) if (MainImageForm->iMainImage->RealPosX < data->First.x - rg || MainImageForm->iMainImage->RealPosX > data->Second.x + rg || MainImageForm->iMainImage->RealPosY < data->First.y - rg || MainImageForm->iMainImage->RealPosY > data->Second.y + rg) continue; data->bModified = true; // PatternFill µî¿¡¼­´Â modify°¡ ³¡³ª°í Çѹø¿¡ ¼öÁ¤ÇØ¾ß ÇÏ´Ï ¿É¼ÇÀ» µÐ´Ù // ¹ÝÀü º¹»ç ¸øÇϵµ·Ï ¸·À½ - by monkman (2009.05.11) if (data->Kind == V_TEXT || data->Kind == V_TEXTBOX || data->ParentTextBox) { bReverseCopy = false; } for (int j = 0; j < data->nCount * 3 + 1; j += 3) { // ½ÇÁ¦ Á¡ ¸ÕÀú if (rt.DPtInRect(data->pList[j].x, data->pList[j].y)) { if (data->pMask == NULL) continue; memset(data->pMask, 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); data->pMask[j / 8] |= (0x01 << (j % 8)); UndoSave(VU_MODIFY, i); if (j == 0) { if (data->bClosed) { // closed path¿¡¼­ÀÇ Ã³¸® data->pList[data->nCount * 3 - 1] = data->pList[j]; } data->pList[j + 1] = data->pList[j]; } else if (j == data->nCount * 3) { data->pList[j - 1] = data->pList[j]; } else { data->pList[j + 1] = data->pList[j]; data->pList[j - 1] = data->pList[j]; } rc1.top = data->First.y - data->PenThick - 5; rc1.bottom = data->Second.y + data->PenThick + 5; rc1.left = data->First.x - data->PenThick - 5; rc1.right = data->Second.x + data->PenThick + 5; SET_RECT_ORIGIN; rc2.top = data->First.y - data->PenThick - 5; rc2.bottom = data->Second.y + data->PenThick + 5; rc2.left = data->First.x - data->PenThick - 5; rc2.right = data->Second.x + data->PenThick + 5; UnionRect(&rc3, &rc1, &rc2); // µÎ rect¸¦ Æ÷ÇÔÇÏ´Â °¡Àå ÀÛÀº rect rc3 // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - ¹ÝÀü °Å¿ïÀÇ º¤ÅÍ ¿µ¿ªÀ» °°ÀÌ ±¸ÇÑ´Ù - by monkman(2005.03.16) if (NVector->bVectorReflectionMode) { GetRealAndReflectionRect(&rc3); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // Repaint ÇÒ Çʿ䰡 ¾ø´Â °Í °°¾Æ¼­ ÁÖ¼®À¸·Î ¸·À½ by david 09.05.01 // MainImageForm->iMainImage->RectPaint(rc3); NVector->bUndosw = false; goto success; } } for (int j = 0; j < data->nCount * 3 + 1; j++) { if (rt.DPtInRect(data->pList[j].x, data->pList[j].y)) { if (data->pMask == NULL) continue; memset(data->pMask, 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); data->pMask[j / 8] |= (0x01 << (j % 8)); } } // -->by linuxjun for CurvedVectorText if (data->ParentTextBox) { MakeTextBoxPointList(data->ParentTextBox); } // <--by linuxjun for CurvedVectorText } success: // ¸¶¿ì½º ¿À¸¥ÂÊ ¹öư ´­·¶À»¶§ ¶ß´Â ÆË¾÷ â°ú À̵¿/º¹»ç ¸Þ´º¿¡¼­ ReverseCopy¸¦ ¸·À½ - by monkman (2004.11.09) if (bReverseCopy) { VectorForm->ReverseCopy->Enabled = true; VectorForm->btReverseCopy->Enabled = true; } else { VectorForm->ReverseCopy->Enabled = false; VectorForm->btReverseCopy->Enabled = false; } END_LOG; return; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::OnMouseConvert(int &Lsx, int &Lsy, int X, int Y) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) RECT rc1, rc2, rc3; DRECT tp; int MoveX = X - Lsx; int MoveY = Y - Lsy; Lsx = X; Lsy = Y; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; data->bModified = true; // PatternFill µî¿¡¼­´Â modify°¡ ³¡³ª°í Çѹø¿¡ ¼öÁ¤ÇØ¾ß ÇÏ´Ï ¿É¼ÇÀ» µÐ´Ù // if (*bUndosw && (MoveX || MoveY)) UndoSave(VU_MODIFY, i); if (NVector->bUndosw) UndoSave(VU_MODIFY, i); for (int j = 0; j < data->nCount * 3 + (!data->bClosed); j++) { if ((data->pMask[j / 8] >> j % 8) & 0x01) { switch(j % 3) { case 0: // ±ÙÁ¢Á¡ ã±âÀÇ Á¤È®µµ¸¦ ³ôÀ̱â À§ÇØ - by monkman (2007.10.02) tp.DRect(MainImageForm->iMainImage->RealPosX - 5, MainImageForm->iMainImage->RealPosY - 5, MainImageForm->iMainImage->RealPosX + 5, MainImageForm->iMainImage->RealPosY + 5); if (tp.DPtInRect(data->pList[j].x, data->pList[j].y)) { // ¿òÁ÷ÀÓÀÌ ¾ø´Â°æ¿ì if (j == 0) { if (data->bClosed) { // closed path¿¡¼­ÀÇ Ã³¸® data->pList[data->nCount * 3 - 1] = data->pList[j]; } data->pList[j + 1] = data->pList[j]; } else if (j == data->nCount * 3) { data->pList[j - 1] = data->pList[j]; } else { data->pList[j + 1] = data->pList[j]; data->pList[j - 1] = data->pList[j]; } } else { if (j == 0) { if (data->bClosed) { // closed path¿¡¼­ÀÇ Ã³¸® data->pList[data->nCount * 3 - 1].DPoint (data->pList[j].x * 2 - data->pList[j + 1].x, data->pList[j].y * 2 - data->pList[j + 1].y); } data->pList[j + 1].DPoint(X, Y); } else if (j == data->nCount * 3) { data->pList[j - 1].DPoint(data->pList[j].x * 2 - X, data->pList[j].y * 2 - Y); } else { data->pList[j + 1].DPoint(X, Y); data->pList[j - 1].DPoint (data->pList[j].x * 2 - data->pList[j + 1].x, data->pList[j].y * 2 - data->pList[j + 1].y); } } break; case 1: data->pList[j].DPoint(X, Y); break; case 2: data->pList[j].DPoint(X, Y); break; } break; } } rc1.top = data->First.y - data->PenThick - 5; rc1.bottom = data->Second.y + data->PenThick + 5; rc1.left = data->First.x - data->PenThick - 5; rc1.right = data->Second.x + data->PenThick + 5; SET_RECT_ORIGIN; // -->by linuxjun for CurvedVectorText if (data->ParentTextBox) { MakeTextBoxPointList(data->ParentTextBox); } // <--by linuxjun for CurvedVectorText rc2.top = data->First.y - data->PenThick - 5; rc2.bottom = data->Second.y + data->PenThick + 5; rc2.left = data->First.x - data->PenThick - 5; rc2.right = data->Second.x + data->PenThick + 5; UnionRect(&rc3, &rc1, &rc2); // µÎ rect¸¦ Æ÷ÇÔÇÏ´Â °¡Àå ÀÛÀº rect rc3 // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - ¹ÝÀü °Å¿ïÀÇ º¤ÅÍ ¿µ¿ªÀ» °°ÀÌ ±¸ÇÑ´Ù - by monkman(2005.03.16) if (NVector->bVectorReflectionMode) { GetRealAndReflectionRect(&rc3); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- if (data->bMotive) { TRect trect; GetRectForMouseMove(data, trect); rc3.top = rc3.top - trect.Height() / 2; rc3.left = rc3.left - trect.Width() / 2; rc3.bottom = rc3.bottom + trect.Height() / 2; rc3.right = rc3.right + trect.Width() / 2; } MainImageForm->iMainImage->RectPaint(rc3); break; } // if (MoveX || MoveY) *bUndosw = false; NVector->bUndosw = false; END_LOG; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::OnMouseRepro(int &Lsx, int &Lsy, int X, int Y) { TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) RECT rc; int MoveX = X - Lsx; int MoveY = Y - Lsy; Lsx = X; Lsy = Y; bool sw = true; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; UndoSave(VU_MODIFY, i, sw); sw = false; switch(nSelPos) { case 1: data->First.x += MoveX; data->First.y += MoveY; break; case 2: data->Second.x += MoveX; data->First.y += MoveY; break; case 3: data->First.x += MoveX; data->Second.y += MoveY; break; case 4: data->Second.x += MoveX; data->Second.y += MoveY; break; } rc.top = MoveY > 0 ? data->First.y - MoveY - data->PenThick : data->First.y - data->PenThick; rc.bottom = MoveY > 0 ? data->Second.y + data->PenThick : data->Second.y - MoveY + data->PenThick; rc.left = MoveX > 0 ? data->First.x - MoveX - data->PenThick : data->First.x - data->PenThick; rc.right = MoveX > 0 ? data->Second.x + data->PenThick : data->Second.x - MoveX + data->PenThick; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - ¹ÝÀü °Å¿ïÀÇ º¤ÅÍ ¿µ¿ªÀ» °°ÀÌ ±¸ÇÑ´Ù - by monkman(2005.03.16) if (NVector->bVectorReflectionMode) { GetRealAndReflectionRect(&rc); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- MainImageForm->iMainImage->RectPaint(rc); } } // --------------------------------------------------------------------------- void __fastcall TVecDraw::OnMouseSelectDrag(int Lex, int Ley, int X, int Y) { HPEN hOldPen = NULL, hPen = NULL; HBRUSH hOldBrush = NULL; int nDrawMode; HDC dcDst = MainImageForm->iMainImage->Canvas->Handle; int ZoomIn = MainImageForm->iMainImage->ZoomIn; int ZoomOut = MainImageForm->iMainImage->ZoomOut; int PositionX = MainImageForm->sbHorz->Position; int PositionY = MainImageForm->sbVert->Position; int FirstX = (Lex - PositionX) * ZoomIn / ZoomOut; int FirstY = (Ley - PositionY) * ZoomIn / ZoomOut; int SecondX = (X - PositionX) * ZoomIn / ZoomOut; int SecondY = (Y - PositionY) * ZoomIn / ZoomOut; int TempX = (pBak.x - PositionX) * ZoomIn / ZoomOut; int TempY = (pBak.y - PositionY) * ZoomIn / ZoomOut; hPen = CreatePen(psDash, 1, clBlue); hOldPen = (HPEN)SelectObject(dcDst, hPen); nDrawMode = GetROP2(dcDst); SetROP2(dcDst, R2_NOT); hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); if (!(NVector->bFirstMove)) Rectangle(dcDst, FirstX, FirstY, TempX, TempY); // ÀÜ»ó¾ø¿¡±â Rectangle(dcDst, FirstX, FirstY, SecondX, SecondY); SetROP2(dcDst, nDrawMode); SelectObject(dcDst, hOldPen); SelectObject(dcDst, hOldBrush); DeleteObject(hPen); hPen = NULL; pBak = Point(X, Y); } // --------------------------------------------------------------------------- bool __fastcall TVecDraw::MouseDragUp(TShiftState Shift, RECT Area, bool bPoint) { TList *DataList = NVector->DataList; POINT Third, Forth; bool Success = false, sw = false; // int group = 0; // ÀÌ¹Ì ¼±ÅÃÇÑ groupÀ» ´Ù½Ã ¼±ÅÃÇÏÁö ¾Êµµ·Ï bool group[100000]; // ¾²À̰í ÀÖ´Â group index¸¦ È®ÀÎÇϱâ À§ÇØ ¸¸µê(groupÀÌ 10¸¸°³´Â ³ÑÀ»¸® ¾øÀ¸´Ï....) by siuaa 080501 for (int i = 0; i < 100000; i++) group[i] = false; int count = 0; // ¸¶¿ì½º ¿À¸¥ÂÊ ¹öư ´­·¶À»¶§ ¶ß´Â ÆË¾÷ ¸Þ´º¿¡¼­ ReverseCopy¸¦ ¸·À½ - by monkman (2004.11.09) bool bReverseCopy; TVecData *data = NULL, *childdata = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) bReverseCopy = true; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (data->bLocked) { data->bSelected = false; continue; } // if ((data->GroupIndex & group) && !bPoint) continue; if (group[data->GroupIndex / 10000] == true && !bPoint) continue; // by siuaa 080501 if (!Shift.Contains(ssShift) && !Shift.Contains(ssAlt)) data->bSelected = false; if (data->Kind == V_LINE || data->Kind == V_CURVE) { // ¶óÀΰú Ä¿ºê´Â °¢°¢ÀÇ Á¡µéÀ» ´Ù Ã¼Å©ÇØº»´Ù if (!bPoint || (!Shift.Contains(ssShift) && !Shift.Contains(ssAlt))) { // Point MaskÃʱâÈ­ if (data->pMask) { memset(data->pMask, 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); } } for (int j = 0; j < data->nCount * 3 + 1; j += 3) { if (PtInRect(&Area, data->pList[j].P())) { sw = true; // ¸¶¿ì½º ¿À¸¥ÂÊ ¹öư ´­·¶À»¶§ ¶ß´Â ÆË¾÷ ¸Þ´º¿¡¼­ ReverseCopy¸¦ ¸·À½ - by monkman (2004.11.09) if (data->ParentTextBox) { // CurvedTextÀÏ °æ¿ì ¹ÝÀüº¹»ç ¾ÈµÇµµ·Ï ¼öÁ¤ - by monkman (2009.05.07) bReverseCopy &= false; } if (!bPoint) break; // object editÀÎ °æ¿ì °É¸®¸é ³Ñ¾î°¡±â else { // point editÀÎ °æ¿ì if (Shift.Contains(ssAlt)) data->pMask[j / 8] &= ~(0x01 << (j % 8)); else data->pMask[j / 8] |= (0x01 << (j % 8)); } } } } else if (data->Kind == V_TEXTBOX && !bPoint) { // V_TEXTBOXÀ϶§ (Point Edit menu¿¡¼­´Â ºÒ°¡) Third = Point(data->First.x, data->Second.y); Forth = Point(data->Second.x, data->First.y); if (PtInRect(&Area, data->First) || PtInRect(&Area, data->Second) || PtInRect(&Area, Third) || PtInRect(&Area, Forth)) { sw = true; // ¸¶¿ì½º ¿À¸¥ÂÊ ¹öư ´­·¶À»¶§ ¶ß´Â ÆË¾÷ ¸Þ´º¿¡¼­ ReverseCopy¸¦ ¸·À½ - by monkman (2004.11.09) bReverseCopy &= false; } } else if (!bPoint) { // ±âŸµîµî (Point Edit menu¿¡¼­´Â ºÒ°¡) Third = Point(data->First.x, data->Second.y); Forth = Point(data->Second.x, data->First.y); if (PtInRect(&Area, data->First) || PtInRect(&Area, data->Second) || PtInRect(&Area, Third) || PtInRect(&Area, Forth)) { sw = true; // ¸¶¿ì½º ¿À¸¥ÂÊ ¹öư ´­·¶À»¶§ ¶ß´Â ÆË¾÷ ¸Þ´º¿¡¼­ ReverseCopy¸¦ ¸·À½ - by monkman (2004.11.09) bReverseCopy |= true; } } if (sw) { if (data->bSelected) { if (!Shift.Contains(ssShift) && !bPoint) { // AltŰ ´©¸¥ °æ¿ì data->bSelected = false; // if (data->GroupIndex & 0xfffffe00) { if (data->GroupIndex - ((data->GroupIndex % 10000) & 0x000001ff)) { // by siuaa 080501 // group |= data->GroupIndex; // ¼±ÅÃÇÑ groupÀº ÀúÀåÇØ¼­ ´Ù½Ã ¼±ÅõÇÁö ¾Êµµ·Ï ÇÔ group[data->GroupIndex / 10000] = true; // ¼±ÅÃÇÑ groupÀº ÀúÀåÇØ¼­ ´Ù½Ã ¼±ÅõÇÁö ¾Êµµ·Ï ÇÔ ModifyGroup(data, false); } } } else { // ¾È´©¸£°Å³ª Shift´©¸¥ °æ¿ì if (!Shift.Contains(ssAlt)) { data->bSelected = true; // if ((data->GroupIndex & 0xfffffe00) && !bPoint) { if (data->GroupIndex - ((data->GroupIndex % 10000) & 0x000001ff)) { // group |= data->GroupIndex; group[data->GroupIndex / 10000] = true; // ¼±ÅÃÇÑ groupÀº ÀúÀåÇØ¼­ ´Ù½Ã ¼±ÅõÇÁö ¾Êµµ·Ï ÇÔ ModifyGroup(data, true); } } Index = i; } NVector->bSelected = true; Success = true; sw = false; } if (data->bSelected && data->bAntialiasing) count++; } bool bTemp = VectorForm->bUserChange; VectorForm->bUserChange = false; if (count >= 1) { if (count == 1) { // Antialiasing üũ¹Ú½º ¼³Á¤ shin VectorForm->cbObjAntialiasing2->Checked = true; } else { // Antialiasing üũ¹Ú½º ¼³Á¤ shin VectorForm->cbObjAntialiasing2->Checked = true; } } else { VectorForm->cbObjAntialiasing2->Checked = false; } VectorForm->bUserChange = bTemp; // ¸¶¿ì½º ¿À¸¥ÂÊ ¹öư ´­·¶À»¶§ ¶ß´Â ÆË¾÷ â°ú À̵¿/º¹»ç ¸Þ´º¿¡¼­ ReverseCopy¸¦ ¸·À½ - by monkman (2004.11.09) if (bReverseCopy) { VectorForm->ReverseCopy->Enabled = true; VectorForm->btReverseCopy->Enabled = true; } else { VectorForm->ReverseCopy->Enabled = false; VectorForm->btReverseCopy->Enabled = false; } return Success; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::ProportionMouseMove(double &X, double &Y) { RECT rc; static int tempX = X, tempY = Y; // rectpaint½ÃÀÇ ±¸¿ªÀ» Àâ±â À§ÇØ(ÀÌÀü Á¡À» ÀúÀå) double DirectProportion = 1; // Á¤ºñ·Ê·Î Ä¿Áö°Ô Çϱâ À§ÇØ - by monkman (2005.07.19) double xSize, ySize; // 2005 Vector Upgrade Shin 0315 if (!bRatio) { xSize = X - sx; ySize = Y - sy; } ratiox = double(X - sx) / (double(ex - sx) ? double(ex - sx) : 1); ratioy = double(Y - sy) / (double(ey - sy) ? double(ey - sy) : 1); // MovtiveÀÇ È®´ë/Ãà¼Ò ½Ã »ç¿ëµÇ´Â °¡Àå ±äÃàÀÇ ±æÀÌ - by monkamn (2009.04.10) rc.top = min(int(sy), min(Y, tempY)) - thick - nMaxMotiveLength - 5; rc.bottom = max(int(ey * 2 - Y), max(Y, tempY)) + thick + nMaxMotiveLength + 5; rc.left = min(int(sx), min(X, tempX)) - thick - nMaxMotiveLength - 5; rc.right = max(int(ex * 2 - X), max(X, tempX)) + thick + nMaxMotiveLength + 5; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - ¹ÝÀü °Å¿ïÀÇ º¤ÅÍ ¿µ¿ªÀ» °°ÀÌ ±¸ÇÑ´Ù - by monkman(2005.03.16) if (NVector->bVectorReflectionMode) { GetRealAndReflectionRect(&rc); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- tempX = X; tempY = Y; NVector->bSelectedVectorMove = false; //NVector->bVectorMove = false; // MainImageForm->iMainImage->RectPaint(rc); MainImageForm->iMainImage->Repaint(); // For TextBox by maxleo21c (04.10.19) // 2005 Vector Upgrade Shin 0315 if (bRatio) { if (VectorForm->isShiftKeyDownState()) { // Á¤ºñ·Ê·Î Ä¿Áö°Ô Çϱâ À§ÇØ - by monkman (2005.07.19) DirectProportion = min(fabs(ratiox), fabs(ratioy)); X = DirectProportion * 100; Y = DirectProportion * 100; } else { X = ratiox * 100; // ºñÀ²À» µ¹·ÁÁØ´Ù(¼ýÀÚ·Î º¸¿©ÁÖ±â À§ÇØ) Y = ratioy * 100; } } else { if (VectorForm->isShiftKeyDownState()) { // Á¤ºñ·Ê·Î Ä¿Áö°Ô Çϱâ À§ÇØ - by monkman (2005.07.19) DirectProportion = min(xSize, ySize); switch(MainImageForm->CurrentUnit) { case uDot: break; case uInch: X = DirectProportion / MainImageForm->CanvasInfor.DotsPerInch; Y = DirectProportion / MainImageForm->CanvasInfor.DotsPerInch; break; case uCm: X = DirectProportion / MainImageForm->CanvasInfor.DotsPerInch * 2.54; Y = DirectProportion / MainImageForm->CanvasInfor.DotsPerInch * 2.54; break; } } else { switch(MainImageForm->CurrentUnit) { case uDot: break; case uInch: X = xSize / MainImageForm->CanvasInfor.DotsPerInch; Y = ySize / MainImageForm->CanvasInfor.DotsPerInch; break; case uCm: X = xSize / MainImageForm->CanvasInfor.DotsPerInch * 2.54; Y = ySize / MainImageForm->CanvasInfor.DotsPerInch * 2.54; break; } } } // X = ratiox * 100; // ºñÀ²À» µ¹·ÁÁØ´Ù(¼ýÀÚ·Î º¸¿©ÁÖ±â À§ÇØ) // Y = ratioy * 100; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::OnMouseDirectDown(TShiftState Shift, int X, int Y) { // 2005 Vector Upgrade =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // Point ¼±Åà °³¼± TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) double PointPosX, PointPosY; // ±ÙÁ¢Á¡ ã±â º¯¼ö (±ÙÁ¢Á¡À» ãÀ» ¶§¸¶´Ù ÀúÀå) - by monkman (2005.01.25) int pListPos; // ±ÙÁ¢Á¡ Áß pListÀÇ À§Ä¡ - by monkman (2005.01.25) POINT *pPoints = NULL; // pPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) // ±ÙÁ¢Á¡ ã±âÀÇ Á¤È®µµ¸¦ ³ôÀ̱â À§ÇØ - by monkman (2007.10.02) double rg = 0; DRECT rt; rg = (double)(3 * MainImageForm->iMainImage->ZoomOut) / MainImageForm->iMainImage->ZoomIn; rt.DRect(MainImageForm->iMainImage->RealPosX - rg, MainImageForm->iMainImage->RealPosY - rg, MainImageForm->iMainImage->RealPosX + rg, MainImageForm->iMainImage->RealPosY + rg); rg = 1.0; // data->First, data->Second¸¦ ã±â À§ÇØ 1.0À¸·Î ´Ã·ÁÁØ´Ù (data->First, data->Second´Â Á¤¼öÀ̱⠶§¹®) - by monkman (2009.09.15) bool bBreak = false; if (Shift.Contains(ssAlt)) { // AltŰ ´©¸£°í Ŭ¸¯ÇÏ¿© ÆÐ½º ¿­±â if ((ptNumber % 3) != 0) return; data = (TVecData*)DataList->Items[Index]; if (data->Kind != V_LINE && data->Kind != V_CURVE) return; // Line°ú curve¿¡¼­¸¸ Point Edit °¡´É if (!data->bClosed) return; if (!rt.DPtInRect(data->pList[ptNumber].x, data->pList[ptNumber].y)) return; UndoSave(VU_MODIFY, Index); if (data->Kind == V_TEXTBOX) { pPoints = new POINT[5]; } else { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new POINT[(data->nCount + 1) * 3 + 1]; } else { pPoints = new POINT[data->nCount * 3 + 1]; } } for (int i = 0; i < data->nCount * 3 - ptNumber; i++) pPoints[i] = data->pList[ptNumber + i].P(); for (int i = data->nCount * 3 - ptNumber; i < data->nCount * 3 + 1; i++) pPoints[i] = data->pList[i - data->nCount * 3 + ptNumber].P(); for (int i = 0; i < data->nCount * 3 + 1; i++) data->pList[i].DPoint(pPoints[i]); if (pPoints) delete[]pPoints; pPoints = NULL; data->bClosed = false; ptNumber = 0; } else { POINT Index = Point(-1, -1); // Alt¿Í Shift¸¦ ´­·¶À» °æ¿ì (¸ðµç ¿ÀºêÁ§Æ®ÀÇ ¼±ÅÃµÈ Æ÷ÀÎÆ®µé..) if (Shift.Contains(ssShift) || Shift.Contains(ssAlt)) { for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->Kind != V_LINE && data->Kind != V_CURVE) continue; // Line°ú curve¿¡¼­¸¸ Point Edit °¡´É // ¼Óµµ °³¼± - »ç°¢ ¿µ¿ª¾È¿¡ µé¾î¿Â ¿ÀºêÁ§Æ®¸¸ °Ë»ö - by monkman (2005.07.11) if (MainImageForm->iMainImage->RealPosX < data->First.x - rg || MainImageForm->iMainImage->RealPosX > data->Second.x + rg || MainImageForm->iMainImage->RealPosY < data->First.y - rg || MainImageForm->iMainImage->RealPosY > data->Second.y + rg) continue; PointPosX = MaxInt; PointPosY = MaxInt; pListPos = -1; for (int j = 0; j < data->nCount * 3 + 1; j++) { // ¸ðµç Á¡À» °Ë»ö if (rt.DPtInRect(data->pList[j].x, data->pList[j].y)) { // ¾Æ·¡´Â ÃÖ±ÙÁ¢Á¡À» ã±â À§ÇÑ ÀÛ¾÷ if ((PointPosX + PointPosY) > (fabs(MainImageForm->iMainImage->RealPosX - data->pList[j].x)) + fabs(MainImageForm->iMainImage->RealPosY - data->pList[j].y)) { PointPosX = fabs(MainImageForm->iMainImage->RealPosX - data->pList [j].x); PointPosY = fabs(MainImageForm->iMainImage->RealPosY - data->pList [j].y); pListPos = j; } } } if (pListPos >= 0) { switch(pListPos % 3) { case 0: // ½ÇÁ¦Á¡ for (int j = 0; j < data->nCount * 3 + 1; j++) { // ¸ðµç Á¡À» °Ë»ö if (j % 3) data->pMask[j / 8] &= ~(0x01 << (j % 8)); // Á¶ÀýÁ¡ Á¦°Å } data->pMask[pListPos / 8] |= (0x01 << (pListPos % 8)); break; case 1: // ù ¹øÂ° Á¶ÀýÁ¡ if (data->pList[pListPos - 1].x == data->pList[pListPos] .x && data->pList[pListPos - 1].y == data->pList[pListPos].y) { data->pMask[(pListPos - 1) / 8] |= (0x01 << ((pListPos - 1) % 8)); // ½ÇÁ¦Á¡ } else { data->pMask[pListPos / 8] |= (0x01 << (pListPos % 8)); } break; case 2: // µÎ ¹øÂ° Á¶ÀýÁ¡ if (data->pList[pListPos].x == data->pList[pListPos + 1] .x && data->pList[pListPos].y == data->pList[pListPos + 1].y) { data->pMask[(pListPos + 1) / 8] |= (0x01 << ((pListPos + 1) % 8)); // ½ÇÁ¦Á¡ } else { data->pMask[pListPos / 8] |= (0x01 << (pListPos % 8)); } break; } } else { for (int j = 0; j < data->nCount * 3 + 1; j++) { // ¸ðµç Á¡À» °Ë»ö if (j % 3) data->pMask[j / 8] &= ~(0x01 << (j % 8)); // Á¶ÀýÁ¡ Á¦°Å } } // if (bBreak) break; // ´Ù¸¥ ¿ÀºêÁ§Æ®ÀÇ Æ÷ÀÎÆ®µµ °Ë»çÇØ¾ßÇÑ´Ù.. } } else { PointPosX = MaxInt; PointPosY = MaxInt; // Alt¿Í Shift¸¦ ´©¸£Áö ¾Ê¾ÒÀ» °æ¿ì (¼±ÅÃµÈ ¿ÀºêÁ§Æ®ÀÇ Æ÷ÀÎÆ®¸¸.,.) if (!Shift.Contains(ssAlt) && !Shift.Contains(ssShift)) { // Index = ApproachObject(DataList, MainImageForm->iMainImage->RealPosX, MainImageForm->iMainImage->RealPosY, true, true); for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->Kind != V_LINE && data->Kind != V_CURVE) continue; // ¼Óµµ °³¼± - »ç°¢ ¿µ¿ª¾È¿¡ µé¾î¿Â ¿ÀºêÁ§Æ®¸¸ °Ë»ö - by monkman (2005.07.11) if (MainImageForm->iMainImage->RealPosX < data->First.x - rg || MainImageForm->iMainImage->RealPosX > data->Second.x + rg || MainImageForm->iMainImage->RealPosY < data->First.y - rg || MainImageForm->iMainImage->RealPosY > data->Second.y + rg) { if (data->pMask) { memset(data->pMask, 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); } continue; } for (int j = 0; j < data->nCount * 3 + 1; j++) { // ¸ðµç Á¡À» °Ë»ö if (rt.DPtInRect(data->pList[j].x, data->pList[j].y)) { // ¾Æ·¡´Â ÃÖ±ÙÁ¢Á¡À» ã±â À§ÇÑ ÀÛ¾÷ if ((PointPosX + PointPosY) > (fabs(MainImageForm->iMainImage->RealPosX - data->pList[j].x) ) + fabs(MainImageForm->iMainImage->RealPosY - data->pList[j] .y)) { PointPosX = fabs (MainImageForm->iMainImage->RealPosX - data->pList[j].x); PointPosY = fabs (MainImageForm->iMainImage->RealPosY - data->pList[j].y); if (Index.x >= 0) { TVecData *tempData = (TVecData*)DataList->Items[Index.x]; // ÀÌÀü ±ÙÁ¢Á¡ÀÌ ÇöÀç Á¡º¸´Ù Á¶±Ý ´õ ¸Ö¸® ÀÖÀ¸¹Ç·Î pMask¸¦ ÃʱâÈ­ ÇÑ´Ù memset(tempData->pMask, 0, (tempData->nCount * 3 + 1) % 8 == 0 ? (tempData->nCount * 3 + 1) / 8 : (tempData->nCount * 3 + 1) / 8 + 1); } Index.y = j; Index.x = i; } } } if (i != Index.x) { if (data->pMask) { // ¼±ÅõÇÁö ¾ÊÀº ¿ÀºêÁ§Æ®ÀÇ pMask¸¦ ÃʱâÈ­ÇÑ´Ù memset(data->pMask, 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); } } } if (Index.x >= 0 && Index.x < DataList->Count) { data = (TVecData*)DataList->Items[Index.x]; } else return; if (Index.y >= 0) { // data->pMask[128]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.19) switch(Index.y % 3) { case 0: // ½ÇÁ¦Á¡ for (int j = 0; j < data->nCount * 3 + 1; j++) { // ¸ðµç Á¡À» °Ë»ö if (j % 3) data->pMask[j / 8] &= ~(0x01 << (j % 8)); // Á¶ÀýÁ¡ Á¦°Å } if ((data->pMask[Index.y / 8] >> Index.y % 8) & 0x01) { // ÀÌ¹Ì ¼±ÅõǾî ÀÖ´ø Æ÷ÀÎÆ®ÀÇ °æ¿ì data->pMask[Index.y / 8] |= (0x01 << (Index.y % 8)); // Æ÷ÀÎÆ®¸¦ Ãß°¡·Î ¼±Åà } else { // »õ·Î ¼±ÅõǴ Á¡À̶ó¸é if (data->pMask) { memset(data->pMask, 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); // ÀÌÀü Æ÷ÀÎÆ® ¼±ÅÃÀ» ÃʱâÈ­ data->pMask[Index.y / 8] |= (0x01 << (Index.y % 8)); // Æ÷ÀÎÆ®¸¦ ¼±Åà } } break; case 1: // ù ¹øÂ° Á¶ÀýÁ¡ if (data->pList[Index.y - 1].x == data->pList[Index.y] .x && data->pList[Index.y - 1].y == data->pList[Index.y].y) { if ((data->pMask[(Index.y - 1) / 8] >> (Index.y - 1) % 8) & 0x01) { // ÀÌ¹Ì ¼±ÅõǾî ÀÖ´ø Æ÷ÀÎÆ®ÀÇ °æ¿ì data->pMask[(Index.y - 1) / 8] |= (0x01 << ((Index.y - 1) % 8)); // ½ÇÁ¦Á¡ } else { if (data->pMask) { memset(data->pMask, 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); data->pMask[(Index.y - 1) / 8] |= (0x01 << ((Index.y - 1) % 8)); // ½ÇÁ¦Á¡ } } } else { if (data->pMask) { memset(data->pMask, 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); // ÀÌÀü Æ÷ÀÎÆ® ¼±ÅÃÀ» ÃʱâÈ­ data->pMask[Index.y / 8] |= (0x01 << (Index.y % 8)); } } break; case 2: // µÎ ¹øÂ° Á¶ÀýÁ¡ if (data->pList[Index.y].x == data->pList[Index.y + 1] .x && data->pList[Index.y].y == data->pList[Index.y + 1].y) { if ((data->pMask[(Index.y + 1) / 8] >> (Index.y + 1) % 8) & 0x01) { // ÀÌ¹Ì ¼±ÅõǾî ÀÖ´ø Æ÷ÀÎÆ®ÀÇ °æ¿ì data->pMask[(Index.y + 1) / 8] |= (0x01 << ((Index.y + 1) % 8)); // ½ÇÁ¦Á¡ } else { if (data->pMask) { memset(data->pMask, 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); data->pMask[(Index.y + 1) / 8] |= (0x01 << ((Index.y + 1) % 8)); // ½ÇÁ¦Á¡ } } } else { if (data->pMask) { memset(data->pMask, 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); // ÀÌÀü Æ÷ÀÎÆ® ¼±ÅÃÀ» ÃʱâÈ­ data->pMask[Index.y / 8] |= (0x01 << (Index.y % 8)); } } break; } } else if (Index.x < 0) { if (data->pMask) { memset(data->pMask, 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); } } } } } if (pPoints) delete[]pPoints; pPoints = NULL; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // Object Edit Part // --------------------------------------------------------------------------- void __fastcall TVecDraw::ChangeObjectColor(bool bFill) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) RECT rc, rc2 = Rect(MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height, 0, 0); bool sw = true, repaintAll = false; TSWordData *tsWordData; RECT rect; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->ParentTextBox && bFill) continue; // by linuxjun for CurvedVectorText UndoSave(VU_MODIFY, i, sw); sw = false; if (bFill) { // »ö±ò·Î ä¿ì±â data->bPatternFill = false; data->bGradientFill = false; // shin gradientFill if (data->Bitmap) { delete data->Bitmap; data->Bitmap = NULL; } if (data->TBitmap) { delete data->TBitmap; data->TBitmap = NULL; } if (data->TBitmapSource) { delete data->TBitmapSource; data->TBitmapSource = NULL; } if (data->MaskBitmap) { delete data->MaskBitmap; data->MaskBitmap = NULL; } if (PaletteForm->DIB256Palette->ChoiceIndex == 1) { // ¼±ÅÃµÈ color°¡ ¹ÙÅÁ»öÀ̸é NULL Brush·Î~ // data->Brush = 0; data->bFill = false; } else { if (data->bFill && data->Brush == PenManagerForm->PenShape->Pen->Color) { if (data->bWinding) data->bWinding = false; else data->bWinding = true; } else { data->Brush = PenManagerForm->PenShape->Pen->Color; data->bFill = true; data->bWinding = false; } } } else { // Ææ»ö±ò ¹Ù²Ù±â data->Color = PenManagerForm->PenShape->Pen->Color; // -->by linuxjun for CurvedVectorText if (data->ParentTextBox) { // if (data->ParentTextBox->TextAngle) repaintAll = true; UndoSave(VU_TEXTMODIFY, DataList->IndexOf(data->ParentTextBox), sw); for (int k = 0; k < data->ParentTextBox->nCount; k++) { tsWordData = (TSWordData*)data->ParentTextBox->ListOfAllLine->Items (k); tsWordData->Color = PenManagerForm->PenShape->Pen->Color; } } // <--by linuxjun for CurvedVectorText else if (data->Kind == V_TEXTBOX) { // by maxleo21c (04.10.22) if (data->TextAngle) repaintAll = true; for (int k = 0; k < data->nCount; k++) { tsWordData = (TSWordData*)data->ListOfAllLine->Items(k); tsWordData->Color = PenManagerForm->PenShape->Pen->Color; } } } if (!bFill && data->PenThick == 0) data->PenThick = 2;//Åõ¸í»öÀÏ °æ¿ì »öÀ» ¹Ù²Ù¸é ±âº»°ªÀ¸·Î º¯°æ if (data->Kind == V_TEXT) { rc.top = min(data->First.y, data->Second.y) - data->Font.lfHeight; rc.bottom = max(data->First.y, data->Second.y) + data->Font.lfHeight; rc.left = min(data->First.x, data->Second.x) - data->Font.lfHeight; rc.right = max(data->First.x, data->Second.x) + data->Font.lfHeight; } else if (data->Kind == V_TEXTBOX) { GetRectForMouseMove(data, rect); rc.top = rect.top; rc.bottom = rect.bottom; rc.left = rect.left; rc.right = rect.right; } else { int plusRange = data->PenThick*2; if (data->ArrowCap){ plusRange = data->PenThick*(data->ArrowCap->LineCapWidthScale+1)*data->ArrowCap->LineCapWidth/2; } rc.top = data->First.y - plusRange; rc.bottom = data->Second.y + plusRange; rc.left = data->First.x - plusRange; rc.right = data->Second.x + plusRange; } rc2.top = min(rc2.top, rc.top); // ÃÖÀûÀÇ »ç°¢Çü ¸¸µé±â (ÇѹøÀÇ rectpaint¸¸ Çϵµ·Ï) rc2.bottom = max(rc2.bottom, rc.bottom); rc2.left = min(rc2.left, rc.left); rc2.right = max(rc2.right, rc.right); } // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - ¹ÝÀü °Å¿ïÀÇ º¤ÅÍ ¿µ¿ªÀ» °°ÀÌ ±¸ÇÑ´Ù - by monkman(2005.03.16) if (NVector->bVectorReflectionMode) { GetRealAndReflectionRect(&rc2); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- MainImageForm->iMainImage->RectPaint(rc2); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::ChangeObjectOrder(bool bFront, bool bOne) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) RECT rc, rc2 = Rect(MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height, 0, 0); bool sw = true; int NumberOfSeleted = 0; //2017.03.24 @jhs ¼±ÅÃµÈ º¤ÅÍÀÇ °³¼ö for (int i = 0; i < DataList->Count; i++) { if (bFront) // ¾ÕÀ¸·Î º¸³»±â¿¡¼­´Â µÚ¿¡¼­ºÎÅÍ °Ë»öÇØ¾ßÇÔ data = (TVecData*)DataList->Items[DataList->Count - i - 1]; else data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; else NumberOfSeleted++; //2017.03.24 @jhs Ä«¿îÆ® // -->by linuxjun for CurvedVectorText if (data->ParentTextBox) { if (bFront) { // ¾ÕÀ¸·Î º¸³¿ if (bOne) { if (i == 0 || i == 1) continue; // ¸Ç ¾Õ¿¡°Å´Â ¸øº¸³¿~ UndoSave(VU_ORDERF, DataList->Count - i, sw, DataList->Count - i + 1); UndoSave(VU_ORDERF, DataList->Count - i - 1, false, DataList->Count - i); DataList->Move(DataList->Count - i, DataList->Count - i + 1); DataList->Move(DataList->Count - i - 1, DataList->Count - i); Index = DataList->Count - i; } else { UndoSave(VU_ORDERF, DataList->Count - i - 1, sw); UndoSave(VU_ORDERF, DataList->Count - i, false); DataList->Move(DataList->Count - i, DataList->Count - 1); DataList->Move(DataList->Count - i - 1, DataList->Count - 2); Index = DataList->Count - 2; } } else { // µÚ·Î º¸³¿ if (bOne) { if (i == 0 || i == 1) continue; // ¸Ç µÚ¿¡°Å´Â ¸øº¸³¿~ UndoSave(VU_ORDERB, i, sw, i - 1); UndoSave(VU_ORDERB, i + 1, false, i); DataList->Move(i, i - 1); DataList->Move(i + 1, i); Index = i - 1; } else { UndoSave(VU_ORDERB, i, sw); UndoSave(VU_ORDERB, i + 1, false); DataList->Move(i, 0); DataList->Move(i + 1, 1); Index = 0; } } // <--by linuxjun for CurvedVectorText } else { if (bFront) { // ¾ÕÀ¸·Î º¸³¿ if (bOne) { if (i == 0) continue; // ¸Ç ¾Õ¿¡°Å´Â ¸øº¸³¿~ UndoSave(VU_ORDERF, DataList->Count - i - 1, sw, DataList->Count - i); DataList->Move(DataList->Count - i - 1, DataList->Count - i); Index = DataList->Count - i; } else { // 2017.03.27 º¤ÅÍ Á¤·Ä ¼ø¼­ ¼öÁ¤ @jhs // ¼öÁ¤ Àü ,(µÚ) 1-(2)-3-(4)-(5)-6 (¾Õ) => (µÚ) 1-3-6-(5)-(4)-(2) (¾Õ) // ¼öÁ¤ ÈÄ, (µÚ) 1-(2)-3-(4)-(5)-6 (¾Õ) => (µÚ) 1-3-6-(2)-(4)-(5) (¾Õ) UndoSave(VU_ORDERF, DataList->Count - i - 1, sw, DataList->Count - NumberOfSeleted); DataList->Move(DataList->Count - i - 1, DataList->Count - NumberOfSeleted); Index = DataList->Count - NumberOfSeleted; } } else { // µÚ·Î º¸³¿ if (bOne) { if (i == 0) continue; // ¸Ç µÚ¿¡°Å´Â ¸øº¸³¿~ UndoSave(VU_ORDERB, i, sw, i - 1); DataList->Move(i, i - 1); Index = i - 1; } else{ // 2017.03.27 º¤ÅÍ Á¤·Ä ¼ø¼­ ¼öÁ¤ @jhs // ¼öÁ¤ Àü ,(µÚ) 1-(2)-3-(4)-(5)-6 (¾Õ) => (µÚ) (5)-(4)-(2)-1-3-6 (¾Õ) // ¼öÁ¤ ÈÄ, (µÚ) 1-(2)-3-(4)-(5)-6 (¾Õ) => (µÚ) (2)-(4)-(5)-1-3-6 (¾Õ) UndoSave(VU_ORDERB, i,sw,NumberOfSeleted-1); DataList->Move(i,NumberOfSeleted-1); Index = NumberOfSeleted-1; } } } sw = false; if (data->Kind == V_TEXT) { rc.top = min(data->First.y, data->Second.y) - data->Font.lfHeight; rc.bottom = max(data->First.y, data->Second.y) + data->Font.lfHeight; rc.left = min(data->First.x, data->Second.x) - data->Font.lfHeight; rc.right = max(data->First.x, data->Second.x) + data->Font.lfHeight; } else { int plusRange = data->PenThick*2; if (data->ArrowCap){ plusRange = data->PenThick*(data->ArrowCap->LineCapWidthScale+1)*data->ArrowCap->LineCapWidth/2; } rc.top = data->First.y - plusRange; rc.bottom = data->Second.y + plusRange; rc.left = data->First.x - plusRange; rc.right = data->Second.x + plusRange; } rc2.top = min(rc2.top, rc.top); // ÃÖÀûÀÇ »ç°¢Çü ¸¸µé±â (ÇѹøÀÇ rectpaint¸¸ Çϵµ·Ï) rc2.bottom = max(rc2.bottom, rc.bottom); rc2.left = min(rc2.left, rc.left); rc2.right = max(rc2.right, rc.right); } // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - ¹ÝÀü °Å¿ïÀÇ º¤ÅÍ ¿µ¿ªÀ» °°ÀÌ ±¸ÇÑ´Ù - by monkman(2005.03.16) if (NVector->bVectorReflectionMode) { GetRealAndReflectionRect(&rc2); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- MainImageForm->iMainImage->RectPaint(rc2); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::DeleteVectorObject(bool bUndo) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TList *UndoList = MainImageForm->VU_DATA; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) TPVectorUndo *Undo = (TPVectorUndo*)MainImageForm->VecUndo; RECT rc = Rect(0, 0, MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height); bool sw = true; int UndoIndex = 0; if (!(NVector->bSelected)) { END_LOG; return; } for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; // -->by linuxjun for CurvedVectorText if (data->ParentTextBox) { continue; } else if (data->ListOfAllLine && !data->bSelected) { if (!data->ListOfAllLine->CurveData) { continue; } if (!data->ListOfAllLine->CurveData->bSelected) { continue; } } // <--by linuxjun for CurvedVectorText else if (!data->bSelected) continue; if (bUndo) { // -->by linuxjun for CurvedVectorText if (data->ListOfAllLine) { UndoSave(VU_TEXTDELETE, i, sw); // <--by linuxjun for CurvedVectorText } else { UndoSave(VU_DELETE, i, sw); } } else { /* // VU_NOTHING ´ëü ÇϱâÀ§ÇØ Undo->RemoveLastEltNum(UndoIndex);¸¦È£ÃâÇÔ. udata = (TVUndoData *)UndoList->Items[UndoIndex++]; udata->Kind = VU_NOTHING; udata->bFirst = false; */ UndoIndex++; // by linuxjun } sw = false; if (data->Bitmap) { delete data->Bitmap; data->Bitmap = NULL; } // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¿ø·¡ DataList->Remove(i) ¿´À¸³ª Access Violation ¹®Á¦·Î ¾Æ·¡¿Í °°ÀÌ ¼öÁ¤ - by monkman (2005.03.29) // -->by linuxjun for CurvedVectorText if (data->ListOfAllLine) { int seqNum; if (data->ListOfAllLine->CurveData) { seqNum = DataList->Remove(data->ListOfAllLine->CurveData); delete data->ListOfAllLine->CurveData; data->ListOfAllLine->CurveData = NULL; if (seqNum <= i) { i--; } } } // <--by linuxjun for CurvedVectorText DataList->Remove(data); // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- if (data) delete data; data = NULL; i--; } nSelPos = 0; NVector->bSelected = false; if (!bUndo) { Undo->RemoveLastEltNum(UndoIndex); // by linuxjun } MainImageForm->iMainImage->Cursor = crDefault; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - ¹ÝÀü °Å¿ïÀÇ º¤ÅÍ ¿µ¿ªÀ» °°ÀÌ ±¸ÇÑ´Ù - by monkman(2005.03.16) if (NVector->bVectorReflectionMode) { GetRealAndReflectionRect(&rc); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- MainImageForm->iMainImage->RectPaint(rc); FullViewForm->Image->Repaint(); END_LOG; } // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // --> by linuxjun for CurvedVectorText TVecData * __fastcall TVecDraw::GetSelectedCurvedData() { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL, *ResultData = NULL; int num = 0; for (int i = 0; i < DataList->Count; i++) { data = (TVecData *)DataList->Items[i]; if(data->Kind == V_TEXT || data->Kind == V_TEXTBOX) continue; if(data->bSelected && !data->ChildList) { ResultData = data; } } END_LOG; if(num <= 1) return ResultData; else return NULL; } // --------------------------------------------------------------------------- TVecData * __fastcall TVecDraw::GetSelectedTextData() { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL, *ResultData = NULL; int num = 0; for (int i = 0; i < DataList->Count; i++) { data = (TVecData *)DataList->Items[i]; if(!(data->Kind == V_TEXTBOX))continue; if(data->ListOfAllLine->CurveData) { if(data->ListOfAllLine->CurveData->bSelected) { ResultData = data; } } } END_LOG; if(num <= 1) return ResultData; else return NULL; } // --------------------------------------------------------------------------- TVecData * __fastcall TVecDraw::GetLastCurvedData() { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) // TVecData * ResultData = NULL; // int num = 0; for (int i = DataList->Count - 1; i >= 0; i--) { data = (TVecData*)DataList->Items[i]; if (data->Kind == V_TEXT || data->Kind == V_TEXTBOX) continue; // if(data->ParentTextBox)continue; if (!data->ChildList) { END_LOG; return data; } } END_LOG; return NULL; } // --------------------------------------------------------------------------- TVecData * __fastcall TVecDraw::GetSelectedData() { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL; if (Index < DataList->Count) data = (TVecData *)DataList->Items[Index]; END_LOG; return data; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::MakeCurveTextFromObject(TVecData *tdata) { // * BEGIN_LOG(""); HDC hdc; // int Num, *line = 0; TLineTextBox * tempTLineTextBox; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) TVecData * CurveData; int Num; RECT rc; int widthsum = 0, height; TList *DataList = NVector->DataList; int VisualX, VisualY; Char tString[2] = L"a"; SIZE size; TEXTMETRIC tm; if ((data = new TVecData(MainImageForm->Number)) == NULL) goto fail; data->Kind = V_TEXTBOX; data->Color = PenManagerForm->PenShape->Pen->Color; data->nCount = 0; data->ListOfAllLine = new TWordList; tempTLineTextBox = new TLineTextBox; data->StartPoint.x = 0; data->StartPoint.y = 0; // »õ·Î¿î TextBox°¡ ¸¸µé¾îÁö¸é °ü·Ã º¯¼ö°¡ ÃʱâÈ­ µÇ¾î¾ß ÇÑ´Ù. tString[1] = '\0'; hdc = MainImageForm->iMainImage->Canvas->Handle; GetTextExtentPoint32(hdc, tString, 2, &size); GetTextMetrics(hdc, &tm); IndexOfLine = 0; // ToDo: Caretº¸¿©Áö´Â À§Ä¡ ²À Ãß°¡ÇØÁÙ°Í!!! VisualX = MainImageForm->iMainImage->BitmapToCanvasX(tdata->pList[0].x); // ÁÜÀ̳ª À̵¿ÈÄ ÇöÀç ´«¿¡ º¸ÀÌ´Â °÷ VisualY = MainImageForm->iMainImage->BitmapToCanvasY(tdata->pList[0].y); // ¸¶¿ì½º¸¦ Ŭ¸¯ÇÑ °÷ÀÇ À§Ä¡ xCaretPoz = VisualX; yCaretPoz = VisualY; // Caret º¸¿©Áö´Â À§Ä¡ CaretW = 0; CaretH = size.cy; // ±ÛÀÚÀÇ Å©±â // *line = CaretH; tempTLineTextBox->lineHeight = CaretH; IndexOfWord = 0; data->First.x = 0; data->First.y = 0; data->Second.x = 0; data->Second.y = 0; data->CenterPoint.x = 0; data->CenterPoint.y = 0; TextAngle = 0.0; data->ListOfAllLine->Add(tempTLineTextBox); DataList->Add(data); data->pList = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * 5); for (int i = 0; i<5; i++) { data->pList[i].x = 0; data->pList[i].y = 0; } data->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, 1); // ======= Undo Test // UndoSave(VU_CREATE, DataList->Count-1); CurveData = new TVecData(MainImageForm->Number); CurveData->Copy(tdata); CurveData->PenThick = 0; // by linuxjun for CurvedVectorText 7¿ù¸» // data->ListOfAllLine->CurveData = tdata; data->ListOfAllLine->CurveData = CurveData; CurveData->ParentTextBox = data; if (DataList->IndexOf(tdata) >= 0) { UndoSave(VU_DELETE, DataList->IndexOf(tdata), true); DataList->Remove(tdata); delete tdata; tdata = NULL; // DataList->Add(CurveData); // UndoSave(VU_TEXTCREATE, DataList->Count-2,false); //for new font DataList->Insert(DataList->Count - 1, CurveData); UndoSave(VU_TEXTCREATE, DataList->Count - 1, false); // for new font // UndoSave(VU_CREATE, DataList->Count-1,false); //for new font } else { // DataList->Add(CurveData); // UndoSave(VU_TEXTCREATE, DataList->Count-2,true); //for new font DataList->Insert(DataList->Count - 1, CurveData); UndoSave(VU_TEXTCREATE, DataList->Count - 1, true); // for new font // UndoSave(VU_CREATE, DataList->Count-1,false); //for new font } // MakeTextBoxPointList(data); // ======= Undo Test NVector->bFirst = true; bInSel = false; SelStart = 0; SelEnd = 0; LineStart = 0; LineEnd = 0; BeReadyEdit = true; ExistSelected = false; if (CurveData) { // CurrentTextBox = DataList->Count-2; //DataList->Count´Â 1ºÎÅÍ ½ÃÀÛ CurrentTextBox = DataList->Count - 1; // DataList->Count´Â 1ºÎÅÍ ½ÃÀÛ } else { CurrentTextBox = DataList->Count - 1; // DataList->Count´Â 1ºÎÅÍ ½ÃÀÛ } // Antialiasing ¼³Á¤ 20050211 if (VectorForm->cbTextAntialiasing->Checked) data->bAntialiasing = true; else data->bAntialiasing = false; END_LOG; return; fail: if (data) delete data; data = NULL; END_LOG; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::SetTextSelected(TVecData *tdata) // by linuxjun for CurvedVectorText { BEGIN_LOG(""); TList *DataList = NVector->DataList; NVector->bFirst = true; bInSel = false; CurrentTextBox = DataList->IndexOf(tdata); SelStart = 0; SelEnd = tdata->ListOfAllLine->GetLineTextBox(0)->LineDataList->Count; LineStart = 0; LineEnd = 0; IndexOfWord = 0; // Line Index (OffSet) BeReadyEdit = true; ExistSelected = true; END_LOG; } // <-- by linuxjun for CurvedVectorText // --------------------------------------------------------------------------- /// MotiveObject¸¦ »ý¼ºÇÏ´Â ÇÔ¼ö /** tempChildList¸¦ ÀÌ¿ëÇÏ¿© MotiveObject¸¦ ¸¸µé°í DataList¿¡ µî·ÏÇÏ´Â ÇÔ¼ö. MotiveObject¸¦ ¸¸µé°í, MotiveObject¸¸ÀÌ °¡Áö´Â ¼Ó¼ºÀ» °è»êÇÏ¿© ³Ö¾îÁØ´Ù. (childcount, mode, gap, proportion....) */ // by embakum 20090217 void __fastcall TVecDraw::MakeMotiveObject(TVecData *data) { BEGIN_LOG(""); // TVecData *data¸¦ ÀÔ·Â ¹Þµµ·Ï º¯°æ - by monkman (2009.04.02) TList *DataList = NVector->DataList; TVecData *Parent = NULL, *Child1 = NULL, *Child2 = NULL; float eMotiveProportion = 0; float eMotiveGap = 0; int eMotiveCount = 0; eMotiveProportion = VectorForm->eMotiveProportion->Value; eMotiveGap = VectorForm->eMotiveGap->Value; eMotiveCount = VectorForm->eMotiveCount->Value; /* if (!TryStrToFloat(VectorForm->eMotiveProportion->Text, eMotiveProportion) || !TryStrToFloat(VectorForm->eMotiveGap->Text, eMotiveGap) || !TryStrToInt(VectorForm->eMotiveCount->Text, eMotiveCount)) { return; } */ /* if (!TryStrToFloat(VectorForm->eMotiveProportion->Text, eMotiveProportion)) { VectorForm->eMotiveProportion->Text = "100"; eMotiveProportion = 100; } if (!TryStrToFloat(VectorForm->eMotiveGap->Text, eMotiveGap)) { VectorForm->eMotiveGap->Text = "100"; eMotiveGap = 100; } if (!TryStrToInt(VectorForm->eMotiveCount->Text, eMotiveCount)) { VectorForm->eMotiveCount->Text = "5"; eMotiveCount = 5; } */ UndoSave(VU_DELETE, DataList->IndexOf(data), true); if (data->ChildList) data->DeleteChildList(); UndoSave(VU_MOTIVECREATE, DataList->Count - 1, false); data->bMotive = true; data->ChildList = new TList; for (int i = 0; i < tempChildList->Count; i++) { Child1 = new TVecData(MainImageForm->Number); Child2 = (TVecData*)tempChildList->Items[i]; Child1->Copy(Child2); data->ChildList->Add(Child1); } data->proportion = eMotiveProportion / 100; data->ChildCount = tempChildList->Count; if (VectorForm->rbMotiveMax->Checked) { data->mode = 0; } else if (VectorForm->rbMotiveCount->Checked) { data->mode = 1; data->motivecount = eMotiveCount; } else if (VectorForm->rbMotiveGap->Checked) { data->mode = 2; switch(MainImageForm->CurrentUnit) { case uDot: data->gap = eMotiveGap; break; case uInch: data->gap = eMotiveGap * MainImageForm->CanvasInfor.DotsPerInch / 2.54; break; case uCm: data->gap = eMotiveGap * MainImageForm->CanvasInfor.DotsPerInch; break; } } CalculateChild(data); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::CalculateChild(TVecData *ParentData) { TList *DataList = ParentData->ChildList; TVecData *Child; double minX = 60000; double minY = 60000; double maxX = 0; double maxY = 0; if (DataList) { for (int i = 0; i < DataList->Count; i++) { Child = (TVecData*)DataList->Items[i]; Child->SetRect(); if (minX > Child->First.x) minX = Child->First.x; if (maxX < Child->Second.x) maxX = Child->Second.x; if (minY > Child->First.y) minY = Child->First.y; if (maxY < Child->Second.y) maxY = Child->Second.y; } ParentData->centerX = (minX + maxX) / 2; ParentData->centerY = (minY + maxY) / 2; ParentData->childwidth = maxX - minX; ParentData->childheight = maxY - minY; } else { return; } } // --------------------------------------------------------------------------- /// Motive Object¸¦ ±×¸®´Â ÇÔ¼ö. /** Motive Object¸¦ ±×¸®´Â ÇÔ¼ö. 1. ParentDataÀÇ nµîºÐÁ¡À» ã°í, ±× Á¡¿¡¼­ÀÇ tangent¸¦ ±¸ÇÑ´Ù. 2. nµîºÐÁ¡¿¡ ParentDataÀÇ ChildList¸¦ ±×·ÁÁØ´Ù. (ChildListÀÇ centerÁ¡À» ParentDataÀÇ nµîºÐÁ¡À¸·Î ÀÏÄ¡½ÃÄÑ ±×¸²) 3. nµîºÐÁ¡¿¡¼­ÀÇtangent¸¸Å­ ChildList¸¦ ȸÀü½ÃÄÑ ÁØ´Ù. # nµîºÐÁ¡¿¡ ±×¸± ¶§, ¸Å¹ø nµîºÐÁ¡À¸·Î ¿Å±è, ȸÀü, ȸÀüȯ¿ø, ¿Å±è ȯ¿ø ¼ø¼­¸¦ °ÅÄ£´Ù. */ // --------------------------------------------------------------------------- void __fastcall TVecDraw::DrawMotiveObjects(HDC dcDst, TVecData *ParentData, TMainImageForm *form, double px, double py, int nMode, int nPositionX, int nPositionY, double dZoom, int nInstanceNumber, int method) { TList *tDataList = ParentData->ChildList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) TList *DataList = new TList; TList * ResultBezierPointList; TPointList *tempPointList; bool bSelectedLine; DPOINT firstPoint, onPoint, normalPoint, tempCurpt, tempOldpt; DPOINT *pTempList = NULL; double dInterval; TBezierPointList * BezierPointList = new TBezierPointList(); // »ý¼º BezierPointList->Init(ParentData); double CurveLength = BezierPointList->GetCurveLength(); int nSegment; // int quotient = int(CurveLength/((ParentData->proportion)*(ParentData->childwidth))); // if (quotient==0) quotient = 1; switch(ParentData->mode) { case 0: // ²Ë ä¿ì±â if (ParentData->proportion == 0) { ParentData->proportion = 1; if (VectorForm) VectorForm->eMotiveProportion->Value = 1; } if (ParentData->childwidth == 0) { ParentData->childwidth = 1; } nSegment = int(CurveLength / ((ParentData->proportion) * (ParentData->childwidth))); if (nSegment == 0) nSegment = 1; ParentData->gap = double(CurveLength / nSegment); ParentData->motivecount = nSegment; break; case 1: // °³¼ö ¼³Á¤ nSegment = ParentData->motivecount; if (nSegment == 0) { nSegment = 1; if (VectorForm) VectorForm->eMotiveCount->Value = 1; } ParentData->gap = double(CurveLength / nSegment); break; case 2: // °£°Ý ¼³Á¤ if (ParentData->gap == 0) { ParentData->gap = 1; if (VectorForm) VectorForm->eMotiveGap->Value = 1; } nSegment = int(CurveLength / ParentData->gap); if (nSegment == 0) nSegment = 1; ParentData->motivecount = nSegment; break; } int count = 1; ResultBezierPointList = BezierPointList->Calculate(ParentData, nSegment); if (!ResultBezierPointList) { delete DataList; DataList; delete BezierPointList; BezierPointList = NULL; return; } pTempList = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * (nSegment * 3 + 1)); double *tangentlist = new double[nSegment + 1]; // ±â¿ï±â¸¦ °¡Áö°í ÀÖ´Â ¹è¿­ firstPoint = FindingNormalOnBezier(&ParentData->pList[0], 0, 0, 0); pTempList[0].x = firstPoint.x; pTempList[0].y = firstPoint.y; pTempList[1].x = firstPoint.x; pTempList[1].y = firstPoint.y; tangentlist[0] = FindCurveTangent(&ParentData->pList[0], 0); for (int i = 0; i < ResultBezierPointList->Count; i++) { tempPointList = (TPointList*)ResultBezierPointList->Items[i]; for (tempPointList->First(); !tempPointList->IsDone(); tempPointList->Next()) { dInterval = tempPointList->CurrentDouble(); // BezierCurve À§ÀÇ Á¡À§Ä¡ // onPoint = FindingPointOnBezier(&tData->pList[i*3], dInterval); // ãÀº Á¡ÀÇ NormalÀÇ À§Ä¡ (ãÀº Á¡Àº ResultBezierPointList¾È¿¡ ÀÖÀ½) normalPoint = FindingNormalOnBezier(&ParentData->pList[i * 3], dInterval, 0, count % 2); tangentlist[count] = FindCurveTangent(&ParentData->pList[i * 3], dInterval); pTempList[count * 3 - 2] = pTempList[count * 3 - 3]; pTempList[count * 3 - 1].x = normalPoint.x; pTempList[count * 3 - 1].y = normalPoint.y; pTempList[count * 3].x = normalPoint.x; pTempList[count * 3].y = normalPoint.y; count++; tempOldpt = tempCurpt; } } if (ParentData->bClosed) { // ´ÝÈù ¿ÀºêÁ§Æ®ÀÇ °æ¿ì ³¡Á¡°ú ùÁ¡À» °°°Ô. pTempList[nSegment * 3] = pTempList[0]; pTempList[nSegment * 3 - 1] = pTempList[0]; } delete BezierPointList; BezierPointList = NULL; // È­¸é¿¡ º¸À̱â HPEN hOldPen = NULL, hPen = NULL; HBRUSH hOldBrush = NULL, hBrush = NULL; LOGBRUSH logbrush; int nDrawMode, nFillMode, nTemp, nPenStyle; RGBQUAD rgb; HFONT font = NULL, oldfont = NULL; Graphics::TBitmap *TempBitmap = NULL; int ZoomIn = form->iMainImage->ZoomIn; int ZoomOut = form->iMainImage->ZoomOut; int PositionX = form->sbHorz->Position; int PositionY = form->sbVert->Position; int FirstX, FirstY, SecondX, SecondY; int R_FirstX, R_FirstY, R_SecondX, R_SecondY; // Gradient ¹ÝÀü °Å¿ï - by monkman (2009.04.15) int PositionX2, PositionY2; // Gradient ¹ÝÀü °Å¿ï - by monkman (2009.05.06) int nReflectionIndex; // Gradient ¹ÝÀü °Å¿ï - by monkman (2009.04.15) double CenterX, CenterY, FontZoom = 1.0; int OffsetX, OffsetY; // by linuxjun for CurvedVectorText int StartX, StartY; int pw; float* dashValues = NULL; bool bColorfill = false, bPatternfill = false, bGradientfill = false; TColor tColor = clBlack, tBrush = clBlack; TVecData *tdata; // motive childÀÇ È®´ë Ãà¼Ò for (int i = 0; i < tDataList->Count; i++) { data = (TVecData*)tDataList->Items[i]; tdata = new TVecData(data->GetInstNum()); tdata->Copy(data); tdata->bSelected = data->bSelected; // º¹»ç ºÙ¿©³Ö±â ½Ã º¸¿©Áöµµ·Ï - by monkman (2009.04.02) for (int l = 0; l < data->nCount * 3 + 1; l++) { tdata->pList[l].x = (data->pList[l].x - ParentData->centerX) * ParentData->proportion + ParentData->centerX; tdata->pList[l].y = (data->pList[l].y - ParentData->centerY) * ParentData->proportion + ParentData->centerY; } DataList->Add(tdata); } // ------------------------------------------ // Mode Ãß°¡ - by monkman (2009.04.09) switch(nMode) { case 0: dZoom = (double)ZoomIn / ZoomOut; bSelectedLine = true; break; case 1: // Tag // dZoom = 1; PositionX = nPositionX; PositionY = nPositionY; bSelectedLine = false; break; case 2: // Arbitrary px = -px / 2; py = -py / 2; PositionX = nPositionX; PositionY = nPositionY; bSelectedLine = false; break; case 3: // Scale 1:1 dZoom = 1; PositionX = 0; PositionY = 0; bSelectedLine = false; break; case 4: // bSelectedLine == false dZoom = (double)ZoomIn / ZoomOut; bSelectedLine = false; break; case 5: // Scale 1:1 Pattern Fill ÇÏÁö ¾ÊÀ½ dZoom = 1; PositionX = 0; PositionY = 0; bSelectedLine = false; break; case 6: // DrawSpreadObject() ¿ë dZoom = (double)ZoomIn / ZoomOut; PositionX = nPositionX; PositionY = nPositionY; bSelectedLine = false; } gdp::Graphics graphics(dcDst); // using GDI+ gdp::PointF *pPoints = NULL; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) gdp::PointF *pRefPoints = NULL; int ReflectionIndex = -1; if (form->NVector->bVectorReflectionMode && ((form->NVector->ReflectionVH == 1 && form->NVector->ReflectionVIndex >= 0) || (form->NVector->ReflectionVH == 2 && form->NVector->ReflectionHIndex >= 0))) { // ¼öÁ÷ ±âÁؼ± if (form->NVector->ReflectionVH == 1) ReflectionIndex = (form->NVector->ReflectionVIndex - PositionX) * dZoom; // ¼öÆò ±âÁؼ± if (form->NVector->ReflectionVH == 2) ReflectionIndex = (form->NVector->ReflectionHIndex - PositionY) * dZoom; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- for (int k = 0; k < nSegment; k++) { for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; for (int l = 0; l < data->nCount * 3 + 1; l++) { data->pList[l].x = data->pList[l].x - ParentData->centerX + pTempList [3 * k].x; data->pList[l].y = data->pList[l].y - ParentData->centerY + pTempList [3 * k].y; } for (int l = 0; l < data->nCount * 3 + 1; l++) { double dx = data->pList[l].x - pTempList[3 * k].x; double dy = data->pList[l].y - pTempList[3 * k].y; data->pList[l].x = dx * cos(tangentlist[k]) - dy * sin(tangentlist[k]) + pTempList[3 * k].x; data->pList[l].y = dx * sin(tangentlist[k]) + dy * cos(tangentlist[k]) + pTempList[3 * k].y; } // todo : ¿ø·¡´Â ¾Æ·¡ ¼Ò½º°¡ ÁÖ¼®Ã³¸® µÇ¾î ÀÖ¾úÀ½.. // ´Ù¸¥ ĵ¹ö½º±îÁö °°ÀÌ ¾÷µ¥ÀÌÆ®µÇ¹Ç·Î ÁÖ¼®Ã³¸® - by monkman (2004.10.05) // if (nInstanceNumber > 0) { if (!data->Equal(nInstanceNumber)) continue; // nInstanceNumber¸¦ Á÷Á¢ ÁÙ °æ¿ì Ãß°¡ - by monkman (2009.04.08) } else { if (!data->Equal(form->Number)) continue; } // object¸¶´Ù antialiasing¼³Á¤ if (!(NVector->bCancelAntialiasing) && ParentData->bAntialiasing && ! (form->NVector->bSelectedVectorMove)) { graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); } else { graphics.SetSmoothingMode(gdp::SmoothingModeNone); } if (form->NVector->bMergeMode && ParentData->bSelected) { // Merge Mode¿¡¼­ ¼±ÅÃµÈ ¿ÀºêÁ§Æ®ÀÇ ¸¶¿ì½º À̵¿¿¡ µû¸¥ ÁÂÇ¥ º¯°æ // Gradient¿ë Position °è»ê - by monkman (2009.05.06) PositionX2 = (-MergeX - PositionX); PositionY2 = (-MergeY - PositionY); PositionX -= MergeX; PositionY -= MergeY; } else { PositionX2 = -PositionX; PositionY2 = -PositionY; } SET_RECT; // gradientfill FirstX = (data->First.x - PositionX) * dZoom - px; FirstY = (data->First.y - PositionY) * dZoom - py; SecondX = (data->Second.x - PositionX) * dZoom - px; SecondY = (data->Second.y - PositionY) * dZoom - py; // Gradient ¹ÝÀü °Å¿ï - by monkman (2009.04.15) nReflectionIndex = form->NVector->ReflectionVH == 1 ? form->NVector->ReflectionVIndex : form->NVector->ReflectionHIndex; if (form->NVector->bVectorReflectionMode && form->NVector->ReflectionVH > 0) { if (form->NVector->ReflectionVH == 1) { R_FirstX = (nReflectionIndex * 2 - data->Second.x + PositionX2) * ZoomIn / ZoomOut - px; R_FirstY = FirstY; R_SecondX = (nReflectionIndex * 2 - data->First.x + PositionX2) * ZoomIn / ZoomOut - px; R_SecondY = SecondY; } else if (form->NVector->ReflectionVH == 2) { R_FirstX = FirstX; R_FirstY = (nReflectionIndex * 2 - data->Second.y + PositionY2) * ZoomIn / ZoomOut - py; R_SecondX = SecondX; R_SecondY = (nReflectionIndex * 2 - data->First.y + PositionY2) * ZoomIn / ZoomOut - py; } } pw = data->PenThick / 2; // 090811 by david // Style Data(Color´Â ºí·¢, ColorFill, Pattern, Gradient Á¦¿Ü Çϰí ÀúÀå) if (method & 32) { tColor = data->Color, tBrush = data->Brush; bColorfill = data->bFill; bPatternfill = data->bPatternFill; bGradientfill = data->bGradientFill; data->Color = clBlack, data->Brush = clBlack; data->bFill = false; data->bPatternFill = false; data->bGradientFill = false; } gdp::Color penColor(GetRValue(data->Color), GetGValue(data->Color), GetBValue(data->Color)); gdp::Color FillColor(GetRValue(data->Brush), GetGValue(data->Brush), GetBValue(data->Brush)); gdp::Pen ObjectPen(penColor, data->PenThick * dZoom); if (nMode == 1) { // Tag ObjectPen.SetWidth(data->PenThick * dZoom); } gdp::SolidBrush ObjectBrush(FillColor); gdp::GraphicsPath gFillPath; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) gdp::GraphicsPath gRefFillPath; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- if (data->Kind == V_TEXTBOX) { pPoints = new gdp::PointF[5]; } else { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new gdp::PointF[(data->nCount + 1) * 3 + 1]; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (form->NVector->bVectorReflectionMode && (form->NVector->ReflectionVH == 1 || form->NVector->ReflectionVH == 2)) pRefPoints = new gdp::PointF[(data->nCount + 1) * 3 + 1]; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } else { pPoints = new gdp::PointF[data->nCount * 3 + 1]; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (form->NVector->bVectorReflectionMode && (form->NVector->ReflectionVH == 1 || form->NVector->ReflectionVH == 2)) pRefPoints = new gdp::PointF[data->nCount * 3 + 1]; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } } if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int i = 0; i < data->nCount * 3 + 1; i++) { pPoints[i].X = (data->pList[i].x - PositionX) * dZoom - px; pPoints[i].Y = (data->pList[i].y - PositionY) * dZoom - py; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (form->NVector->bVectorReflectionMode) { if (form->NVector->ReflectionVH == 1) { pRefPoints[i].X = ReflectionIndex * 2 - (data->pList[i].x - PositionX) * dZoom - px; pRefPoints[i].Y = (data->pList[i].y - PositionY) * dZoom - py; } if (form->NVector->ReflectionVH == 2) { pRefPoints[i].X = (data->pList[i].x - PositionX) * dZoom - px; pRefPoints[i].Y = ReflectionIndex * 2 - (data->pList[i].y - PositionY) * dZoom - py; } } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } } if (data->Kind == V_TEXTBOX) { StartX = (data->StartPoint.x - PositionX) * dZoom - px; StartY = (data->StartPoint.y - PositionY) * dZoom - py; CenterX = (data->CenterPoint.x - PositionX) * dZoom - px; CenterY = (data->CenterPoint.y - PositionY) * dZoom - py; OffsetX = PositionX; OffsetY = PositionY; // by linuxjun for CurvedVectorText FontZoom = dZoom; for (int i = 0; i < 5; i++) { pPoints[i].X = (data->pList[i].x - PositionX) * dZoom - px; pPoints[i].Y = (data->pList[i].y - PositionY) * dZoom - py; } if (form->NVector->bMergeMode && ParentData->bSelected) { CenterX = (FirstX + SecondX) / 2; CenterY = (FirstY + SecondY) / 2; } } if (form->NVector->bMergeMode && ParentData->bSelected) { // µÇµ¹¸®±â PositionX += MergeX; PositionY += MergeY; } //////// Closed Path last point and for nicer close if (data->bClosed && data->PenStyle == P_SOLID) { pPoints[data->nCount * 3] = pPoints[0]; pPoints[data->nCount * 3 + 1] = pPoints[1]; pPoints[data->nCount * 3 + 2] = pPoints[2]; pPoints[data->nCount * 3 + 3] = pPoints[3]; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (form->NVector->bVectorReflectionMode && (form->NVector->ReflectionVH == 1 || form->NVector->ReflectionVH == 2)) { pRefPoints[data->nCount * 3] = pRefPoints[0]; pRefPoints[data->nCount * 3 + 1] = pRefPoints[1]; pRefPoints[data->nCount * 3 + 2] = pRefPoints[2]; pRefPoints[data->nCount * 3 + 3] = pRefPoints[3]; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } //////// nDrawMode = GetROP2(dcDst); nFillMode = GetPolyFillMode(dcDst); if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { // Text´Â Pen°ú Brush°¡ ÇÊ¿ä ¾ø´Ù logbrush.lbStyle = BS_SOLID; logbrush.lbColor = data->Brush; logbrush.lbHatch = 0; if (data->bPatternFill && !data->bModified && ! (form->NVector->bProportion && data->bSelected)) { // PatternFill À϶§ int bltwidth, bltheight; HDC dcPattern = NULL, dcMask = NULL; MakePatternBitmap(data); if (!data->TBitmap) goto patternfail; if (!data->MaskBitmap) goto patternfail; if ((dcPattern = data->TBitmap->CreateDC()) == NULL) goto patternfail; if ((dcMask = data->MaskBitmap->CreateDC()) == NULL) goto patternfail; bltwidth = data->TBitmap->Width * dZoom; bltheight = data->TBitmap->Height * dZoom; // º¤ÅÍ ¿ÀºêÁ§Æ® ¾È¿¡ ä¿îºñÆ®¸Ê À̹ÌÁö Ãà¼Òº¸±â ÇßÀ» ¶§ Ä®¶ó³ª ÆÐÅÏÀÌ º¯ÁúµÇÁö ¾Êµµ·Ï ¼öÁ¤ - by monkman (2007.09.13) if (osVERSION < 2) { // 3.1, 95, 98 SetStretchBltMode(dcDst, COLORONCOLOR); } else { SetStretchBltMode(dcDst, HALFTONE); } StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcMask, 0, 0, data->MaskBitmap->Width, data->MaskBitmap->Height, SRCAND); StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcPattern, 0, 0, data->TBitmap->Width, data->TBitmap->Height, SRCPAINT); patternfail: if (dcPattern) { data->TBitmap->DeleteDC(dcPattern); dcPattern = NULL; } if (dcMask) { data->MaskBitmap->DeleteDC(dcMask); dcMask = NULL; } } else if (data->bFill) { // ColorFill À϶§ hBrush = CreateBrushIndirect(&logbrush); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); } else { // Fill X hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } if (data->bWinding) { gFillPath.SetFillMode(gdp::FillModeWinding); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) gRefFillPath.SetFillMode(gdp::FillModeWinding); // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } else { gFillPath.SetFillMode(gdp::FillModeAlternate); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) gRefFillPath.SetFillMode(gdp::FillModeAlternate); // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } logbrush.lbColor = data->Color; // ÆæÀÇ color¸¦ À§Çؼ­... switch(data->PenStyle) { case 0: nPenStyle = int(PS_SOLID); break; case 1: nPenStyle = int(PS_DASH); break; case 2: nPenStyle = int(PS_DOT); break; case 3: nPenStyle = int(PS_DASHDOT); break; case 4: nPenStyle = int(PS_DASHDOTDOT); break; case 5: nPenStyle = P_USERSTYLE; int count = 0; double temp[6] = { 0, 0, 0, 0, 0, 0 }; CheckUserDashedLine(data, temp, count); dashValues = new float[count]; for (int i = 0; i < count; i++) { dashValues[i] = temp[i]; } ObjectPen.SetDashPattern(dashValues, count); break; // DashStyleCustom = 5 } if (osVERSION < 2) { // 3.1, 95, 98 hPen = CreatePen(psSolid, int(data->PenThick * dZoom + 0.5), data->Color); } else { if (data->bRound) { // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapRound); } } else { ObjectPen.SetStartCap(gdp::LineCapRound); ObjectPen.SetEndCap(gdp::LineCapRound); } ObjectPen.SetLineJoin(gdp::LineJoinRound); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapRound); } else { if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapFlat); } } else { ObjectPen.SetStartCap(gdp::LineCapFlat); ObjectPen.SetEndCap(gdp::LineCapFlat); } ObjectPen.SetLineJoin(gdp::LineJoinMiter); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapFlat); } } hOldPen = (HPEN)SelectObject(dcDst, hPen); } else { nTemp = data->Font.lfHeight; data->Font.lfHeight = data->Font.lfHeight * dZoom + 0.5; if (data->Font.lfHeight == 0) data->Font.lfHeight = 1; } // ====================================== if (!data->ParentTextBox) { // by linuxjun for CurvedVectorText if (nMode == 3) { // PrintDraw PAINT_VECTOR; } else { PAINT_LINEDRAW_VECTOR; } } if (pPoints) delete[]pPoints; pPoints = NULL; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (form->NVector->bVectorReflectionMode && (form->NVector->ReflectionVH == 1 || form->NVector->ReflectionVH == 2)) { if (pRefPoints) delete[]pRefPoints; } pRefPoints = NULL; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { SelectObject(dcDst, hOldBrush); SelectObject(dcDst, hOldPen); } if (hBrush) DeleteObject(hBrush); if (hPen) DeleteObject(hPen); hOldPen = NULL; hOldBrush = NULL; hPen = NULL; hBrush = NULL; if (TempBitmap) { delete TempBitmap; TempBitmap = NULL; } if (!(form->NVector->bSelected)) data->bSelected = false; if (nPenStyle == P_USERSTYLE) delete[]dashValues; dashValues = NULL; // 20090220 °¢µµº¯È¯ reverseÇÊ¿ä for (int l = 0; l < data->nCount * 3 + 1; l++) { double dx = data->pList[l].x - pTempList[3 * k].x; double dy = data->pList[l].y - pTempList[3 * k].y; data->pList[l].x = dx * cos(-tangentlist[k]) - dy * sin (-tangentlist[k]) + pTempList[3 * k].x; data->pList[l].y = dx * sin(-tangentlist[k]) + dy * cos (-tangentlist[k]) + pTempList[3 * k].y; } for (int l = 0; l < data->nCount * 3 + 1; l++) { data->pList[l].x = data->pList[l].x + ParentData->centerX - pTempList [3 * k].x; data->pList[l].y = data->pList[l].y + ParentData->centerY - pTempList [3 * k].y; } // Àӽ÷Πó¸®ÇÑ ³»¿ëÀ» µÇµ¹¸®´Â ºÎºÐ - 090811 by david if (method & 32) { data->Color = tColor, data->Brush = tBrush; data->bFill = bColorfill; data->bPatternFill = bPatternfill; data->bGradientFill = bGradientfill; } } } if (DataList) { for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (data) delete data; } DataList->Clear(); delete DataList; DataList = NULL; } if (tangentlist) delete[]tangentlist; tangentlist = NULL; if (!form->NVector->bSelected){ ptNumber = -1; nSelPos = 0; } // if (form->NVector->bSelected && !(form->NVector->bMergeMode) && bSelectedLine) // DrawSelectedLine(dcDst, px, py, form); // else { // ptNumber = -1; // nSelPos = 0; // } // if (VectorForm) { // nInstanceNumber¸¦ Á÷Á¢ ÁÙ °æ¿ì¸¦ »ý°¢ÇÒ Çʿ䰡 ¾ø´Ù - by monkman (2009.04.08) // if (form->NVector->step != 0 && form->Number == MainImageForm->Number && ! // (NVector->bUserInput)) // DrawCurrentObject(dcDst, px, py); // if (NVector->bUserInput) // DrawUserObject(dcDst, px, py); // 2005 Vector upgrade shin 0228 // } // ¸Þ¸ð¸® ÇØÁ¦ - by monkman (2009.04.16) if (pTempList) { HeapFree(GetProcessHeap(), 0, pTempList); } pTempList = NULL; pPoints = NULL; pRefPoints = NULL; return; fail: if (DataList) { for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (data) delete data; } DataList->Clear(); delete DataList; DataList = NULL; } if (tangentlist) delete[]tangentlist; tangentlist = NULL; if (data) delete data; data = NULL; // ¸Þ¸ð¸® ÇØÁ¦ - by monkman (2009.04.16) if (pTempList) { HeapFree(GetProcessHeap(), 0, pTempList); } pTempList = NULL; if (pPoints) delete[]pPoints; pPoints = NULL; if (pRefPoints) delete[]pRefPoints; pRefPoints = NULL; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::DrawMotiveObjectsMask(HDC dcDst, TVecData *ParentData, TMainImageForm *form, double px, double py, int nMode, int nPositionX, int nPositionY, double dZoom, int nInstanceNumber) { TList *tDataList = ParentData->ChildList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) TList *DataList = new TList; TList * ResultBezierPointList; TPointList *tempPointList; bool bSelectedLine; double rx, ry, ratio; DPOINT firstPoint, onPoint, normalPoint, tempCurpt, tempOldpt; DPOINT *pTempList = NULL; double dInterval; TBezierPointList * BezierPointList = new TBezierPointList(); // »ý¼º BezierPointList->Init(ParentData); double CurveLength = BezierPointList->GetCurveLength(); int nSegment; // int quotient = int(CurveLength/((ParentData->proportion)*(ParentData->childwidth))); // if (quotient==0) quotient = 1; switch(ParentData->mode) { case 0: // ²Ë ä¿ì±â if (ParentData->proportion == 0) { ParentData->proportion = 1; if (VectorForm) VectorForm->eMotiveProportion->Value = 1; } if (ParentData->childwidth == 0) { ParentData->childwidth = 1; } nSegment = int(CurveLength / ((ParentData->proportion) * (ParentData->childwidth))); if (nSegment == 0) nSegment = 1; ParentData->gap = double(CurveLength / nSegment); ParentData->motivecount = nSegment; break; case 1: // °³¼ö ¼³Á¤ nSegment = ParentData->motivecount; if (nSegment == 0) { nSegment = 1; if (VectorForm) VectorForm->eMotiveCount->Value = 1; } ParentData->gap = double(CurveLength / nSegment); break; case 2: // °£°Ý ¼³Á¤ if (ParentData->gap == 0) { ParentData->gap = 1; if (VectorForm) VectorForm->eMotiveGap->Value = 1; } nSegment = int(CurveLength / ParentData->gap); if (nSegment == 0) nSegment = 1; ParentData->motivecount = nSegment; break; } int count = 1; ResultBezierPointList = BezierPointList->Calculate(ParentData, nSegment); if (!ResultBezierPointList) { delete DataList; DataList; delete BezierPointList; BezierPointList = NULL; return; } pTempList = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * (nSegment * 3 + 1)); double *tangentlist = new double[nSegment + 1]; // ±â¿ï±â¸¦ °¡Áö°í ÀÖ´Â ¹è¿­ firstPoint = FindingNormalOnBezier(&ParentData->pList[0], 0, 0, 0); pTempList[0].x = firstPoint.x; pTempList[0].y = firstPoint.y; pTempList[1].x = firstPoint.x; pTempList[1].y = firstPoint.y; tangentlist[0] = FindCurveTangent(&ParentData->pList[0], 0); for (int i = 0; i < ResultBezierPointList->Count; i++) { tempPointList = (TPointList*)ResultBezierPointList->Items[i]; for (tempPointList->First(); !tempPointList->IsDone(); tempPointList->Next()) { dInterval = tempPointList->CurrentDouble(); // BezierCurve À§ÀÇ Á¡À§Ä¡ // onPoint = FindingPointOnBezier(&tData->pList[i*3], dInterval); // ãÀº Á¡ÀÇ NormalÀÇ À§Ä¡ (ãÀº Á¡Àº ResultBezierPointList¾È¿¡ ÀÖÀ½) normalPoint = FindingNormalOnBezier(&ParentData->pList[i * 3], dInterval, 0, count % 2); tangentlist[count] = FindCurveTangent(&ParentData->pList[i * 3], dInterval); pTempList[count * 3 - 2] = pTempList[count * 3 - 3]; pTempList[count * 3 - 1].x = normalPoint.x; pTempList[count * 3 - 1].y = normalPoint.y; pTempList[count * 3].x = normalPoint.x; pTempList[count * 3].y = normalPoint.y; count++; tempOldpt = tempCurpt; } } if (ParentData->bClosed) { // ´ÝÈù ¿ÀºêÁ§Æ®ÀÇ °æ¿ì ³¡Á¡°ú ùÁ¡À» °°°Ô. pTempList[nSegment * 3] = pTempList[0]; pTempList[nSegment * 3 - 1] = pTempList[0]; } delete BezierPointList; BezierPointList = NULL; // È­¸é¿¡ º¸À̱â HPEN hOldPen = NULL, hPen = NULL; HBRUSH hOldBrush = NULL, hBrush = NULL; LOGBRUSH logbrush; int nDrawMode, nFillMode, nTemp, nPenStyle; RGBQUAD rgb; HFONT font = NULL, oldfont = NULL; Graphics::TBitmap *TempBitmap = NULL; int ZoomIn = form->iMainImage->ZoomIn; int ZoomOut = form->iMainImage->ZoomOut; int PositionX = form->sbHorz->Position; int PositionY = form->sbVert->Position; int FirstX, FirstY, SecondX, SecondY; double CenterX, CenterY, FontZoom = 1.0; int OffsetX, OffsetY; // by linuxjun for CurvedVectorText int StartX, StartY; int pw; float* dashValues = NULL; // motive childÀÇ È®´ë Ãà¼Ò /* for (int i =0; i < DataList->Count; i++) { data = (TVecData *)DataList->Items[i]; for (int l = 0; l < data->nCount*3 +1; l++) { data->pList[l].x = (data->pList[l].x - ParentData->centerX) * ParentData->proportion + ParentData->centerX; data->pList[l].y = (data->pList[l].y - ParentData->centerY) * ParentData->proportion + ParentData->centerY; } } */ TVecData *tdata; // motive childÀÇ È®´ë Ãà¼Ò for (int i = 0; i < tDataList->Count; i++) { data = (TVecData*)tDataList->Items[i]; tdata = new TVecData(data->GetInstNum()); tdata->Copy(data); tdata->bSelected = data->bSelected; // º¹»ç ºÙ¿©³Ö±â ½Ã º¸¿©Áöµµ·Ï - by monkman (2009.04.02) for (int l = 0; l < data->nCount * 3 + 1; l++) { tdata->pList[l].x = (data->pList[l].x - ParentData->centerX) * ParentData->proportion + ParentData->centerX; tdata->pList[l].y = (data->pList[l].y - ParentData->centerY) * ParentData->proportion + ParentData->centerY; } DataList->Add(tdata); } // ------------------------------------------ // Mode Ãß°¡ - by monkman (2009.04.09) switch(nMode) { case 0: dZoom = (double)ZoomIn / ZoomOut; bSelectedLine = true; break; case 1: // Tag // dZoom = 1; PositionX = nPositionX; PositionY = nPositionY; bSelectedLine = false; break; case 2: // Scale 1:1 ZoomIn = 1; ZoomOut = 1; dZoom = 1; PositionX = 0; PositionY = 0; bSelectedLine = false; break; case 3: // Full View PositionX = nPositionX; PositionY = nPositionY; bSelectedLine = false; break; case 4: // bSelectedLine == false dZoom = (double)ZoomIn / ZoomOut; bSelectedLine = false; break; case 5: // Scale 1:1 Pattern Fill ÇÏÁö ¾ÊÀ½ dZoom = 1; PositionX = 0; PositionY = 0; bSelectedLine = false; break; case 6: // DrawSpreadObject() ¿ë dZoom = (double)ZoomIn / ZoomOut; PositionX = nPositionX; PositionY = nPositionY; bSelectedLine = false; } gdp::Graphics graphics(dcDst); // using GDI+ gdp::PointF *pPoints = NULL; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) gdp::PointF *pRefPoints = NULL; int ReflectionIndex = -1; if (form->NVector->bVectorReflectionMode && ((form->NVector->ReflectionVH == 1 && form->NVector->ReflectionVIndex >= 0) || (form->NVector->ReflectionVH == 2 && form->NVector->ReflectionHIndex >= 0))) { // ¼öÁ÷ ±âÁؼ± if (form->NVector->ReflectionVH == 1) ReflectionIndex = (form->NVector->ReflectionVIndex - PositionX) * dZoom; // ¼öÆò ±âÁؼ± if (form->NVector->ReflectionVH == 2) ReflectionIndex = (form->NVector->ReflectionHIndex - PositionY) * dZoom; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- for (int k = 0; k < nSegment; k++) { for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; for (int l = 0; l < data->nCount * 3 + 1; l++) { data->pList[l].x = data->pList[l].x - ParentData->centerX + pTempList [3 * k].x; data->pList[l].y = data->pList[l].y - ParentData->centerY + pTempList [3 * k].y; } for (int l = 0; l < data->nCount * 3 + 1; l++) { double dx = data->pList[l].x - pTempList[3 * k].x; double dy = data->pList[l].y - pTempList[3 * k].y; data->pList[l].x = dx * cos(tangentlist[k]) - dy * sin(tangentlist[k]) + pTempList[3 * k].x; data->pList[l].y = dx * sin(tangentlist[k]) + dy * cos(tangentlist[k]) + pTempList[3 * k].y; } if (nMode == 1) { // Tag rx = (double)80 / form->iMainImage->Bitmap->Width; ry = (double)100 / form->iMainImage->Bitmap->Height; if (rx > ry) ratio = ry; else ratio = rx; for (int l = 0; l < data->nCount * 3 + 1; l++) { data->pList[l].x *= rx; data->pList[l].y *= ry; } } // todo : ¿ø·¡´Â ¾Æ·¡ ¼Ò½º°¡ ÁÖ¼®Ã³¸® µÇ¾î ÀÖ¾úÀ½.. // ´Ù¸¥ ĵ¹ö½º±îÁö °°ÀÌ ¾÷µ¥ÀÌÆ®µÇ¹Ç·Î ÁÖ¼®Ã³¸® - by monkman (2004.10.05) // if (nInstanceNumber > 0) { if (!data->Equal(nInstanceNumber)) continue; // nInstanceNumber¸¦ Á÷Á¢ ÁÙ °æ¿ì Ãß°¡ - by monkman (2009.04.08) } else { if (!data->Equal(form->Number)) continue; } // object¸¶´Ù antialiasing¼³Á¤ if (data->bAntialiasing && !(form->NVector->bSelectedVectorMove)) graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); else graphics.SetSmoothingMode(gdp::SmoothingModeNone); if (form->NVector->bProportion && data->bSelected) { ProportionTransform(ParentData); // È®´ëÃà¼Ò½Ã¿¡´Â Á¡µéÀÇ TransformÀÌ °¡ÇØÁü } if (form->NVector->bMergeMode && data->bSelected) { // Merge Mode¿¡¼­ ¼±ÅÃµÈ ¿ÀºêÁ§Æ®ÀÇ ¸¶¿ì½º À̵¿¿¡ µû¸¥ ÁÂÇ¥ º¯°æ PositionX -= MergeX; PositionY -= MergeY; } SET_RECT; // gradientfill FirstX = (data->First.x - PositionX) * dZoom - px; FirstY = (data->First.y - PositionY) * dZoom - py; SecondX = (data->Second.x - PositionX) * dZoom - px; SecondY = (data->Second.y - PositionY) * dZoom - py; pw = data->PenThick / 2; gdp::Color penColor(0, 0, 0); gdp::Color FillColor(0, 0, 0); gdp::Pen ObjectPen(penColor, data->PenThick * dZoom); if (nMode == 1) { // Tag ObjectPen.SetWidth(data->PenThick * dZoom * ratio); } gdp::SolidBrush ObjectBrush(FillColor); gdp::GraphicsPath gFillPath; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) gdp::GraphicsPath gRefFillPath; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- if (data->Kind == V_TEXTBOX) { pPoints = new gdp::PointF[5]; } else { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new gdp::PointF[(data->nCount + 1) * 3 + 1]; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (form->NVector->bVectorReflectionMode && (form->NVector->ReflectionVH == 1 || form->NVector->ReflectionVH == 2)) pRefPoints = new gdp::PointF[(data->nCount + 1) * 3 + 1]; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } else { pPoints = new gdp::PointF[data->nCount * 3 + 1]; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (form->NVector->bVectorReflectionMode && (form->NVector->ReflectionVH == 1 || form->NVector->ReflectionVH == 2)) pRefPoints = new gdp::PointF[data->nCount * 3 + 1]; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } } if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int i = 0; i < data->nCount * 3 + 1; i++) { pPoints[i].X = (data->pList[i].x - PositionX) * dZoom - px; pPoints[i].Y = (data->pList[i].y - PositionY) * dZoom - py; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (form->NVector->bVectorReflectionMode) { if (form->NVector->ReflectionVH == 1) { pRefPoints[i].X = ReflectionIndex * 2 - (data->pList[i].x - PositionX) * dZoom - px; pRefPoints[i].Y = (data->pList[i].y - PositionY) * dZoom - py; } if (form->NVector->ReflectionVH == 2) { pRefPoints[i].X = (data->pList[i].x - PositionX) * dZoom - px; pRefPoints[i].Y = ReflectionIndex * 2 - (data->pList[i].y - PositionY) * dZoom - py; } } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } } if (data->Kind == V_TEXTBOX) { StartX = (data->StartPoint.x - PositionX) * dZoom - px; StartY = (data->StartPoint.y - PositionY) * dZoom - py; CenterX = (data->CenterPoint.x - PositionX) * dZoom - px; CenterY = (data->CenterPoint.y - PositionY) * dZoom - py; OffsetX = PositionX; OffsetY = PositionY; // by linuxjun for CurvedVectorText FontZoom = dZoom; for (int i = 0; i < 5; i++) { pPoints[i].X = (data->pList[i].x - PositionX) * dZoom - px; pPoints[i].Y = (data->pList[i].y - PositionY) * dZoom - py; } if (form->NVector->bMergeMode && data->bSelected) { CenterX = (FirstX + SecondX) / 2; CenterY = (FirstY + SecondY) / 2; } } if (form->NVector->bMergeMode && data->bSelected) { // µÇµ¹¸®±â PositionX += MergeX; PositionY += MergeY; } //////// Closed Path last point and for nicer close if (data->bClosed && data->PenStyle == P_SOLID) { pPoints[data->nCount * 3] = pPoints[0]; pPoints[data->nCount * 3 + 1] = pPoints[1]; pPoints[data->nCount * 3 + 2] = pPoints[2]; pPoints[data->nCount * 3 + 3] = pPoints[3]; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (form->NVector->bVectorReflectionMode && (form->NVector->ReflectionVH == 1 || form->NVector->ReflectionVH == 2)) { pRefPoints[data->nCount * 3] = pRefPoints[0]; pRefPoints[data->nCount * 3 + 1] = pRefPoints[1]; pRefPoints[data->nCount * 3 + 2] = pRefPoints[2]; pRefPoints[data->nCount * 3 + 3] = pRefPoints[3]; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } //////// nDrawMode = GetROP2(dcDst); nFillMode = GetPolyFillMode(dcDst); if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { // Text´Â Pen°ú Brush°¡ ÇÊ¿ä ¾ø´Ù logbrush.lbStyle = BS_SOLID; logbrush.lbColor = clBlack; logbrush.lbHatch = 0; if (data->bPatternFill && !data->bModified && ! (form->NVector->bProportion && data->bSelected)) { // PatternFill À϶§ int bltwidth, bltheight; HDC /* dcPattern = NULL, */ dcMask = NULL; MakePatternBitmap(data); // if (!data->TBitmap) goto patternfail; if (!data->MaskBitmap) goto patternfail; // if ((dcPattern = data->TBitmap->CreateDC())==NULL) goto patternfail; if ((dcMask = data->MaskBitmap->CreateDC()) == NULL) goto patternfail; bltwidth = data->TBitmap->Width * dZoom; bltheight = data->TBitmap->Height * dZoom; // º¤ÅÍ ¿ÀºêÁ§Æ® ¾È¿¡ ä¿îºñÆ®¸Ê À̹ÌÁö Ãà¼Òº¸±â ÇßÀ» ¶§ Ä®¶ó³ª ÆÐÅÏÀÌ º¯ÁúµÇÁö ¾Êµµ·Ï ¼öÁ¤ - by monkman (2007.09.13) if (osVERSION < 2) { // 3.1, 95, 98 SetStretchBltMode(dcDst, COLORONCOLOR); } else { SetStretchBltMode(dcDst, HALFTONE); } StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcMask, 0, 0, data->MaskBitmap->Width, data->MaskBitmap->Height, SRCAND); // StretchBlt(dcDst, FirstX, FirstY, bltwidth, bltheight, dcPattern, 0,0, // data->TBitmap->Width, data->TBitmap->Height, SRCPAINT); patternfail: // if (dcPattern) { data->TBitmap->DeleteDC(dcPattern); dcPattern = NULL; } if (dcMask) { data->MaskBitmap->DeleteDC(dcMask); dcMask = NULL; } } else if (data->bFill) { // ColorFill À϶§ hBrush = CreateBrushIndirect(&logbrush); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); } else { // Fill X hOldBrush = (HBRUSH)SelectObject(dcDst, GetStockObject(NULL_BRUSH)); } if (data->bWinding) { gFillPath.SetFillMode(gdp::FillModeWinding); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) gRefFillPath.SetFillMode(gdp::FillModeWinding); // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } else { gFillPath.SetFillMode(gdp::FillModeAlternate); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) gRefFillPath.SetFillMode(gdp::FillModeAlternate); // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } logbrush.lbColor = clBlack; // ÆæÀÇ color¸¦ À§Çؼ­... switch(data->PenStyle) { case 0: nPenStyle = int(PS_SOLID); break; case 1: nPenStyle = int(PS_DASH); break; case 2: nPenStyle = int(PS_DOT); break; case 3: nPenStyle = int(PS_DASHDOT); break; case 4: nPenStyle = int(PS_DASHDOTDOT); break; case 5: nPenStyle = P_USERSTYLE; int count = 0; double temp[6] = { 0, 0, 0, 0, 0, 0 }; CheckUserDashedLine(data, temp, count); dashValues = new float[count]; for (int i = 0; i < count; i++) { dashValues[i] = temp[i]; } ObjectPen.SetDashPattern(dashValues, count); break; // DashStyleCustom = 5 } if (osVERSION < 2) { // 3.1, 95, 98 hPen = CreatePen(psSolid, int(data->PenThick * dZoom + 0.5), data->Color); hOldPen = (HPEN)SelectObject(dcDst, hPen); } else { if (data->bRound) { // win 2000, NT¿¡¼­¸¸ Á¦´ë·Î ÀÛµ¿ÇÑ´Ù if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapRound); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapRound); } } else { ObjectPen.SetStartCap(gdp::LineCapRound); ObjectPen.SetEndCap(gdp::LineCapRound); } ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapRound); } else { if (data->CapStyle[0] == 1 && data->ArrowCap){ // arrow gdp::AdjustableArrowCap arrowCap(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomStartCap(dynamic_cast(&arrowCap)); if (data->ArrowCap->bShowArrowBoth){ gdp::AdjustableArrowCap arrowCap2(data->ArrowCap->LineCapHeight, data->ArrowCap->LineCapWidth, data->ArrowCap->bFillLineCap); arrowCap2.SetWidthScale(data->ArrowCap->LineCapWidthScale); arrowCap2.SetStrokeCap(gdp::LineCapFlat); ObjectPen.SetCustomEndCap(dynamic_cast(&arrowCap2)); } else { ObjectPen.SetEndCap(gdp::LineCapFlat); } } else { ObjectPen.SetStartCap(gdp::LineCapFlat); ObjectPen.SetEndCap(gdp::LineCapFlat); } ObjectPen.SetLineJoin(gdp::LineJoinMiter); ObjectPen.SetDashStyle((gdp::DashStyle)nPenStyle); ObjectPen.SetDashCap(gdp::DashCapFlat); } } } else { nTemp = data->Font.lfHeight; data->Font.lfHeight = data->Font.lfHeight * dZoom + 0.5; if (data->Font.lfHeight == 0) data->Font.lfHeight = 1; } // ====================================== if (!data->ParentTextBox) { // by linuxjun for CurvedVectorText PAINT_LINEDRAW_VECTOR_MASK; } if (pPoints) delete[]pPoints; pPoints = NULL; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.02.22) if (form->NVector->bVectorReflectionMode && (form->NVector->ReflectionVH == 1 || form->NVector->ReflectionVH == 2)) { if (pRefPoints) delete[]pRefPoints; } pRefPoints = NULL; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- if (data->Kind != V_TEXTBOX && data->Kind != V_TEXT) { SelectObject(dcDst, hOldBrush); SelectObject(dcDst, hOldPen); } if (hBrush) DeleteObject(hBrush); if (hPen) DeleteObject(hPen); hOldPen = NULL; hOldBrush = NULL; hPen = NULL; hBrush = NULL; if (TempBitmap) { delete TempBitmap; TempBitmap = NULL; } if (!(form->NVector->bSelected)) data->bSelected = false; if (nPenStyle == P_USERSTYLE && dashValues) delete[]dashValues; dashValues = NULL; if (form->NVector->bProportion && data->bSelected) ProportionInverseTransform(ParentData); // TransformÀÌ °¡ÇØÁø Á¡À» ´Ù½Ã µÇµ¹¸² /* if (form->bProportion && data->bSelected && data->Kind == V_TEXTBOX) // by maxleo21c { data->ProportionFirst.x = (data->ProportionFirst.x - PositionX) * dZoom -px; data->ProportionFirst.y = (data->ProportionFirst.y - PositionY) * dZoom -py; for (int j = 0; j < 5; j++) { Temp[j].x = (Temp[j].x - PositionX) * dZoom -px; Temp[j].y = (Temp[j].y - PositionY) * dZoom -py; } DrawProportionTextBox(dcDst, data, px, py); // È®´ë/Ãà¼ÒµÇ´Â ±ÛÀÚ¸¦ º¸¿©ÁÖ±â À§Çؼ­ } */ if (nMode == 1) { // Tag for (int l = 0; l < data->nCount * 3 + 1; l++) { data->pList[l].x /= rx; data->pList[l].y /= ry; } } // 20090220 °¢µµº¯È¯ reverseÇÊ¿ä for (int l = 0; l < data->nCount * 3 + 1; l++) { double dx = data->pList[l].x - pTempList[3 * k].x; double dy = data->pList[l].y - pTempList[3 * k].y; data->pList[l].x = dx * cos(-tangentlist[k]) - dy * sin (-tangentlist[k]) + pTempList[3 * k].x; data->pList[l].y = dx * sin(-tangentlist[k]) + dy * cos (-tangentlist[k]) + pTempList[3 * k].y; } for (int l = 0; l < data->nCount * 3 + 1; l++) { data->pList[l].x = data->pList[l].x + ParentData->centerX - pTempList [3 * k].x; data->pList[l].y = data->pList[l].y + ParentData->centerY - pTempList [3 * k].y; } } } if (DataList) { for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (data) delete data; } DataList->Clear(); delete DataList; DataList = NULL; } if (tangentlist) delete[]tangentlist; tangentlist = NULL; // ¸Þ¸ð¸® ÇØÁ¦ - by monkman (2009.04.16) if (pTempList) { HeapFree(GetProcessHeap(), 0, pTempList); } pTempList = NULL; pPoints = NULL; pRefPoints = NULL; if (!form->NVector->bSelected){ ptNumber = -1; nSelPos = 0; } // if (form->NVector->bSelected && !(form->NVector->bMergeMode) && bSelectedLine) // DrawSelectedLine(dcDst, px, py, form); // else { // ptNumber = -1; // nSelPos = 0; // } // if (form->NVector->bRotation) // DrawRotationLine(dcDst, px, py); // if (form->NVector->bPatternMode && form->NVector->PatternStep) // DrawSubBitmap(dcDst, px, py); // if (VectorForm) { // nInstanceNumber¸¦ Á÷Á¢ ÁÙ °æ¿ì¸¦ »ý°¢ÇÒ Çʿ䰡 ¾ø´Ù - by monkman (2009.04.08) // if (form->NVector->step != 0 && form->Number == MainImageForm->Number && ! // (NVector->bUserInput)) // DrawCurrentObject(dcDst, px, py); // if (NVector->bUserInput) // DrawUserObject(dcDst, px, py); // 2005 Vector upgrade shin 0228 // } return; fail: if (DataList) { for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (data) delete data; } DataList->Clear(); delete DataList; DataList = NULL; } if (tangentlist) delete[]tangentlist; tangentlist = NULL; if (data) delete data; data = NULL; // ¸Þ¸ð¸® ÇØÁ¦ - by monkman (2009.04.16) if (pTempList) { HeapFree(GetProcessHeap(), 0, pTempList); } pTempList = NULL; if (pPoints) delete[]pPoints; pPoints = NULL; if (pRefPoints) delete[]pRefPoints; pRefPoints = NULL; } // --------------------------------------------------------------------------- /// tempChildList¸¦ ±³Ã¼ÇÏ´Â ÇÔ¼ö /** ±âÁ¸¿¡ ÀÖ´Â tempChildList¸¦ ¼±ÅÃÇÑ TVecMotiveÀÇ MotiveList·Î ±³Ã¼ÇÏ´Â ÇÔ¼ö. */ void __fastcall TVecDraw::MotiveToChild(TVecMotive *Motive) { BEGIN_LOG(""); TVecData *Child = NULL, *ChildFromMotive = NULL; // tempChildList¸¦ clear if (tempChildList) { for (int i = 0; i < tempChildList->Count; i++) { Child = (TVecData*)tempChildList->Items[i]; if (Child) delete Child; Child = NULL; } tempChildList->Clear(); } for (int i = 0; i < Motive->MotiveList->Count; i++) { Child = new TVecData(MainImageForm->Number); ChildFromMotive = (TVecData*)Motive->MotiveList->Items[i]; Child->Copy(ChildFromMotive); tempChildList->Add(Child); } END_LOG; } // --------------------------------------------------------------------------- /// ¼±ÅÃÇÑ VecDataÀÇ ChildList¸¦ ÇöÀç tempChildList·Î ¹Ù²Ù¾îÁÖ´Â ÇÔ¼ö. /** ¼±ÅÃµÈ VecData¸¦ ¹ÞÀº TVecMotiveÀÇ MotiveList¸¦ Child·Î ÇÏ¿© MotiveObject·Î ¸¸µç´Ù. */ void __fastcall TVecDraw::ChangeMotiveChild(TVecMotive *Motive) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *Parent = NULL, *Child = NULL, *ChildFromMotive = NULL; // Undo Ãß°¡ - by monkman (2009.04.09)--¼±ÅÃµÈ ÆÄÀϸ¸ ó¸®ÇØ¾ß ÇÑ´Ù. ±×·¡¼­ ÁÖ¼® ó¸® ÈÄ ¾Æ·¡ Ãß°¡ by david 090506 // UndoSave(VU_DELETE, DataList->Count-1, true); // UndoSave(VU_MOTIVECREATE, DataList->Count-1, false); for (int i = 0; i < DataList->Count; i++) { Parent = (TVecData*)DataList->Items[i]; if (Parent->bSelected) { if (Parent->Kind == V_TEXTBOX) { Application->MessageBox(IDS_MESSAGE012.c_str(), L"Warning", MB_OK); } else { // ¼±ÅÃµÈ ÆÄÀϸ¸ ó¸®ÇØ¾ß ÇÑ´Ù. ±×·¡¼­ ÁÖ¼® ó¸® ÈÄ ¾Æ·¡ Ãß°¡ by david 090506 UndoSave(VU_DELETE, i, true); UndoSave(VU_MOTIVECREATE, i, false); if (Parent->ChildList) { if (Parent->ChildList) { for (int k = 0; k < Parent->ChildList->Count; k++) { Child = (TVecData*)Parent->ChildList->Items[k]; if (Child) delete Child; Child = NULL; } Parent->ChildList->Clear(); } for (int j = 0; j < Motive->MotiveList->Count; j++) { Child = new TVecData(MainImageForm->Number); ChildFromMotive = (TVecData*)Motive->MotiveList->Items[j]; Child->Copy(ChildFromMotive); Parent->ChildList->Add(Child); } CalculateChild(Parent); Parent->ChildCount = Motive->MotiveList->Count; } else { Parent->ChildList = new TList; Parent->bMotive = true; for (int j = 0; j < Motive->MotiveList->Count; j++) { Child = new TVecData(MainImageForm->Number); ChildFromMotive = (TVecData*)Motive->MotiveList->Items[j]; Child->Copy(ChildFromMotive); Parent->ChildList->Add(Child); } CalculateChild(Parent); Parent->ChildCount = Motive->MotiveList->Count; } } } } TRect rect; rect = GetObjectRect(); // MainImageForm->iMainImage->RectPaint(rect); MainImageForm->iMainImage->Repaint(); FullViewForm->Image->Repaint(); END_LOG; } // --------------------------------------------------------------------------- /// ¼±ÅÃµÈ MotiveObjectÀÇ Á¤º¸·Î motivepanelÀ» ¼³Á¤ÇØÁÖ´Â ÇÔ¼ö /** ¼±ÅÃµÈ VecdataÁß¿¡ MotiveObject°¡ ÀÖÀ» °æ¿ì, ±× VecDataÀÇ Á¤º¸·Î MotivePanelÀ» ¼³Á¤½ÃÄÑÁØ´Ù. */ void __fastcall TVecDraw::InitMotivePanel() { TList *DataList = NVector->DataList; TVecData *Data; for (int i = 0; i < DataList->Count; i++) { Data = (TVecData*)DataList->Items[i]; if (Data->bSelected && Data->ChildList) { VectorForm->eMotiveProportion->Value = int(Data->proportion * 100); if (Data->mode == 0) { VectorForm->rbMotiveMax->Checked = true; } else if (Data->mode == 1) { VectorForm->rbMotiveCount->Checked = true; } else if (Data->mode == 2) { VectorForm->rbMotiveGap->Checked = true; } VectorForm->eMotiveCount->Value = Data->motivecount; switch(MainImageForm->CurrentUnit) { case uDot: VectorForm->eMotiveGap->Value = int(Data->gap); break; case uInch: VectorForm->eMotiveGap->Value = double (int(Data->gap / MainImageForm->CanvasInfor.DotsPerInch * 100) / 100.f); break; case uCm: VectorForm->eMotiveGap->Value = double (int(Data->gap / MainImageForm->CanvasInfor.DotsPerInch * 2.54 * 100) / 100.f); break; } break; } } VectorForm->lbMotiveGap->Caption = MainImageForm->UnitName(); VectorForm->V_MainItem = 1; switch(VectorForm->MotiveModeComboBox->ItemIndex) { case 0: // free VectorForm->V_Item = M_D_FREEDRAW; break; case 1: // oblique VectorForm->V_Item = M_D_LINE; break; case 2: // Rectangle VectorForm->V_Item = M_D_RECT; break; case 3: // Circle VectorForm->V_Item = M_D_CIRCLE; break; case 4: // Ellipse VectorForm->V_Item = M_D_ELLIPSE; break; case 5: // Curve VectorForm->V_Item = M_D_CURVE; VectorForm->LineType = 2; break; case 6: // Continuous Curve VectorForm->V_Item = M_D_CURVE; VectorForm->LineType = 3; break; case 7: // H/V Line VectorForm->V_Item = M_D_LINE; break; } } // --------------------------------------------------------------------------- /// ºó object »èÁ¦ void __fastcall TVecDraw::DeleteEmptyObject() { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *tdata; for (int i = 0; i < DataList->Count; i++) { tdata = (TVecData*)DataList->Items[i]; if (!tdata->Equal(MainImageForm->Number)) continue; if (tdata->nCount) continue; // text¿¡ ±ÛÀÚ°¡ ¾øÀ¸¸é nCount = 0ÀÌ´Ù. ±×·¸´Ù°í ÇØ¼­ empty object·Î // Áö¿ì¸é undo/redo µî ±âŸ ±â´É¿¡¼­ access°¡ ¹ß»ýÇÑ´Ù. // ÀÏ·¯ µî ±âŸ ÇÁ·Î±×·¥µµ ±ÛÀ» ¾²±â À§ÇØ object¸¦ ¸¸µé¾îÁö¸é ±ÛÀ» ¾²Áö // ¾Ê¾Æµµ Áö¿ìÁö ¾Ê´Â´Ù. undo/redo saveÇÒ ¶§ ó¸®ÇϱⰡ Èûµé´Ù. // ±ÛÀÌ À־ del·Î ¸ðµÎ Áö¿ï °æ¿ìµµ ¸¶Âù°¡ÁöÀÌ´Ù. if (tdata->Kind == V_TEXTBOX) continue; DataList->Remove(tdata); delete tdata; tdata = NULL; i--; } END_LOG; } // --------------------------------------------------------------------------- /// vector object º¹»ç, À̵¿ void __fastcall TVecDraw::MoveCopyVectorObject(bool bMove, int nReverse) { BEGIN_LOG(""); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // º¤ÅÍ ¿ÀºêÁ§Æ® º¹»ç, À̵¿Çϱâ - by monkman (2005.02.28) // (bMove : true-À̵¿ false-º¹»ç, nReflection : 0-None 1-Á¿ì¹ÝÀü 2-»óÇϹÝÀü 3-Á¿ì»óÇϹÝÀü) TList *DataList = NVector->DataList; TVecData *data = NULL, *cdata = NULL, *childdata = NULL; DPOINT dpFirst, dpSecond; double dpMotiveAxis; PasteRange = Rect(MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height, 0, 0); RECT rect = Rect(MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height, 0, 0); RECT TextBoxRect; int cenX = 0, cenY = 0; // ¹ÝÀü º¹»ç ½Ã Á᫐ Á¡ int nCount = DataList->Count; bool sw = true; if (!(NVector->bSelected)) { END_LOG; return; } PasteObjRange.left = 0; PasteObjRange.right = 0; PasteObjRange.top = 0; PasteObjRange.bottom = 0; // copyÇÏ´Â °æ¿ì¿¡ CopyList¸¦ ÃʱâÈ­ if (bMove == false) { for (int i = 0; i < CopyList->Count; i++) { data = (TVecData*)CopyList->Items[i]; if (data) { if (data->ParentTextBox) { delete data->ParentTextBox; data->ParentTextBox = NULL; } delete data; } data = NULL; } CopyList->Clear(); // ÇѲ¨¹ø¿¡ Áö¿ì´Â °ÍÀ¸·Î ¼öÁ¤ - by monkman (2009.03.31) } MaxThick = 0; // ±âÁØÁ¡À» ±¸Çϱâ À§ÇØ ¼±ÅÃµÈ ¿µ¿ªÀ» ±¸ÇÑ´Ù for (int i = 0; i < nCount; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->Kind == V_TEXTBOX) { for (int j = 0; j < 5; j++) { rect.left = min(rect.left, data->pList[j].x); rect.top = min(rect.top, data->pList[j].y); rect.right = max(rect.right, data->pList[j].x); rect.bottom = max(rect.bottom, data->pList[j].y); } } else { for (int j = 0; j < data->nCount * 3 + 1; j++) { rect.left = min(rect.left, data->pList[j].x); rect.top = min(rect.top, data->pList[j].y); rect.right = max(rect.right, data->pList[j].x); rect.bottom = max(rect.bottom, data->pList[j].y); } } } cenX = (rect.right - rect.left) / 2; // ¹ÝÀü º¹»ç ½Ã »ç¿ëÇÒ ±âÁØÁ¡ (XÁÂÇ¥) cenY = (rect.bottom - rect.top) / 2; // ¹ÝÀü º¹»ç ½Ã »ç¿ëÇÒ ±âÁØÁ¡ (YÁÂÇ¥) PasteObjRange = rect; //ZŰ·Î ¼öÁ÷/¼öÆò À̵¿/º¹»ç¿¡ »ç¿ë for (int i = 0; i < nCount; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (bMove) { // À̵¿ ½Ã cdata = data; if (cdata->ParentTextBox) UndoSave(VU_TEXTMOVE, i, sw); else UndoSave(VU_MODIFY, i, sw); sw = false; } else { // º¹»ç ½Ã // -->by linuxjun for CurvedVectorText if (data->ParentTextBox) { cdata = new TVecData(MainImageForm->Number); cdata->Copy(data->ParentTextBox); cdata = cdata->ListOfAllLine->CurveData; } else { // <--by linuxjun for CurvedVectorText cdata = new TVecData(MainImageForm->Number); cdata->Copy(data); } data->bSelected = false; cdata->bSelected = true; } // ¿øº»ÀÇ ¼±ÅÃÀ» ÇØÁ¦ÇÑ´Ù - by monkman (2009.04.02) if (cdata->bMotive && cdata->ChildList && cdata->ChildList->Count) { for (int j = 0; j < cdata->ChildList->Count; j++) { childdata = (TVecData*)data->ChildList->Items[j]; // ¿øº» childdata->bSelected = false; childdata = (TVecData*)cdata->ChildList->Items[j]; // º¹»çº» childdata->bSelected = true; } } // cdata->GroupIndex = 0; // GroupIndex´Â copy¾ÈµÇ°Ô.. => copyµÇµµ·Ï Çϱâ À§ÇØ ÁÖ¼®Ã³¸®ÇÔ. // cdata->First.x = MaxInt; cdata->First.y = MaxInt; // cdata->Second.x = 0; cdata->Second.y = 0; if (cdata->Kind == V_TEXTBOX) { int tempx, tempy; cdata->CenterPoint.x = (cdata->First.x + cdata->Second.x) / 2; cdata->CenterPoint.y = (cdata->First.y + cdata->Second.y) / 2; tempx = abs(cdata->First.x - cdata->CenterPoint.x); tempy = abs(cdata->First.y - cdata->CenterPoint.y); switch(nReverse) { case 0: // ¹ÝÀü ¾øÀ½ cdata->StartPoint.x = cdata->StartPoint.x - rect.left; cdata->StartPoint.y = cdata->StartPoint.y - rect.top; for (int j = 0; j < 5; j++) { cdata->pList[j].x = cdata->pList[j].x - rect.left; cdata->pList[j].y = cdata->pList[j].y - rect.top; } cdata->CenterPoint.x = cdata->CenterPoint.x - rect.left; cdata->CenterPoint.y = cdata->CenterPoint.y - rect.top; cdata->First.x = cdata->CenterPoint.x - tempx; cdata->First.y = cdata->CenterPoint.y - tempy; cdata->Second.x = cdata->CenterPoint.x + tempx; cdata->Second.y = cdata->CenterPoint.y + tempy; break; case 1: // Á¿ì·Î ¹ÝÀü // cdata->StartPoint.x = ((rect.right-cenX)*2 - cdata->StartPoint.x) - rect.left; // cdata->StartPoint.y = cdata->StartPoint.y - rect.top; for (int j = 0; j < 5; j++) { cdata->pList[j].x = ((rect.right - cenX) * 2 - cdata->pList[j].x) - rect.left; cdata->pList[j].y = cdata->pList[j].y - rect.top; // cdata->First.x = min(cdata->First.x, cdata->pList[j].x); // cdata->First.y = min(cdata->First.y, cdata->pList[j].y); // cdata->Second.x = max(cdata->Second.x, cdata->pList[j].x); // cdata->Second.y = max(cdata->Second.y, cdata->pList[j].y); } cdata->StartPoint.x = cdata->First.x; cdata->StartPoint.y = cdata->StartPoint.y - rect.top; cdata->CenterPoint.x = ((rect.right - cenX) * 2 - cdata->CenterPoint.x) - rect.left; cdata->CenterPoint.y = cdata->CenterPoint.y - rect.top; cdata->First.x = cdata->CenterPoint.x - tempx; cdata->First.y = cdata->CenterPoint.y - tempy; cdata->Second.x = cdata->CenterPoint.x + tempx; cdata->Second.y = cdata->CenterPoint.y + tempy; break; case 2: // »óÇÏ·Î ¹ÝÀü cdata->StartPoint.x = cdata->StartPoint.x - rect.left; cdata->StartPoint.y = ((rect.bottom - cenY) * 2 - cdata->StartPoint.y) - rect.top; for (int j = 0; j < 5; j++) { cdata->pList[j].x = cdata->pList[j].x - rect.left; cdata->pList[j].y = ((rect.bottom - cenY) * 2 - cdata->pList[j].y) - rect.top; cdata->First.x = min(cdata->First.x, cdata->pList[j].x); cdata->First.y = min(cdata->First.y, cdata->pList[j].y); cdata->Second.x = max(cdata->Second.x, cdata->pList[j].x); cdata->Second.y = max(cdata->Second.y, cdata->pList[j].y); } cdata->CenterPoint.x = cdata->CenterPoint.x - rect.left; cdata->CenterPoint.y = ((rect.bottom - cenY) * 2 - cdata->CenterPoint.y) - rect.top; break; case 3: // Á¿ì»óÇÏ·Î ¹ÝÀü cdata->StartPoint.x = ((rect.right - cenX) * 2 - cdata->StartPoint.x) - rect.left; cdata->StartPoint.y = ((rect.bottom - cenY) * 2 - cdata->StartPoint.y) - rect.top; for (int j = 0; j < 5; j++) { cdata->pList[j].x = ((rect.right - cenX) * 2 - cdata->pList[j].x) - rect.left; cdata->pList[j].y = ((rect.bottom - cenY) * 2 - cdata->pList[j].y) - rect.top; cdata->First.x = min(cdata->First.x, cdata->pList[j].x); cdata->First.y = min(cdata->First.y, cdata->pList[j].y); cdata->Second.x = max(cdata->Second.x, cdata->pList[j].x); cdata->Second.y = max(cdata->Second.y, cdata->pList[j].y); } cdata->CenterPoint.x = ((rect.right - cenX) * 2 - cdata->CenterPoint.x) - rect.left; cdata->CenterPoint.y = ((rect.bottom - cenY) * 2 - cdata->CenterPoint.y) - rect.top; break; } } else { cdata->First.x = MaxInt; cdata->First.y = MaxInt; cdata->Second.x = 0; cdata->Second.y = 0; for (int j = 0; j < data->nCount * 3 + 1; j++) { switch(nReverse) { case 0: // ¹ÝÀü ¾øÀ½ cdata->pList[j].x = cdata->pList[j].x - rect.left; cdata->pList[j].y = cdata->pList[j].y - rect.top; break; case 1: // Á¿ì·Î ¹ÝÀü cdata->pList[j].x = ((rect.right - cenX) * 2 - cdata->pList[j].x) - rect.left; cdata->pList[j].y = cdata->pList[j].y - rect.top; break; case 2: // »óÇÏ·Î ¹ÝÀü cdata->pList[j].x = cdata->pList[j].x - rect.left; cdata->pList[j].y = ((rect.bottom - cenY) * 2 - cdata->pList[j].y) - rect.top; break; case 3: // Á¿ì»óÇÏ·Î ¹ÝÀü cdata->pList[j].x = ((rect.right - cenX) * 2 - cdata->pList[j].x) - rect.left; cdata->pList[j].y = ((rect.bottom - cenY) * 2 - cdata->pList[j].y) - rect.top; break; } cdata->First.x = min(cdata->First.x, cdata->pList[j].x); cdata->First.y = min(cdata->First.y, cdata->pList[j].y); cdata->Second.x = max(cdata->Second.x, cdata->pList[j].x); cdata->Second.y = max(cdata->Second.y, cdata->pList[j].y); } // Motive ¹ÝÀü ó¸® - by monkman (2009.05.01) if (nReverse == 1 && cdata->bMotive && cdata->ChildList && cdata->ChildList->Count > 0) { dpFirst.y = MaxInt; dpSecond.y = 0; for (int j = 0; j < cdata->ChildList->Count; j++) { childdata = (TVecData*)cdata->ChildList->Items[j]; for (int k = 0; k < childdata->nCount * 3 + 1; k++) { dpFirst.y = min(dpFirst.y, childdata->pList[k].y); dpSecond.y = max(dpSecond.y, childdata->pList[k].y); } } for (int j = 0; j < cdata->ChildList->Count; j++) { childdata = (TVecData*)cdata->ChildList->Items[j]; dpMotiveAxis = dpFirst.y + (dpSecond.y - dpFirst.y) / 2; for (int k = 0; k < childdata->nCount * 3 + 1; k++) { childdata->pList[k].y = (dpMotiveAxis * 2) - childdata->pList[k].y; } } } } if (!bMove) { if (cdata->bPatternFill) MakePatternBitmap(cdata); // Group¼³Á¤À» À¯ÁöÇϵµ·Ï Çϱâ À§ÇØ Àӽ÷ΠCopyList¿¡ copyÇϵµ·Ï ¼öÁ¤ CopyList->Add(cdata); /* /-->by linuxjun for CurvedVectorText if(cdata->ParentTextBox){ // DataList->Add(cdata->ParentTextBox); // DataList->Add(cdata); // UndoSave(VU_TEXTCREATE, DataList->Count-2, sw); DataList->Add(cdata); DataList->Add(cdata->ParentTextBox); UndoSave(VU_TEXTCREATE, DataList->Count-1, sw); }else{ //<--by linuxjun for CurvedVectorText DataList->Add(cdata); UndoSave(VU_CREATE, DataList->Count-1, sw); } sw = false; */ } } /////////////// if (!bMove) { // ±âÁ¸ object¸¦ º¹»çÇÏ¿© ºÙ¿©³ÖÀ» ¶§ ±×·ìÀÌ ¼³Á¤µÈ °æ¿ì¿¡µµ // ±×·ì ¼³Á¤ÀÌ Ç®¸®µµ·Ï(Áï, GroupIndex = 0) µÇ¾î ÀÖ´ø °ÍÀ» // »õ·Î¿î GroupIndex¸¦ ¼³Á¤ÇÏ¿© ±×·ìÀ» À¯Áö Çϵµ·Ï Çϱâ À§ÇØ ¾Æ·¡¿Í °°ÀÌ ¼öÁ¤ // º¹»çµÇ¾î ¿À´Â objectµéÀÇ GroupIndex¸¦ ¹Ì¸® Á¶»çÇÏ¿© tempIndexlist¿¡ ÀúÀå int srcGroupCnt = 0; int *tempIndexList = new int[CopyList->Count]; for (int i = 0; i < CopyList->Count; i++) { cdata = (TVecData*)CopyList->Items[i]; cdata->GroupIndex -= ((cdata->GroupIndex % 10000) & 0x000001ff); int cnt = 0; for (cnt = 0; cnt < srcGroupCnt; cnt++) { if (tempIndexList[cnt] == cdata->GroupIndex) break; } if (cnt == srcGroupCnt) tempIndexList[srcGroupCnt++] = cdata->GroupIndex; } // object¸¦ DataList¿¡ Ãß°¡ ÇÒ¶§ °°Àº group³¢¸® °°Àº GroupIndex¸¦ °¡Áöµµ·Ï ¼³Á¤ ÇÑ ÈÄ Ãß°¡ for (int i = 0; i < CopyList->Count; i++) { cdata = (TVecData*)CopyList->Items[i]; for (int idx = 0; idx < srcGroupCnt; idx++) { if (cdata->GroupIndex != 0 && cdata->GroupIndex == tempIndexList[idx]) { cdata->GroupIndex = MainImageForm->GroupIndexState + (idx + 1) * 10000; break; } } data = new TVecData(MainImageForm->Number); if (cdata->ParentTextBox) { data->Copy(cdata->ParentTextBox); data = data->ListOfAllLine->CurveData; } else { data->Copy(cdata); } data->bSelected = true; // -->by linuxjun for CurvedVectorText if (data->ParentTextBox) { DataList->Add(data); DataList->Add(data->ParentTextBox); UndoSave(VU_TEXTCREATE, DataList->Count - 1, sw); } else { // <--by linuxjun for CurvedVectorText DataList->Add(data); UndoSave(VU_CREATE, DataList->Count - 1, sw); } sw = false; } MainImageForm->GroupIndexState += (srcGroupCnt * 10000); if (tempIndexList) delete[]tempIndexList; tempIndexList = NULL; } /////////////// for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->Kind == V_TEXTBOX) { MaxThick = 5; // ¿Ü°û¿µ¿ªÀ» ´ëÃæ 5·Î Àâ´Â´Ù // PasteRange.left = min(PasteRange.left, min(data->First.x, data->Second.x)); // PasteRange.right = max(PasteRange.right, max(data->First.x, data->Second.x)); // PasteRange.top = min(PasteRange.top, min(data->First.y, data->Second.y)); // PasteRange.bottom = max(PasteRange.bottom, max(data->First.y, data->Second.y)); PasteRange.left = min(PasteRange.left, rect.left); PasteRange.right = max(PasteRange.right, rect.right); PasteRange.top = min(PasteRange.top, rect.top); PasteRange.bottom = max(PasteRange.bottom, rect.bottom); /* MaxThick = 5; // ¿Ü°û¿µ¿ªÀ» ´ëÃæ 5·Î Àâ´Â´Ù MakeTextBoxPointList(data); GetRectForMouseMove(data, rect); PasteRange.left = min(PasteRange.left, rect.left); PasteRange.right = max(PasteRange.right, rect.right); PasteRange.top = min(PasteRange.top, rect.top); PasteRange.bottom = max(PasteRange.bottom, rect.bottom); */ } else { MaxThick = max(MaxThick, data->PenThick + 1); // ÃÖ´ë Ææ ±½±â·Î ÇÑ´Ù PasteRange.left = min(PasteRange.left, min(data->First.x, data->Second.x)); PasteRange.right = max(PasteRange.right, max(data->First.x, data->Second.x)); PasteRange.top = min(PasteRange.top, min(data->First.y, data->Second.y)); PasteRange.bottom = max(PasteRange.bottom, max(data->First.y, data->Second.y)); } } /* //-->by linuxjun for CurvedVectorText if(cdata->ParentTextBox){ // DataList->Add(cdata->ParentTextBox); // DataList->Add(cdata); // UndoSave(VU_TEXTCREATE, DataList->Count-2, sw); data = cdata; } //<--by linuxjun for CurvedVectorText */ NVector->bSelected = true; NVector->bMergeMode = true; // ¸¶¿ì½º¸¦ µû¶ó´Ù´Ïµµ·Ï.. if (bMove) { rect.left -= MaxThick + 5; rect.top -= MaxThick + 5; rect.right += MaxThick + 5; rect.bottom += MaxThick + 5; MainImageForm->iMainImage->RectPaint(rect); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- END_LOG; } // --------------------------------------------------------------------------- /// ´ÜÃàŰ·Î vector object º¹»ç bool __fastcall TVecDraw::CopyVectorObjectFromHotKey(int X, int Y, TShiftState Shift) { BEGIN_LOG(""); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ´ÜÃàŰ·Î º¤ÅÍ ¿ÀºêÁ§Æ® º¹»çÇϱâ - by monkman (2005.02.14) // X, Y, Shift´Â ¾ÕÀ¸·Î ¹Ù²ðÁöµµ ¸ð¸¦ °¡´É¼º ¶§¹®¿¡ ÀÏ´Ü ¹Þ¾ÆµÐ´Ù.. TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) TVecData *cdata = NULL; int CopyCount = 0; int nCount; bool sw = true; bool bReturn = false; if (!(NVector->bSelected)) { END_LOG; return bReturn; } // CopyList ÃʱâÈ­ for (int i = 0; i < CopyList->Count; i++) { cdata = (TVecData*)CopyList->Items[i]; if (cdata) { if (cdata->ParentTextBox) { delete cdata->ParentTextBox; cdata->ParentTextBox = NULL; } } delete cdata; cdata = NULL; } CopyList->Clear(); // ÇѲ¨¹ø¿¡ Áö¿ì´Â °ÍÀ¸·Î ¼öÁ¤ - by monkman (2009.03.31) nCount = DataList->Count; for (int i = 0; i < nCount; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; // -->by linuxjun for CurvedVectorText 7¿ù¸» º¤ÅͶóÀεû¶ó ±Û¾¾½áÁö´Â ±â´É º¤ÅÍ Ä«ÇÇ¿¡·¯ ¼öÁ¤ /* if (data->ParentTextBox || (data->ListOfAllLine && data->ListOfAllLine->CurveData)) { data->bSelected = false; continue; } */ if (data->ListOfAllLine && data->ListOfAllLine->CurveData) { data->bSelected = false; continue; } // <--by linuxjun for CurvedVectorText 7¿ù¸» º¤ÅͶóÀεû¶ó ±Û¾¾½áÁö´Â ±â´É º¤ÅÍ Ä«ÇÇ¿¡·¯ ¼öÁ¤ if (!data->bSelected) continue; bReturn = true; // Group¼³Á¤À» À¯ÁöÇϵµ·Ï Çϱâ À§ÇØ Àӽ÷ΠCopyList¿¡ copyÇϵµ·Ï ¼öÁ¤ cdata = new TVecData(MainImageForm->Number); if (data->ParentTextBox) { cdata->Copy(data->ParentTextBox); cdata = cdata->ListOfAllLine->CurveData; } else { cdata->Copy(data); } data->bSelected = false; cdata->bSelected = true; CopyList->Add(cdata); /* cdata = new TVecData(MainImageForm->Number); //-->by linuxjun for CurvedVectorText 7¿ù¸» º¤ÅͶóÀεû¶ó ±Û¾¾½áÁö´Â ±â´É º¤ÅÍ Ä«ÇÇ¿¡·¯ ¼öÁ¤ if(data->ParentTextBox){ cdata->Copy(data->ParentTextBox); cdata->GroupIndex = 0; // GroupIndex´Â copy¾ÈµÇ°Ô.. data->bSelected = false; cdata->bSelected = false; cdata->ListOfAllLine->CurveData->bSelected = true; DataList->Add(cdata); DataList->Insert(DataList->Count-1,cdata->ListOfAllLine->CurveData); UndoSave(VU_TEXTCREATE, DataList->Count-1,true); //for new font }else{ //<--by linuxjun for CurvedVectorText 7¿ù¸» º¤ÅͶóÀεû¶ó ±Û¾¾½áÁö´Â ±â´É º¤ÅÍ Ä«ÇÇ¿¡·¯ ¼öÁ¤ cdata->Copy(data); cdata->GroupIndex = 0; // GroupIndex´Â copy¾ÈµÇ°Ô.. data->bSelected = false; cdata->bSelected = true; DataList->Add(cdata); UndoSave(VU_CREATE, DataList->Count-1, sw); } sw = false; */ } // ±âÁ¸ object¸¦ º¹»çÇÏ¿© ºÙ¿©³ÖÀ» ¶§ ±×·ìÀÌ ¼³Á¤µÈ °æ¿ì¿¡µµ // ±×·ì ¼³Á¤ÀÌ Ç®¸®µµ·Ï(Áï, GroupIndex = 0) µÇ¾î ÀÖ´ø °ÍÀ» // »õ·Î¿î GroupIndex¸¦ ¼³Á¤ÇÏ¿© ±×·ìÀ» À¯Áö Çϵµ·Ï Çϱâ À§ÇØ ¾Æ·¡¿Í °°ÀÌ ¼öÁ¤ // º¹»çµÇ¾î ¿À´Â objectµéÀÇ GroupIndex¸¦ ¹Ì¸® Á¶»çÇÏ¿© tempIndexlist¿¡ ÀúÀå int srcGroupCnt = 0; int *tempIndexList = new int[CopyList->Count]; for (int i = 0; i < CopyList->Count; i++) { cdata = (TVecData*)CopyList->Items[i]; cdata->GroupIndex -= ((cdata->GroupIndex % 10000) & 0x000001ff); int cnt = 0; for (cnt = 0; cnt < srcGroupCnt; cnt++) { if (tempIndexList[cnt] == cdata->GroupIndex) break; } if (cnt == srcGroupCnt) tempIndexList[srcGroupCnt++] = cdata->GroupIndex; } // object¸¦ DataList¿¡ Ãß°¡ ÇÒ¶§ °°Àº group³¢¸® °°Àº GroupIndex¸¦ °¡Áöµµ·Ï ¼³Á¤ ÇÑ ÈÄ Ãß°¡ for (int i = 0; i < CopyList->Count; i++) { cdata = (TVecData*)CopyList->Items[i]; for (int idx = 0; idx < srcGroupCnt; idx++) { if (cdata->GroupIndex != 0 && cdata->GroupIndex == tempIndexList[idx]) { cdata->GroupIndex = MainImageForm->GroupIndexState + (idx + 1) * 10000; break; } } data = new TVecData(MainImageForm->Number); if (cdata->ParentTextBox) { data->Copy(cdata->ParentTextBox); data = data->ListOfAllLine->CurveData; } else { data->Copy(cdata); } data->bSelected = true; // -->by linuxjun for CurvedVectorText if (data->ParentTextBox) { DataList->Add(data); DataList->Add(data->ParentTextBox); UndoSave(VU_TEXTCREATE, DataList->Count - 1, sw); } else { // <--by linuxjun for CurvedVectorText DataList->Add(data); UndoSave(VU_CREATE, DataList->Count - 1, sw); } sw = false; } MainImageForm->GroupIndexState += (srcGroupCnt * 10000); if (tempIndexList) delete[]tempIndexList; tempIndexList = NULL; NVector->bSelected = true; END_LOG; return bReturn; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } // --------------------------------------------------------------------------- /// objectÀÇ Ææ±½±â º¯°æ void __fastcall TVecDraw::ChangeObjectThick(double Thick, bool multi) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) RECT rc = Rect(50000, 50000, 0, 0); bool sw = true; double oldThick = 0.0; if (multi) { // ¿©·¯°³ µ¿½Ã¿¡ for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; UndoSave(VU_MODIFY, i, sw); sw = false; // data->PenThick += Thick; // 2005 Vector upgrade shin 0329 // combobox¿¡¼­ 1·Î º¯°æÇϴ°Ͱú ±¸ºÐÀ§ÇØ topclickÀº -2·Î, bottomclickÀº -1·Î ³ªÅ¸³¿. oldThick = data->PenThick; if (Thick == -1 || Thick == -2) { if (Thick == -1) { if (data->PenThick == 1) { data->PenThick = 0.75; } else if (data->PenThick == 0.75) { data->PenThick = 0.5; } else if (data->PenThick == 0.5) { data->PenThick = 0.25; } else if (data->PenThick == 0.25) { data->PenThick = 0.25; } else { data->PenThick -= 1; } } else { if (data->PenThick == 0.75) { data->PenThick = 1; } else if (data->PenThick == 0.5) { data->PenThick = 0.75; } else if (data->PenThick == 0.25) { data->PenThick = 0.5; } else { data->PenThick += 1; } } } else data->PenThick = Thick; //if (data->PenThick == 0) //Åõ¸íÀÌ Ãß°¡ µÇ¾ú±â ¶§¹®¿¡ 0µµ ó¸®ÇÑ´Ù. // data->PenThick = 1; if (oldThick > data->PenThick) { rc.top = min(rc.top, data->First.y - oldThick); rc.bottom = max(rc.bottom, data->Second.y + oldThick); rc.left = min(rc.left, data->First.x - oldThick); rc.right = max(rc.right, data->Second.x + oldThick); } else { rc.top = min(rc.top, data->First.y - data->PenThick); rc.bottom = max(rc.bottom, data->Second.y + data->PenThick); rc.left = min(rc.left, data->First.x - data->PenThick); rc.right = max(rc.right, data->Second.x + data->PenThick); } } } else { // Çϳª¸¸¹Ù²Ù±â data = (TVecData*)DataList->Items[Index]; UndoSave(VU_MODIFY, Index); data->PenThick = Thick; oldThick = data->PenThick; if (data->PenStyle != P_SOLID) GetDashPattern(data); // 2005 Vector upgrade shin 0317 if (oldThick > data->PenThick) { rc.top = data->First.y - oldThick; rc.bottom = data->Second.y + oldThick; rc.left = data->First.x - oldThick; rc.right = data->Second.x + oldThick; } else { rc.top = data->First.y - data->PenThick; rc.bottom = data->Second.y + data->PenThick; rc.left = data->First.x - data->PenThick; rc.right = data->Second.x + data->PenThick; } } // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - ¹ÝÀü °Å¿ïÀÇ º¤ÅÍ ¿µ¿ªÀ» °°ÀÌ ±¸ÇÑ´Ù - by monkman(2005.03.16) if (NVector->bVectorReflectionMode) { GetRealAndReflectionRect(&rc); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- MainImageForm->iMainImage->RectPaint(rc); END_LOG; } // --------------------------------------------------------------------------- /// objectÀÇ CapStyleº¯°æ void __fastcall TVecDraw::ChangeObjectPenStyle(int Style) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) RECT rc = Rect(50000, 50000, 0, 0); bool sw = true; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; UndoSave(VU_MODIFY, i, sw); sw = false; if (Style == 5) { // È­»ìÇ¥ ¼±Åà data->CapStyle[0] = 1; data->CapStyle[1] = 0; data->PenStyle = P_SOLID; if (data->ArrowCap){ data->ArrowCap->bFillLineCap = VectorForm->bFillLineCap; data->ArrowCap->LineCapWidthScale = VectorForm->LineCapWidthScale; data->ArrowCap->LineCapWidth = VectorForm->LineCapWidth; data->ArrowCap->LineCapHeight = VectorForm->LineCapHeight; data->ArrowCap->LineCapLine = VectorForm->LineCapLine; data->ArrowCap->bShowArrowBoth = VectorForm->bShowArrowBoth; if (data->ArrowCap->bShowArrowBoth){ data->CapStyle[1] = 1; } } } else if(Style == 7){ //@jhs - 2016.10.22 ¾ç¹æÇâ È­»ìÇ¥ Ãß°¡ data->CapStyle[0] = 2; data->CapStyle[1] = 2; data->PenStyle = P_SOLID; if (data->ArrowCap){ data->ArrowCap->bFillLineCap = VectorForm->bFillLineCap; data->ArrowCap->LineCapWidthScale = VectorForm->LineCapWidthScale; data->ArrowCap->LineCapWidth = VectorForm->LineCapWidth; data->ArrowCap->LineCapHeight = VectorForm->LineCapHeight; data->ArrowCap->LineCapLine = VectorForm->LineCapLine; data->ArrowCap->bShowArrowBoth = VectorForm->bShowArrowBoth; } } else { data->PenStyle = EPenStyle(Style); if (Style != P_SOLID) GetDashPattern(data); // 2005 Vector Upgrade Shin 0317 eSet¿¡ º¸¿©ÁÖ±âÀ§ÇØ data->CapStyle[0] = 0; data->CapStyle[1] = 0; } rc.top = min(rc.top, data->First.y - data->PenThick); rc.bottom = max(rc.bottom, data->Second.y + data->PenThick); rc.left = min(rc.left, data->First.x - data->PenThick); rc.right = max(rc.right, data->Second.x + data->PenThick); } // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - ¹ÝÀü °Å¿ïÀÇ º¤ÅÍ ¿µ¿ªÀ» °°ÀÌ ±¸ÇÑ´Ù - by monkman(2005.03.16) if (NVector->bVectorReflectionMode) { GetRealAndReflectionRect(&rc); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- MainImageForm->iMainImage->RectPaint(rc); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::ChangeObjectPenCapStyle(bool bFillLineCap, bool bShowArrowBoth, double LineCapWidthScale, double LineCapWidth, double LineCapHeight, double LineCapLine) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) RECT rc = Rect(50000, 50000, 0, 0); bool sw = true; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->CapStyle[0] == 1){ UndoSave(VU_MODIFY, i, sw); sw = false; int plusRange = data->PenThick; if (data->ArrowCap){ double lcWidthScale = LineCapWidthScale > data->ArrowCap->LineCapWidthScale ? LineCapWidthScale : data->ArrowCap->LineCapWidthScale; double lcWidth = LineCapWidth > data->ArrowCap->LineCapWidth ? LineCapWidth : data->ArrowCap->LineCapWidth; double lcHeight = LineCapHeight > data->ArrowCap->LineCapHeight ? LineCapHeight : data->ArrowCap->LineCapHeight; double lcLine = LineCapLine > data->ArrowCap->LineCapLine ? LineCapLine : data->ArrowCap->LineCapLine; plusRange = data->PenThick*lcWidthScale*(lcWidth+1)/2; data->ArrowCap->bFillLineCap = bFillLineCap; data->ArrowCap->LineCapWidthScale = LineCapWidthScale; data->ArrowCap->LineCapWidth = LineCapWidth; data->ArrowCap->LineCapHeight = LineCapHeight; data->ArrowCap->LineCapLine = LineCapLine; data->ArrowCap->bShowArrowBoth = bShowArrowBoth; if (data->ArrowCap->bShowArrowBoth) data->CapStyle[1] = 1; else data->CapStyle[1] = 0; } rc.top = min(rc.top, data->First.y - plusRange); rc.bottom = max(rc.bottom, data->Second.y + plusRange); rc.left = min(rc.left, data->First.x - plusRange); rc.right = max(rc.right, data->Second.x + plusRange); } else if (data->CapStyle[0] == 2) { UndoSave(VU_MODIFY, i, sw); sw = false; int plusRange = data->PenThick; if (data->ArrowCap){ double lcWidthScale = LineCapWidthScale > data->ArrowCap->LineCapWidthScale ? LineCapWidthScale : data->ArrowCap->LineCapWidthScale; double lcWidth = LineCapWidth > data->ArrowCap->LineCapWidth ? LineCapWidth : data->ArrowCap->LineCapWidth; double lcHeight = LineCapHeight > data->ArrowCap->LineCapHeight ? LineCapHeight : data->ArrowCap->LineCapHeight; double lcLine = LineCapLine > data->ArrowCap->LineCapLine ? LineCapLine : data->ArrowCap->LineCapLine; plusRange = data->PenThick*lcWidthScale*(2 * lcWidth+1)/2; data->ArrowCap->bFillLineCap = bFillLineCap; data->ArrowCap->LineCapWidthScale = LineCapWidthScale; data->ArrowCap->LineCapWidth = LineCapWidth; data->ArrowCap->LineCapHeight = LineCapHeight; data->ArrowCap->LineCapLine = LineCapLine; data->ArrowCap->bShowArrowBoth = bShowArrowBoth; } rc.top = min(rc.top, data->First.y - plusRange); rc.bottom = max(rc.bottom, data->Second.y + plusRange); rc.left = min(rc.left, data->First.x - plusRange); rc.right = max(rc.right, data->Second.x + plusRange); } } // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - ¹ÝÀü °Å¿ïÀÇ º¤ÅÍ ¿µ¿ªÀ» °°ÀÌ ±¸ÇÑ´Ù - by monkman(2005.03.16) if (NVector->bVectorReflectionMode) { GetRealAndReflectionRect(&rc); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- MainImageForm->iMainImage->RectPaint(rc); END_LOG; } // --------------------------------------------------------------------------- /// object¿¡ Pattern Fill // added int RatioX, int RatioY by maxleo21c (2004/05/12) : Pattern Fill ¹æ¹ý º¯°æ void __fastcall TVecDraw::ObjectPatternFill(int X, int Y, int Angle, int RatioX, int RatioY) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) RECT rc; RECT Src = MainImageForm->WorkArea->Range; HDC dcTemp = NULL, dcSrc = NULL; // Width, Height´Â PatternAdjustX, PatternAdjustY¸¦ ±¸Çϱâ À§Çؼ­ Ratio°è»ê int Width = SourceBitmap->Width * RatioX / 100, Height = SourceBitmap->Height * RatioY / 100; double doublebrush; bool sw = true; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->Kind == V_TEXTBOX || data->Kind == V_TEXT) continue; if (data->First.x == data->Second.x || data->First.y == data->Second.y) continue; // Rect°¡ ÁöÁ¤ ¾ÈµÇ´Â°æ¿ì UndoSave(VU_MODIFY, i, sw); sw = false; if (data->TBitmapSource) { delete data->TBitmapSource; data->TBitmapSource = NULL; } //SET_RECT_ORIGIN; data->First.x = MaxInt; data->First.y = MaxInt; data->Second.x = 0; data->Second.y = 0; if (data->Kind == V_LINE || data->Kind == V_CURVE) { for (int i = 0; i < data->nCount*3+1; i++) { if (data->pList == NULL) continue; 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; } } else if (data->Kind == V_TEXTBOX && !(data->ListOfAllLine->CurveData)) { for (int i = 0; i < 5; i++) { data->First.x = min(data->First.x, data->pList[i].x); data->First.y = min(data->First.y, data->pList[i].y); data->Second.x = max(data->Second.x, data->pList[i].x); data->Second.y = max(data->Second.y, data->pList[i].y); } } PatternPastAngle = Angle; PatternPastWidth = 100 * Width / (MainImageForm->WorkArea->Range.right - MainImageForm->WorkArea->Range.left); PatternPastHeight = 100 * Height / (MainImageForm->WorkArea->Range.bottom - MainImageForm->WorkArea->Range.top); data->bPatternFill = true; data->bFill = false; data->bGradientFill = false; // shin gradientFill data->bWinding = true; data->TBitmapSource = new TTexpiaBitmap; data->TBitmapSource->Create(SourceBitmap->Width, SourceBitmap->Height, 24); data->PatternAngle = Angle; if (!Angle) { data->PatternAdjustX = Width - (X - data->First.x - Width / 2) % Width; data->PatternAdjustY = Height - (Y - data->First.y - Height / 2) % Height; } else { int rotx, roty; rotx = (X - data->First.x) * cos(data->PatternAngle * M_PI / 180) + (Y - data->First.y) * sin(data->PatternAngle * M_PI / 180) + data->First.x; // + .5; roty = -(X - data->First.x) * sin(data->PatternAngle * M_PI / 180) + (Y - data->First.y) * cos(data->PatternAngle * M_PI / 180) + data->First.y; // + .5; // while (rotx < 0) { rotx += data->TBitmapSource->Height; } // while (roty < 0) { roty += data->TBitmapSource->Width; } data->PatternAdjustX = Width - (rotx - data->First.x - Width / 2) % Width; data->PatternAdjustY = Height - (roty - data->First.y - Height / 2) % Height; } data->RatioX = RatioX; data->RatioY = RatioY; if ((dcSrc = SourceBitmap->CreateDC()) == NULL) goto next; if ((dcTemp = data->TBitmapSource->CreateDC()) == NULL) goto next; BitBlt(dcTemp, 0, 0, SourceBitmap->Width, SourceBitmap->Height, dcSrc, 0, 0, SRCCOPY); data->TBitmapSource->DeleteDC(dcTemp); dcTemp = NULL; SourceBitmap->DeleteDC(dcSrc); dcSrc = NULL; doublebrush = 0.0; // Pattern Fill¿¡¼­ °°Àº PatternÀÎÁö¸¦ identifyÇϱâ À§Çؼ­ Brush¿¡ Áß°£ color¸¦ Áý¾î³Ö´Â´Ù for (int y = Src.top; y < Src.bottom; y++) { for (int x = Src.left; x < Src.right; x++) { doublebrush = doublebrush +double (MainImageForm->iMainImage->uBitmap->GetPixelColor(x, y)) / ((Src.right - Src.left) * (Src.bottom - Src.top)); } } data->Brush = TColor(int(doublebrush)); MakePatternBitmap(data); if (data->nCount > 1 || (data->nCount == 1 && (data->pList[0].x != data->pList[1].x || data->pList[0].y != data->pList[1].y || data->pList[2].x != data->pList[3].x || data->pList[2].y != data->pList[3].y))){ rc.top = data->First.y - data->PenThick; rc.bottom = data->Second.y + data->PenThick; rc.left = data->First.x - data->PenThick; rc.right = data->Second.x + data->PenThick; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - ¹ÝÀü °Å¿ïÀÇ º¤ÅÍ ¿µ¿ªÀ» °°ÀÌ ±¸ÇÑ´Ù - by monkman(2005.03.16) if (NVector->bVectorReflectionMode) { GetRealAndReflectionRect(&rc); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- MainImageForm->iMainImage->RectPaint(rc); } next: } delete SubBitmap; SubBitmap = NULL; delete SourceBitmap; SourceBitmap = NULL; fail: END_LOG; } // --------------------------------------------------------------------------- /// È®´ëÃà¼Ò¸¦ À§ÇÑ Áغñ, °è»ê void __fastcall TVecDraw::InitProportion() { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL, *childdata = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) sx = 0; sy = 0; ex = 0; ey = 0; thick = 0; // sxy: x,yÀÇ ÃÖ¼ÒÁ¡ exy: ÃÖ´ëÁ¡ TSWordData *tsWordData, *newWordData; int *oldLine, *newLine; RECT rect; RECT rtCur, rtUnion; // MotiveÀÇ Child¸¦ °è»êÇϱâÀ§ÇØ - by monkman (2009.04.03) int nMotiveWidth, nMotiveHeight, nMotiveSlope, nMotivePenThick; bool bFirst; int tempCx, tempCy, lineHeight; double angle, tx, ty; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->Kind == V_TEXTBOX) { // for Textbox By maxleo21c (04.10.19) GetTextBoxRect(data); MakeTextBoxPointList(data); GetRectForMouseMove(data, rect); data->CenterPoint.x = (data->First.x + data->Second.x) / 2; data->CenterPoint.y = (data->First.y + data->Second.y) / 2; tempCx = (data->pList[0].x + data->pList[2].x) / 2; tempCy = (data->pList[0].y + data->pList[2].y) / 2; if (tempCx == data->CenterPoint.x && tempCy == data->CenterPoint.y); else { data->First.x += (tempCx - data->CenterPoint.x); data->First.y += (tempCy - data->CenterPoint.y); lineHeight = data->ListOfAllLine->GetLineTextBox(0)->lineHeight; data->StartPoint.x = data->First.x; data->StartPoint.y = (data->First.y + lineHeight); GetTextBoxRect(data); data->CenterPoint.x = (data->First.x + data->Second.x) / 2; data->CenterPoint.y = (data->First.y + data->Second.y) / 2; MakeTextBoxPointList(data); } // todo: ij·ÔÀ» ó¸®Çϱâ À§Çؼ­ (¹Ú»óÈÆ) CenterPoint.x = data->CenterPoint.x; CenterPoint.y = data->CenterPoint.y; if (sx == 0) sx = rect.left; else sx = min(sx, rect.left); if (sy == 0) sy = rect.top; else sy = min(sy, rect.top); ex = max(ex, rect.right); ey = max(ey, rect.bottom); // È®´ë/Ãà¼ÒµÇ´Â ±ÛÀÚ¸¦ º¸¿©ÁÖ±â À§Çؼ­ ¸¸µé¾ú´Ù. if (data->ProportionWordDataList); // ¸¸¾à¿¡ »ý¼ºµÇÁö ¾Ê¾Ò´Ù¸é ¹®Á¦°¡ »ý±æ¼ö Àֱ⠶§¹®¿¡ äũ else data->ProportionWordDataList = new TList; // È®´ë/Ãà¼Ò¸¦ ÇÒ¶§¿¡¸¸ »ç¿ëµÇ´Â ¸®½ºÆ® if (data->ProportionLineList); else data->ProportionLineList = new TList; // È®´ë/Ãà¼Ò¸¦ ÇÒ¶§¿¡¸¸ »ç¿ëµÇ´Â ¸®½ºÆ® if (data->ListOfAllLine); else { TLineTextBox * tempTLineTextBox; data->ListOfAllLine = new TWordList; tempTLineTextBox = new TLineTextBox; data->ListOfAllLine->Add(tempTLineTextBox); } while (data->ProportionWordDataList->Count) { tsWordData = (TSWordData*)data->ProportionWordDataList->First(); data->ProportionWordDataList->Remove(tsWordData); delete tsWordData; } for (int i = 0; i < data->ListOfAllLine->Count; i++) { newWordData = new TSWordData; tsWordData = (TSWordData*)data->ListOfAllLine->Items(i); newWordData->Selected = false; newWordData->bNameChanged = tsWordData->bNameChanged; // 2005 Vector Upgrade Shin 0316 newWordData->Color = tsWordData->Color; newWordData->PPoint.x = tsWordData->PPoint.x; newWordData->PPoint.y = tsWordData->PPoint.y; newWordData->Interval = tsWordData->Interval; newWordData->UsedByte = tsWordData->UsedByte; _tcscpy(newWordData->Word, tsWordData->Word); newWordData->WidthGap = tsWordData->WidthGap; newWordData->HeightGap = tsWordData->HeightGap; newWordData->LFont.lfHeight = tsWordData->LFont.lfHeight; newWordData->LFont.lfWidth = tsWordData->LFont.lfWidth; newWordData->LFont.lfEscapement = tsWordData->LFont.lfEscapement; newWordData->LFont.lfOrientation = tsWordData->LFont.lfOrientation; newWordData->LFont.lfWeight = tsWordData->LFont.lfWeight; newWordData->LFont.lfItalic = tsWordData->LFont.lfItalic; newWordData->LFont.lfUnderline = tsWordData->LFont.lfUnderline; newWordData->LFont.lfStrikeOut = tsWordData->LFont.lfStrikeOut; newWordData->LFont.lfCharSet = tsWordData->LFont.lfCharSet; newWordData->LFont.lfPitchAndFamily = tsWordData->LFont.lfPitchAndFamily; _tcscpy(newWordData->LFont.lfFaceName, tsWordData->LFont.lfFaceName); data->ProportionWordDataList->Add(newWordData); } while (data->ProportionLineList->Count) { oldLine = (int*)data->ProportionLineList->First(); data->ProportionLineList->Remove(oldLine); delete oldLine; } for (int j = 0; j < data->ListOfAllLine->LineCount; j++) { newLine = new int; *newLine = (data->ListOfAllLine->GetLineTextBox(j))->lineHeight; data->ProportionLineList->Add(newLine); } } else if (data->Kind != V_TEXT) { if (sx == 0) sx = data->First.x; else sx = min(sx, double(data->First.x)); if (sy == 0) sy = data->First.y; else sy = min(sy, double(data->First.y)); ex = max(ex, double(data->Second.x)); ey = max(ey, double(data->Second.y)); thick = max(thick, data->PenThick); // -->by linuxjun for CurvedVectorText 7¿ù¸» Àܻ󾸾ֱâ À§ÇÔ if (data->ParentTextBox) { thick = max(thick, data->ParentTextBox->ListOfAllLine->GetLineTextBox(0) ->lineHeight * 3); } // <--by linuxjun for CurvedVectorText 7¿ù¸» Àܻ󾸾ֱâ À§ÇÔ // Motive Child ¿µ¿ª °è»ê - by monkman (2009.04.03) if (data->bMotive && data->ChildList && data->ChildList->Count > 0) { bFirst = true; nMotivePenThick = 0; for (int j = 0; j < data->ChildList->Count; j++) { childdata = (TVecData*)data->ChildList->Items[j]; rtCur = TRect(childdata->First.x, childdata->First.y, childdata->Second.x, childdata->Second.y); if (bFirst) { bFirst = false; rtUnion = rtCur; } else { UnionRect(&rtUnion, &rtCur, &rtUnion); } nMotivePenThick = max(nMotivePenThick, childdata->PenThick); } nMotiveWidth = (rtUnion.right - rtUnion.left) / 2; nMotiveHeight = (rtUnion.bottom - rtUnion.top) / 2; nMotiveSlope = sqrt(nMotiveWidth * nMotiveWidth + nMotiveHeight * nMotiveHeight) + 0.5; if (sx != 0) sx = min(sx, data->First.x - nMotiveSlope); if (sy != 0) sy = min(sy, data->First.y - nMotiveSlope); ex = max(ex, data->Second.x + nMotiveSlope); ey = max(ey, data->Second.y + nMotiveSlope); // MovtiveÀÇ È®´ë/Ãà¼Ò ½Ã »ç¿ëµÇ´Â °¡Àå ±äÃàÀÇ ±æÀÌ - by monkamn (2009.04.10) nMaxMotiveLength = max(nMaxMotiveLength, nMotiveSlope); } } else { double FirstX, FirstY, SecondX, SecondY; double angle = 2 * M_PI * data->Font.lfEscapement / 10 / 360; int height = data->Font.lfHeight; if (angle < M_PI / 2 || (angle > M_PI && angle < M_PI * 3 / 2)) { // 1, 3»çºÐ¸é¿¡¼­ FirstX = data->First.x - height * sin(angle); SecondX = data->Second.x + height * sin(angle); FirstY = data->First.y; SecondY = data->Second.y; } else { // 2, 4»çºÐ¸é¿¡¼­ FirstY = data->First.y - height * cos(angle); SecondY = data->Second.y + height * cos(angle); FirstX = data->First.x; SecondX = data->Second.x; } if (sx == 0) sx = min(FirstX, SecondX); else sx = min(sx, min(FirstX, SecondX)); if (sy == 0) sy = min(FirstY, SecondY); else sy = min(sy, min(FirstY, SecondY)); ex = max(ex, max(FirstX, SecondX)); ey = max(ey, max(FirstY, SecondY)); } } END_LOG; } // --------------------------------------------------------------------------- /// object È®´ëÃà¼Ò¸¦ À§ÇØ dataµéÀ» transform. void __fastcall TVecDraw::ProportionTransform(TVecData *data) { BEGIN_LOG(""); double zoom = 1; zoom = min(fabs(ratiox), fabs(ratioy)); PropPoint1.DPoint(data->First); PropPoint2.DPoint(data->Second); switch(data->Kind) { case V_CURVE: case V_LINE: // È®´ëÃà¼Ò¸¦ À§ÇÑ ÀÓ½ÃÀúÀå°í¸¦ »ý¼º - by monkman (2011.04.19) if (PropPoints) delete[]PropPoints; if (data->bClosed && data->PenStyle == P_SOLID) { PropPoints = new DPOINT[(data->nCount + 1) * 3 + 1]; } else { PropPoints = new DPOINT[data->nCount * 3 + 1]; } for (int i = 0; i < data->nCount * 3 + 1; i++) { PropPoints[i].x = data->pList[i].x; PropPoints[i].y = data->pList[i].y; if (VectorForm->isShiftKeyDownState()) { data->pList[i].x = (data->pList[i].x - sx) * zoom + sx; data->pList[i].y = (data->pList[i].y - sy) * zoom + sy; } else { data->pList[i].x = (data->pList[i].x - sx) * ratiox + sx; data->pList[i].y = (data->pList[i].y - sy) * ratioy + sy; } } break; case V_RECT: case V_ELLIPSE: if (VectorForm->isShiftKeyDownState()) { data->First.x = (data->First.x - sx) * zoom + sx; data->First.y = (data->First.y - sy) * zoom + sy; data->Second.x = (data->Second.x - sx) * zoom + sx; data->Second.y = (data->Second.y - sy) * zoom + sy; } else { data->First.x = (data->First.x - sx) * ratiox + sx; data->First.y = (data->First.y - sy) * ratioy + sy; data->Second.x = (data->Second.x - sx) * ratiox + sx; data->Second.y = (data->Second.y - sy) * ratioy + sy; } break; case V_TEXT: data->First.x = (data->First.x - sx) * zoom + sx; data->First.y = (data->First.y - sy) * zoom + sy; data->Second.x = (data->Second.x - sx) * zoom + sx; data->Second.y = (data->Second.y - sy) * zoom + sy; fontsize = data->Font.lfHeight; // Àӽà ÀúÀå data->Font.lfHeight *= zoom; if (data->Font.lfHeight < 1) data->Font.lfHeight = 1; break; case V_TEXTBOX: TSWordData * tsWordData, *newWordData; int lineHeight = 0, lineCount = 0, *newLine; SIZE size; TFont *font = MainImageForm->iMainImage->Canvas->Font; HDC hdc; // È®´ë/Ãà¼ÒµÇ´Â ±ÛÀÚ¸¦ º¸¿©ÁÖ±â À§Çؼ­ ¸¸µé¾ú´Ù. // Text´Â ÀÛÀº ºñÀ²·Î¸¸ È®´ë Ãà¼Ò°¡ µÈ´Ù (ÇöÀç·Î¼­ °¡·Î, ¼¼·Î ´Ù¸¥ºñÀ² º¯È­´Â ºÒ°¡´É) data->ProportionFirst.x = (data->First.x - sx) * zoom + sx; data->ProportionFirst.y = (data->First.y - sy) * zoom + sy; for (int i = 0; i < data->ListOfAllLine->Count; i++) { newWordData = (TSWordData*)data->ProportionWordDataList->Items[i]; tsWordData = (TSWordData*)data->ListOfAllLine->Items(i); newWordData->LFont.lfHeight = tsWordData->LFont.lfHeight * zoom; if (newWordData->LFont.lfHeight == 0) newWordData->LFont.lfHeight = 1; _tcscpy(newWordData->LFont.lfFaceName, tsWordData->LFont.lfFaceName); font->Name = newWordData->LFont.lfFaceName; font->Size = newWordData->LFont.lfHeight; hdc = MainImageForm->iMainImage->Canvas->Handle; /* if (tsWordData->UsedByte == 1) GetTextExtentPoint32(hdc, tsWordData->Word, 1, &size); else GetTextExtentPoint32(hdc, tsWordData->Word, 2, &size); */ /////////////////////// Vista Font¿¡ ´ëÇØ SizeÁ¦´ë·Î ¸ø°¡Á®¿Í¼­ »ý±â´Â ¹®Á¦ ó¸® (2007. 06. 27 Annualring) size = GetVectorTextExtent(MainImageForm->iMainImage->Canvas, font, tsWordData); newWordData->Interval = tsWordData->Interval * zoom; if (newWordData->Interval == 0) newWordData->Interval = 1; newWordData->Interval = size.cx * 4 / 5; lineHeight = size.cy > lineHeight ? lineHeight = size.cy : lineHeight; if (tsWordData->Word[0] == '\r') { newLine = (int*)data->ProportionLineList->Items[lineCount]; *newLine = lineHeight; lineCount++; lineHeight = 0; } } if (lineCount == 0) { newLine = (int*)data->ProportionLineList->Items[0]; *newLine = lineHeight; } else { newLine = (int*)data->ProportionLineList->Items[lineCount]; *newLine = lineHeight; } // È®´ëÃà¼Ò¸¦ À§ÇÑ ÀÓ½ÃÀúÀå°í¸¦ »ý¼º - by monkman (2011.04.19) if (PropPoints) delete[]PropPoints; PropPoints = new DPOINT[5]; for (int k = 0; k < 5; k++) { PropPoints[k].x = data->pList[k].x; PropPoints[k].y = data->pList[k].y; PropPoints[k].x = (PropPoints[k].x - sx) * zoom + sx; PropPoints[k].y = (PropPoints[k].y - sy) * zoom + sy; } break; } // -->by linuxjun for CurvedVectorText if (data->ParentTextBox) { MakeTextBoxPointList(data->ParentTextBox); } // <--by linuxjun for CurvedVectorText END_LOG; } // --------------------------------------------------------------------------- /// TransformÀÌ °¡ÇØÁø Á¡µéÀ» µÇµ¹¸². void __fastcall TVecDraw::ProportionInverseTransform(TVecData *data) { BEGIN_LOG(""); data->First = PropPoint1.P(); data->Second = PropPoint2.P(); if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int i = 0; i < data->nCount * 3 + 1; i++) { data->pList[i].x = PropPoints[i].x; data->pList[i].y = PropPoints[i].y; } } if (data->Kind == V_TEXT) { data->Font.lfHeight = fontsize; } END_LOG; } // --------------------------------------------------------------------------- /// object È®´ëÃà¼Ò void __fastcall TVecDraw::ObjectProportion(double x, double y) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) RECT rc; // double ratiox = x / 100.0, ratioy = y / 100.0; int x1, x2, y1, y2, fontSize; bool sw = true; SIZE size; TFont *font = MainImageForm->iMainImage->Canvas->Font; HDC hdc; double zoom = 1; // ------------------> 2005 Vector Upgrade Shin 0316 double ratiox, ratioy; int FirstX = 99999, FirstY = 99999, SecondX = 0, SecondY = 0; if (bRatio) { ratiox = x / 100.0; ratioy = y / 100.0; } else { switch(MainImageForm->CurrentUnit) { case uDot: break; case uInch: x = x * MainImageForm->CanvasInfor.DotsPerInch; y = y * MainImageForm->CanvasInfor.DotsPerInch; break; case uCm: x = x * MainImageForm->CanvasInfor.DotsPerInch / 2.54; y = y * MainImageForm->CanvasInfor.DotsPerInch / 2.54; break; } for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->Kind == V_TEXTBOX) { for (int i = 0; i < 5; i++) { FirstX = min(FirstX, data->pList[i].x); FirstY = min(FirstY, data->pList[i].y); SecondX = max(SecondX, data->pList[i].x); SecondY = max(SecondY, data->pList[i].y); } } else { for (int i = 0; i < data->nCount * 3 + 1; i++) { FirstX = min(FirstX, data->pList[i].x); FirstY = min(FirstY, data->pList[i].y); SecondX = max(SecondX, data->pList[i].x); SecondY = max(SecondY, data->pList[i].y); } } } // ±¸ÇÑ ±æÀÌ : ÀÔ·ÂÇÑ ±æÀÌ ºñÀ² ±¸ÇÔ ratiox = (double)x / abs(SecondX - FirstX); ratioy = (double)y / abs(SecondY - FirstY); } // -----------------------< zoom = min(fabs(ratiox), fabs(ratioy)); for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; UndoSave(VU_MODIFY, i, sw); sw = false; switch(data->Kind) { case V_LINE: case V_CURVE: for (int i = 0; i < data->nCount * 3 + 1; i++) { if (VectorForm->isShiftKeyDownState()) { data->pList[i].x = (data->pList[i].x - sx) * zoom + sx; data->pList[i].y = (data->pList[i].y - sy) * zoom + sy; } else { data->pList[i].x = (data->pList[i].x - sx) * ratiox + sx; data->pList[i].y = (data->pList[i].y - sy) * ratioy + sy; } } SET_RECT_ORIGIN; break; case V_RECT: case V_ELLIPSE: if (VectorForm->isShiftKeyDownState()) { data->First.x = (data->First.x - sx) * zoom + sx; data->First.y = (data->First.y - sy) * zoom + sy; data->Second.x = (data->Second.x - sx) * zoom + sx; data->Second.y = (data->Second.y - sy) * zoom + sy; } else { data->First.x = (data->First.x - sx) * ratiox + sx; data->First.y = (data->First.y - sy) * ratioy + sy; data->Second.x = (data->Second.x - sx) * ratiox + sx; data->Second.y = (data->Second.y - sy) * ratioy + sy; } x1 = min(data->First.x, data->Second.x); x2 = max(data->First.x, data->Second.x); y1 = min(data->First.y, data->Second.y); y2 = max(data->First.y, data->Second.y); data->First.x = x1; data->First.y = y1; data->Second.x = x2; data->Second.y = y2; break; case V_TEXT: // Text´Â ÀÛÀº ºñÀ²·Î¸¸ È®´ë Ãà¼Ò°¡ µÈ´Ù (ÇöÀç·Î¼­ °¡·Î, ¼¼·Î ´Ù¸¥ºñÀ² º¯È­´Â ºÒ°¡´É) data->First.x = (data->First.x - sx) * zoom + sx; data->First.y = (data->First.y - sy) * zoom + sy; data->Second.x = (data->Second.x - sx) * zoom + sx; data->Second.y = (data->Second.y - sy) * zoom + sy; data->Font.lfHeight *= zoom; if (data->Font.lfHeight < 1) data->Font.lfHeight = 1; break; case V_TEXTBOX: { double angle; TSWordData *tsWordData; int cx = (sx + ex) / 2, cy = (sy + ey) / 2; // rotation objectµéÀÇ centerÁ¡µé int lineHeight = 0, lineCount = 0; SIZE size; TFont *font = MainImageForm->iMainImage->Canvas->Font; HDC hdc; for (int k = 0; k < data->ListOfAllLine->Count; k++) { tsWordData = (TSWordData*)data->ListOfAllLine->Items(k); tsWordData->LFont.lfHeight *= zoom; if (tsWordData->LFont.lfHeight == 0) tsWordData->LFont.lfHeight = 1; font->Name = tsWordData->LFont.lfFaceName; font->Size = tsWordData->LFont.lfHeight; hdc = MainImageForm->iMainImage->Canvas->Handle; /* if (tsWordData->UsedByte == 1) GetTextExtentPoint32(hdc, tsWordData->Word, 1, &size); else GetTextExtentPoint32(hdc, tsWordData->Word, 2, &size); */ /////////////////////// Vista Font¿¡ ´ëÇØ SizeÁ¦´ë·Î ¸ø°¡Á®¿Í¼­ »ý±â´Â ¹®Á¦ ó¸® (2007. 06. 27 Annualring) size = GetVectorTextExtent(MainImageForm->iMainImage->Canvas, font, tsWordData); tsWordData->PPoint.x = size.cx; tsWordData->PPoint.y = size.cy; tsWordData->Interval = size.cx * 4 / 5; lineHeight = size.cy > lineHeight ? lineHeight = size.cy : lineHeight; if (tsWordData->Word[0] == '\r') { (data->ListOfAllLine->GetLineTextBox(lineCount)) ->lineHeight = lineHeight; lineCount++; lineHeight = 0; } } if (lineCount == 0) (data->ListOfAllLine->GetLineTextBox(0))->lineHeight = lineHeight; else { (data->ListOfAllLine->GetLineTextBox(lineCount)) ->lineHeight = lineHeight; } // Text´Â ÀÛÀº ºñÀ²·Î¸¸ È®´ë Ãà¼Ò°¡ µÈ´Ù (ÇöÀç·Î¼­ °¡·Î, ¼¼·Î ´Ù¸¥ºñÀ² º¯È­´Â ºÒ°¡´É) data->First.x = (data->First.x - sx) * zoom + sx; data->First.y = (data->First.y - sy) * zoom + sy; lineHeight = (data->ListOfAllLine->GetLineTextBox(0))->lineHeight; data->StartPoint.x = data->First.x; data->StartPoint.y = data->First.y + lineHeight; GetTextBoxRect(data); angle = data->TextAngle; angle = angle / 180 * M_PI; data->pList[0].x = data->First.x; data->pList[0].y = data->First.y; data->pList[1].x = data->First.x; data->pList[1].y = data->Second.y; data->pList[2].x = data->Second.x; data->pList[2].y = data->Second.y; data->pList[3].x = data->Second.x; data->pList[3].y = data->First.y; data->pList[4].x = data->First.x; data->pList[4].y = data->First.y; data->CenterPoint.x = (data->pList[0].x + data->pList[2].x) / 2; data->CenterPoint.y = (data->pList[0].y + data->pList[2].y) / 2; cx = data->CenterPoint.x; cy = data->CenterPoint.y; // todo: ij·ÔÀ» ó¸®Çϱâ À§Çؼ­ (¹Ú»óÈÆ) CenterPoint.x = data->CenterPoint.x; CenterPoint.y = data->CenterPoint.y; for (int i = 0; i < 5; i++) { double tx = data->pList[i].x - cx; double ty = cy - data->pList[i].y; data->pList[i].x = tx * cos(-angle) + ty * sin(-angle) + cx; data->pList[i].y = cy - (-tx * sin(-angle) + ty * cos(-angle)); } break; } } if (data->bPatternFill) MakePatternBitmap(data); // -->by linuxjun for CurvedVectorText if (data->ParentTextBox) { MakeTextBoxPointList(data->ParentTextBox); } // <--by linuxjun for CurvedVectorText } NVector->bProportion = false; // ÀÌÁ¦ È®´ëÃà¼Ò¸ðµå´Â ³¡~ rc.top = sy - thick; rc.bottom = sy + (ey - sy) * max(1.0, ratioy) + thick; rc.left = sx - thick; rc.right = sx + (ex - sx) * max(1.0, ratiox) + thick; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - ¹ÝÀü °Å¿ïÀÇ º¤ÅÍ ¿µ¿ªÀ» °°ÀÌ ±¸ÇÑ´Ù - by monkman(2005.03.16) if (NVector->bVectorReflectionMode) { GetRealAndReflectionRect(&rc); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- MainImageForm->iMainImage->RectPaint(rc); END_LOG; } // --------------------------------------------------------------------------- /// object¸¦ ȸÀüÇϱâ À§ÇØ mouse move, ȸÀü °¢µµ °è»ê int __fastcall TVecDraw::RotationMouseMove(int X, int Y) { RECT rc; double dx = X - (sx + ex) / 2, dy = (sy + ey) / 2 - Y; RotationAngle = ArcTan2(dy, dx); double maxl = sqrt(((ex - sx) / 2) * ((ex - sx) / 2) + ((ey - sy) / 2) * ((ey - sy) / 2)); rc.top = (sy + ey) / 2 - maxl - thick; rc.bottom = (sy + ey) / 2 + maxl + thick; rc.left = (sx + ex) / 2 - maxl - thick; rc.right = (sx + ex) / 2 + maxl + thick; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - ¹ÝÀü °Å¿ïÀÇ º¤ÅÍ ¿µ¿ªÀ» °°ÀÌ ±¸ÇÑ´Ù - by monkman(2005.03.16) if (NVector->bVectorReflectionMode) { GetRealAndReflectionRect(&rc); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- MainImageForm->iMainImage->RectPaint(rc); return int(RotationAngle > 0 ? RotationAngle * 180 / M_PI : 360 + RotationAngle * 180 / M_PI); } // --------------------------------------------------------------------------- /// object¸¦ ȸÀü void __fastcall TVecDraw::ObjectRotation(bool box, double angle, bool undo) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) RECT rc; bool sw = true; int cx = (sx + ex) / 2, cy = (sy + ey) / 2; // rotation objectµéÀÇ centerÁ¡µé double maxl = sqrt(((ex - sx) / 2) * ((ex - sx) / 2) + ((ey - sy) / 2) * ((ey - sy) / 2)); NVector->bRotation = false; int tx, ty, tempCx, tempCy, lineHeight; if (box) RotationAngle = angle / 180 * M_PI; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->Kind == V_TEXT) continue; if (undo) UndoSave(VU_MODIFY, i, sw); // for new font if (data->Kind == V_TEXTBOX) { // by maxleo21c 04/09/30 TSWordData *tsWordData; angle = VectorForm->eAngle->Value; angle += data->TextAngle; while (angle > 360) angle -= 360; data->TextAngle = angle; for (int k = 0; k < data->nCount; k++) { tsWordData = (TSWordData*)data->ListOfAllLine->Items(k); tsWordData->LFont.lfEscapement = angle * 10; } for (int i = 0; i < 5; i++) { tx = data->pList[i].x - cx; ty = cy - data->pList[i].y; data->pList[i].x = tx * cos(-RotationAngle) + ty * sin(-RotationAngle) + cx; data->pList[i].y = cy - (-tx * sin(-RotationAngle) + ty * cos (-RotationAngle)); } tempCx = (data->pList[0].x + data->pList[2].x) / 2; tempCy = (data->pList[0].y + data->pList[2].y) / 2; if (tempCx == data->CenterPoint.x && tempCy == data->CenterPoint.y); else { data->First.x += (tempCx - data->CenterPoint.x); data->First.y += (tempCy - data->CenterPoint.y); lineHeight = data->ListOfAllLine->GetLineTextBox(0)->lineHeight; data->StartPoint.x = data->First.x; data->StartPoint.y = (data->First.y + lineHeight); GetTextBoxRect(data); data->CenterPoint.x = (data->First.x + data->Second.x) / 2; data->CenterPoint.y = (data->First.y + data->Second.y) / 2; // todo: ij·ÔÀ» ó¸®Çϱâ À§Çؼ­ (¹Ú»óÈÆ) CenterPoint.x = data->CenterPoint.x; CenterPoint.y = data->CenterPoint.y; MakeTextBoxPointList(data); } continue; } // UndoSave(VU_MODIFY, i, sw); //for new font sw = false; for (int i = 0; i < data->nCount * 3 + 1; i++) { if (data->pList == NULL) continue; double tx = data->pList[i].x - cx; double ty = cy - data->pList[i].y; data->pList[i].x = tx * cos(-RotationAngle) + ty * sin(-RotationAngle) + cx; data->pList[i].y = cy - (-tx * sin(-RotationAngle) + ty * cos (-RotationAngle)); } SET_RECT_ORIGIN; if (data->bPatternFill) MakePatternBitmap(data); } rc.top = (sy + ey) / 2 - maxl - thick; rc.bottom = (sy + ey) / 2 + maxl + thick; rc.left = (sx + ex) / 2 - maxl - thick; rc.right = (sx + ex) / 2 + maxl + thick; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - ¹ÝÀü °Å¿ïÀÇ º¤ÅÍ ¿µ¿ªÀ» °°ÀÌ ±¸ÇÑ´Ù - by monkman(2005.03.16) if (NVector->bVectorReflectionMode) { GetRealAndReflectionRect(&rc); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- MainImageForm->iMainImage->RectPaint(rc); END_LOG; } // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- ///////////// Pattern Filling Functions // --------------------------------------------------------------------------- /// pattern fillÇÒ Áغñ - ĵ¹ö½º¿¡ ÀÛ¾÷±¸¿ª ÀâÈù ¿µ¿ªÀ» SubBitmap°ú pattern fillÇÒ SourceBitmap¿¡ º¹»ç. void __fastcall TVecDraw::InitPatternFill(int ratiox, int ratioy, int angle) { BEGIN_LOG(""); RECT Src = MainImageForm->WorkArea->Range; HDC dcDst1 = NULL, dcDst2 = NULL, dcSrc = NULL; if (SubBitmap) { delete SubBitmap; SubBitmap = NULL; } if (SourceBitmap) { delete SourceBitmap; SourceBitmap = NULL; } SubBitmap = new TTexpiaBitmap; SubBitmap->Create((Src.right - Src.left) * ratiox / 100, (Src.bottom - Src.top) * ratioy / 100, MainImageForm->iMainImage->uBitmap->BitsPerPixel); SourceBitmap = new TTexpiaBitmap; SourceBitmap->Create(Src.right - Src.left, Src.bottom - Src.top, MainImageForm->iMainImage->uBitmap->BitsPerPixel); if ((dcDst1 = SubBitmap->CreateDC()) == NULL) goto next; if ((dcDst2 = SourceBitmap->CreateDC()) == NULL) goto next; // if ((dcSrc = MainImageForm->iMainImage->uBitmap->CreateDC())==NULL) goto next; MainImageForm->iMainImage->uBitmap->UnionStretchBlt(dcDst1, 0, 0, SubBitmap->Width, SubBitmap->Height, Src.left, Src.top, Src.right - Src.left, Src.bottom - Src.top, SRCCOPY); MainImageForm->iMainImage->uBitmap->UnionStretchBlt(dcDst2, 0, 0, SourceBitmap->Width, SourceBitmap->Height, Src.left, Src.top, Src.right - Src.left, Src.bottom - Src.top, SRCCOPY); next: if (dcDst1) SubBitmap->DeleteDC(dcDst1); dcDst1 = NULL; if (dcDst2) SourceBitmap->DeleteDC(dcDst2); dcDst2 = NULL; // if(dcSrc) MainImageForm->iMainImage->Bitmap->DeleteDC(dcSrc); dcSrc = NULL; SubBitmap->Rotate(angle * 100, true, clWhite); END_LOG; } // --------------------------------------------------------------------------- /// º¯°æµÈ object¸¦ update½ÃÄÑÁØ´Ù (pattern fillµÈ °æ¿ì ÆÐÅÏÀ» ´Ù½Ã ¸¸µé¾îÁØ´Ù) void __fastcall TVecDraw::UpdateModifiedObject() { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bModified) continue; if (data->bPatternFill) MakePatternBitmap(data); data->bModified = false; } END_LOG; } // --------------------------------------------------------------------------- /// pattern fillµÈ objectÀÎ °æ¿ì object ÇüÅ¿¡ µû¶ó ä¿öÁú pattern bitmapÀ» ¸¸µé¾î ÁØ´Ù. void __fastcall TVecDraw::MakePatternBitmap(TVecData *dt) { BEGIN_LOG(""); POINT *pPoints = NULL; // pPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) Byte *mask, *bitmap, *source, mm; LOGBRUSH logbrush; HBRUSH hBrush = NULL; HDC dcMask = NULL, dctBitmap, dcDTS; TTexpiaBitmap *tempBitmap; int tWidth, tHeight; if (dt->TBitmap) { delete dt->TBitmap; dt->TBitmap = NULL; } if (dt->MaskBitmap) { delete dt->MaskBitmap; dt->MaskBitmap = NULL; } // ============ Mask ¸¸µé±â dt->MaskBitmap = new TTexpiaBitmap; dt->MaskBitmap->Create(dt->Second.x - dt->First.x, dt->Second.y - dt->First.y, 1); // todo : ÆÐÅÏ Ã¤¿î ¿ÀºêÁ§Æ® ÇÑÁ¡ÀÌ µÇµµ·Ï Ãà¼ÒÇßÀ»¶§ Access¸¦ ÀÓ½ÃÀûÀ¸·Î ¸·±â À§ÇØ // dt->MaskBitmap->Create(0, 0, 1); ·Î Width¿Í Height°¡ ¾ø¾î¼­ MaskBitmapÀÌ // »ý¼ºµÇÁö ¾Ê´Â °ÍÀ» °­Á¦·Î 1Çȼ¿¾¿ ÁöÁ¤ÇÏ¿© »ý¼ºµÇµµ·Ï ¼öÁ¤ÇÏ¿´´Ù. // ³ªÁß¿¡ ½Ã°£ÀÌ µÈ´Ù¸é Á¦´ë·Î ¼öÁ¤ÇÒ °Í - by monkman (2004.09.30) if (!(dt->Second.x - dt->First.x) || !(dt->Second.y - dt->First.y)) dt->MaskBitmap->Create(1, 1, 1); dt->MaskBitmap->FillRect(Rect(0, 0, dt->MaskBitmap->Width, dt->MaskBitmap->Height), 0xFFFFFF); if ((dcMask = dt->MaskBitmap->CreateDC()) == NULL) goto next; if (dt->bClosed && dt->PenStyle == P_SOLID) { pPoints = new POINT[(dt->nCount + 1) * 3 + 1]; } else { pPoints = new POINT[dt->nCount * 3 + 1]; } for (int j = 0; j < dt->nCount * 3 + 1; j++) { pPoints[j].x = int(dt->pList[j].x) - dt->First.x; pPoints[j].y = int(dt->pList[j].y) - dt->First.y; } if (dt->bClosed) pPoints[dt->nCount * 3] = pPoints[0]; SetPolyFillMode(dcMask, WINDING); // ALTERNATE); logbrush.lbStyle = BS_SOLID; logbrush.lbColor = 0; logbrush.lbHatch = 0; hBrush = CreateBrushIndirect(&logbrush); SelectObject(dcMask, hBrush); BeginPath(dcMask); MoveToEx(dcMask, pPoints[0].x, pPoints[0].y, NULL); PolyBezierTo(dcMask, pPoints + 1, dt->nCount * 3); EndPath(dcMask); FillPath(dcMask); DeleteObject(hBrush); hBrush = NULL; dt->MaskBitmap->DeleteDC(dcMask); dcMask = NULL; // ============= temp Bitmap ¸¸µé±â tempBitmap = new TTexpiaBitmap; tWidth = dt->TBitmapSource->Width * dt->RatioX / 100; tHeight = dt->TBitmapSource->Height * dt->RatioY / 100; tempBitmap->Create(tWidth, tHeight, 24); if ((dcDTS = dt->TBitmapSource->CreateDC()) == NULL) goto tNext; if ((dctBitmap = tempBitmap->CreateDC()) == NULL) goto tNext; // º¤ÅÍ ¿ÀºêÁ§Æ® ¾È¿¡ ä¿îºñÆ®¸Ê À̹ÌÁö Ãà¼Òº¸±â ÇßÀ» ¶§ Ä®¶ó³ª ÆÐÅÏÀÌ º¯ÁúµÇÁö ¾Êµµ·Ï ¼öÁ¤ - by monkman (2007.09.13) if (osVERSION < 2) { // 3.1, 95, 98 SetStretchBltMode(dctBitmap, COLORONCOLOR); } else { SetStretchBltMode(dctBitmap, HALFTONE); } if (osVERSION < 2) { // 3.1, 95, 98 SetStretchBltMode(dctBitmap, COLORONCOLOR); } else { SetStretchBltMode(dctBitmap, HALFTONE); } StretchBlt(dctBitmap, 0, 0, tWidth, tHeight, dcDTS, 0, 0, dt->TBitmapSource->Width, dt->TBitmapSource->Height, SRCCOPY); tNext: if (dcDTS) dt->TBitmapSource->DeleteDC(dcDTS); if (dctBitmap) tempBitmap->DeleteDC(dctBitmap); // ============= Pattern Bitmap ¸¸µé±â dt->TBitmap = new TTexpiaBitmap; dt->TBitmap->Create(dt->Second.x - dt->First.x, dt->Second.y - dt->First.y, 24); dt->TBitmap->FillRect(Rect(0, 0, dt->MaskBitmap->Width, dt->MaskBitmap->Height), clWhite); if (!tempBitmap->StartScanLine()) goto fail; if (!dt->TBitmap->StartScanLine()) goto fail; if (!dt->MaskBitmap->StartScanLine()) goto fail; if (!dt->PatternAngle) { for (int y = 0; y < dt->TBitmap->Height; y++) { source = tempBitmap->GetScanLine ((y + dt->PatternAdjustY) % tempBitmap->Height); bitmap = dt->TBitmap->GetScanLine(y); mask = dt->MaskBitmap->GetScanLine(y); mm = 0x80; for (int x = 0; x < dt->TBitmap->Width; x++, bitmap += 3) { // if (*mask & (0x80 >> (y & 7))) { if (!(*mask & mm)) { *bitmap = *(source + ((x + dt->PatternAdjustX) % tempBitmap->Width) * 3); *(bitmap + 1) = * (source + ((x + dt->PatternAdjustX) % tempBitmap->Width) * 3 + 1); *(bitmap + 2) = * (source + ((x + dt->PatternAdjustX) % tempBitmap->Width) * 3 + 2); } else { *bitmap = 0; *(bitmap + 1) = 0; *(bitmap + 2) = 0; } if (mm == 1) { mask++; mm = 0x80; } else mm >>= 1; } dt->TBitmap->PutScanLine(y); } tempBitmap->StopScanLine(); dt->TBitmap->StopScanLine(); dt->MaskBitmap->StopScanLine(); } else { // ȸÀüPattern ä¿ì±â for (int y = 0; y < dt->TBitmap->Height; y++) { bitmap = dt->TBitmap->GetScanLine(y); mask = dt->MaskBitmap->GetScanLine(y); mm = 0x80; for (int x = 0; x < dt->TBitmap->Width; x++, bitmap += 3) { if (!(*mask & mm)) { int rotx, roty; roty = x * cos(dt->PatternAngle * M_PI / 180) + y * sin (dt->PatternAngle * M_PI / 180); // + .5; rotx = -x * sin(dt->PatternAngle * M_PI / 180) + y * cos (dt->PatternAngle * M_PI / 180); // + .5; while (rotx < 0) { rotx += tempBitmap->Height; } while (roty < 0) { roty += tempBitmap->Width; } source = tempBitmap->GetScanLine ((rotx + dt->PatternAdjustY) % tempBitmap->Height); *bitmap = * (source + ((roty + dt->PatternAdjustX) % tempBitmap->Width) * 3); *(bitmap + 1) = * (source + ((roty + dt->PatternAdjustX) % tempBitmap->Width) * 3 + 1); *(bitmap + 2) = * (source + ((roty + dt->PatternAdjustX) % tempBitmap->Width) * 3 + 2); } else { *bitmap = 0; *(bitmap + 1) = 0; *(bitmap + 2) = 0; } if (mm == 1) { mask++; mm = 0x80; } else mm >>= 1; } dt->TBitmap->PutScanLine(y); } tempBitmap->StopScanLine(); dt->TBitmap->StopScanLine(); dt->MaskBitmap->StopScanLine(); } if (pPoints) delete[]pPoints; pPoints = NULL; delete tempBitmap; END_LOG; return; next: fail: if (pPoints) delete[]pPoints; pPoints = NULL; delete tempBitmap; END_LOG; } // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- /// Text dataÀÇ font º¯°æ void __fastcall TVecDraw::ChangeTextFont(TFont* font) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) int height, widthsum; double angle; String Text; HFONT font2, oldfont; Char *tempstr = L""; HDC hdc = MainImageForm->iMainImage->Canvas->Handle; SIZE sz; data = (TVecData*)DataList->Items[Index]; UndoSave(VU_MODIFY, Index); _tcscpy(data->Font.lfFaceName, font->Name.c_str()); data->Font.lfHeight = font->Size; data->Font.lfItalic = font->Style.Contains(fsItalic); data->Font.lfUnderline = font->Style.Contains(fsUnderline); if (font->Style.Contains(fsBold)) data->Font.lfWeight = FW_BOLD; else data->Font.lfWeight = FW_NORMAL; data->Font.lfStrikeOut = font->Style.Contains(fsStrikeOut); Text = data->TextString; for (int k = 0; k < data->nCount; k++) tempstr[k] = Char(data->TextString[k + 1]); font2 = CreateFontIndirect(&data->Font); oldfont = (HFONT)SelectObject(hdc, font2); SelectObject(hdc, font2); GetTextExtentPoint32(hdc, tempstr, Text.Length(), &sz); widthsum = sz.cx; SelectObject(hdc, oldfont); DeleteObject(font2); 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); MainImageForm->iMainImage->Repaint(); END_LOG; } // --------------------------------------------------------------------------- /// Text dataÀÇ text, textangle º¯°æ void __fastcall TVecDraw::ChangeTextData(String Text, int textangle) { BEGIN_LOG(""); // RECT rc; TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) int height, widthsum; double angle; String text; HFONT font, oldfont; Char *tempstr = L""; HDC hdc = MainImageForm->iMainImage->Canvas->Handle; SIZE sz; data = (TVecData*)DataList->Items[Index]; UndoSave(VU_MODIFY, Index); data->nCount = Text.Length(); data->Font.lfEscapement = textangle * 10; data->TextString = Text; text = data->TextString; MainImageForm->iMainImage->Canvas->Font->Size = data->Font.lfHeight; 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); // rc.top = min(data->First.y, data->Second.y) - data->Font.lfHeight; // rc.bottom = max(data->First.y, data->Second.y) + data->Font.lfHeight; // rc.left = min(data->First.x, data->Second.x) - data->Font.lfHeight; // rc.right = max(data->First.x, data->Second.x) + data->Font.lfHeight; // MainImageForm->iMainImage->RectPaint(rc); MainImageForm->iMainImage->Repaint(); END_LOG; } // --------------------------------------------------------------------------- /// È­»ìǥŰ·Î object À̵¿ void __fastcall TVecDraw::ArrowObjectMove(int Key, bool bPoint) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) bool sw = true; RECT rc; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; UndoSave(VU_MODIFY, i, sw); sw = false; if (data->Kind == V_TEXT) { switch(Key) { case 37: data->First.x--; data->Second.x--; break; case 38: data->First.y--; data->Second.y--; break; case 39: data->First.x++; data->Second.x++; break; case 40: data->First.y++; data->Second.y++; break; } } else if (data->Kind == V_TEXTBOX) { switch(Key) { case 37: data->First.x--; data->Second.x--; data->StartPoint.x--; break; case 38: data->First.y--; data->Second.y--; data->StartPoint.y--; break; case 39: data->First.x++; data->Second.x++; data->StartPoint.x++; break; case 40: data->First.y++; data->Second.y++; data->StartPoint.y++; break; } } else { switch(Key) { case 37: // left for (int j = 0; j < data->nCount * 3 + 1; j++) { if (!bPoint) data->pList[j].x--; // Object EditÀÎ °æ¿ì else if ((data->pMask[j / 8] >> j % 8) & 0x01) data->pList[j].x--; // Point Edit ÀÎ °æ¿ì } break; case 38: // up for (int j = 0; j < data->nCount * 3 + 1; j++) { if (!bPoint) data->pList[j].y--; else if ((data->pMask[j / 8] >> j % 8) & 0x01) data->pList[j].y--; } break; case 39: // right for (int j = 0; j < data->nCount * 3 + 1; j++) { if (!bPoint) data->pList[j].x++; else if ((data->pMask[j / 8] >> j % 8) & 0x01) data->pList[j].x++; } break; case 40: // down for (int j = 0; j < data->nCount * 3 + 1; j++) { if (!bPoint) data->pList[j].y++; else if ((data->pMask[j / 8] >> j % 8) & 0x01) data->pList[j].y++; } break; } SET_RECT; } int plusRange = data->PenThick*2; if (data->ArrowCap){ plusRange = data->PenThick*data->ArrowCap->LineCapWidthScale*(data->ArrowCap->LineCapWidth + 1)/2; } rc.top = data->First.y - plusRange - 5; rc.bottom = data->Second.y + plusRange + 5; rc.left = data->First.x - plusRange - 5; rc.right = data->Second.x + plusRange + 5; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - ¹ÝÀü °Å¿ïÀÇ º¤ÅÍ ¿µ¿ªÀ» °°ÀÌ ±¸ÇÑ´Ù - by monkman(2005.03.16) if (NVector->bVectorReflectionMode) { GetRealAndReflectionRect(&rc); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- MainImageForm->iMainImage->RectPaint(rc); } END_LOG; } // --------------------------------------------------------------------------- /// ÇöÀç º¸¿©Áö°í Àִ ĵ¹ö½º ¾È¿¡ ÀÖ´Â ¿ÀºêÁ§Æ®ÀÎÁö È®ÀÎ bool __fastcall TVecDraw::ObjectInCanvas(TVecData *data, int px, int py, bool bSelected) { // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¼Óµµ °³¼± - ÇöÀç º¸¿©Áö°í Àִ ĵ¹ö½º ¾È¿¡ ÀÖ´Â ¿ÀºêÁ§Æ®ÀÎÁö È®ÀÎ - by monkman (2005.07.14) int ZoomIn = MainImageForm->iMainImage->ZoomIn; int ZoomOut = MainImageForm->iMainImage->ZoomOut; int PositionX = MainImageForm->sbHorz->Position; int PositionY = MainImageForm->sbVert->Position; int FirstX, FirstY, SecondX, SecondY; RECT ScreenCanvasRect; RECT VectorRect; // ¼Óµµ °³¼± - ÇöÀç º¸¿©Áö´Â ĵ¹ö½ºÀÇ ¿µ¿ªÀ» ±¸ÇÑ´Ù - by monkman (2005.07.12) ScreenCanvasRect.left = 0; ScreenCanvasRect.top = 0; ScreenCanvasRect.right = MainImageForm->iMainImage->Width; ScreenCanvasRect.bottom = MainImageForm->iMainImage->Height; if (bSelected && !data->bSelected) return false; FirstX = (data->First.x - PositionX) * ZoomIn / ZoomOut - px; FirstY = (data->First.y - PositionY) * ZoomIn / ZoomOut - py; SecondX = (data->Second.x - PositionX) * ZoomIn / ZoomOut - px; SecondY = (data->Second.y - PositionY) * ZoomIn / ZoomOut - py; // ¼Óµµ °³¼± - CurveDataÀÇ ¿µ¿ªÀ» ±¸ÇÑ´Ù - by monkman (2005.07.12) if (data->Kind == V_TEXTBOX) { if (data->ListOfAllLine && data->ListOfAllLine->CurveData) { TVecData *CurveData = NULL; CurveData = data->ListOfAllLine->CurveData; int Margin; try { Margin = data->ListOfAllLine->GetLineTextBox(0)->lineHeight * 3; } catch(...) { Margin = 0; } VectorRect.left = ((CurveData->First.x - Margin) - PositionX) * ZoomIn / ZoomOut - px; VectorRect.right = ((CurveData->Second.x + Margin) - PositionX) * ZoomIn / ZoomOut - px; VectorRect.top = ((CurveData->First.y - Margin) - PositionY) * ZoomIn / ZoomOut - py; VectorRect.bottom = ((CurveData->Second.y + Margin) - PositionY) * ZoomIn / ZoomOut - py; } else { VectorRect.left = FirstX; VectorRect.right = SecondX; VectorRect.top = FirstY; VectorRect.bottom = SecondY; for (int i = 0; i < 5; i++) { VectorRect.left = min(VectorRect.left, (data->pList[i].x - PositionX) * ZoomIn / ZoomOut - px); VectorRect.right = max(VectorRect.right, (data->pList[i].x - PositionX) * ZoomIn / ZoomOut - px); VectorRect.top = min(VectorRect.top, (data->pList[i].y - PositionY) * ZoomIn / ZoomOut - py); VectorRect.bottom = max(VectorRect.bottom, (data->pList[i].y - PositionY) * ZoomIn / ZoomOut - py); } } } else { VectorRect.left = FirstX; VectorRect.right = SecondX; VectorRect.top = FirstY; VectorRect.bottom = SecondY; } // ¼Óµµ °³¼± - ¿µ¿ª¾È¿¡ µé¾î¿Â º¤Å͸¸ ±×¸°´Ù - by monkman (2005.07.08) if (!(NVector->bMergeMode) && ((VectorRect.left < ScreenCanvasRect.left && VectorRect.right < ScreenCanvasRect.left) || (VectorRect.top < ScreenCanvasRect.top && VectorRect.bottom < ScreenCanvasRect.top) || (VectorRect.left > ScreenCanvasRect.right && VectorRect.right > ScreenCanvasRect.right) || (VectorRect.top > ScreenCanvasRect.bottom && VectorRect.bottom > ScreenCanvasRect.bottom))) return false; else return true; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } // --------------------------------------------------------------------------- /** TVecData ±¸Á¶¸¦ °®´Â List¸¦ »ý¼º * by monkman (2005.02.16) * Pos´Â À§Ä¡, Count´Â °¹¼ö (Pos:-1 DstList->CountºÎÅÍ, Count:1 1°³) */ bool __fastcall TVecDraw::VecDataListAdd(TList *AddList, int nPos, int nCount) { // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // TVecData ±¸Á¶¸¦ °®´Â List¸¦ »ý¼º - by monkman (2005.02.16) // Pos´Â À§Ä¡, Count´Â °¹¼ö (Pos:-1 DstList->CountºÎÅÍ, Count:1 1°³) TVecData *data = NULL; for (int i = 0; i < nCount; i++) { if ((data = new TVecData(MainImageForm->Number)) == NULL) goto fail; if (nPos <= -1) { AddList->Add(data); } else { AddList->Insert(nPos, data); nPos++; } } return true; fail: return false; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } // --------------------------------------------------------------------------- /** TVecData ±¸Á¶¸¦ °®´Â List¸¦ º¹»ç * by monkman (2005.02.16) * Pos´Â À§Ä¡, Count´Â °¹¼ö (Pos:-1 Á¦ÀÏ µÚ¿¡(Add), Count:-1 DstList->Count ¸¸Å­) * bPatternFill (true:PatternFillÆ÷ÇÔ false:PatternFillºñÆ÷ÇÔ) * bTextBox (true:TextBox Æ÷ÇÔ, false:TextBoxºñÆ÷ÇÔ) */ bool __fastcall TVecDraw::VecDataListCopy(TList *DstList, TList *SrcList, int nDstPos, int nSrcPos, int nCount, bool bSelected, bool bPatternFill, bool bTextBox) { BEGIN_LOG(""); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // TVecData ±¸Á¶¸¦ °®´Â List¸¦ º¹»ç - by monkman (2005.02.16) // Pos´Â À§Ä¡, Count´Â °¹¼ö (Pos:-1 Á¦ÀÏ µÚ¿¡(Add), Count:-1 DstList->Count ¸¸Å­) // , bPatternFill (true:PatternFillÆ÷ÇÔ false:PatternFillºñÆ÷ÇÔ), bTextBox (true:TextBox Æ÷ÇÔ, false:TextBoxºñÆ÷ÇÔ) TVecData *data = NULL, *cdata = NULL; bool bAdd = false; if (nSrcPos == -1 && nDstPos == -1) bAdd = true; if (nSrcPos == -1) nSrcPos = 0; if (nDstPos == -1) nDstPos = 0; if (nCount == -1) nCount = SrcList->Count; // if (nSrcPos < -1 || nDstPos < -1 || nCount < -1 || nSrcPos >= SrcList->Count // || nCount + nSrcPos > SrcList->Count) return false; // if (nCount + nSrcPos > DstList->Count) bAdd = true; for (int i = nSrcPos; i < nCount; i++) { data = (TVecData*)SrcList->Items[i]; if (bSelected && !data->bSelected) continue; if (!bTextBox && (data->Kind == V_TEXT || data->Kind == V_TEXTBOX)) continue; if (!bPatternFill && data->bPatternFill) continue; if ((cdata = new TVecData(data->GetInstNum())) == NULL) goto fail; cdata->Copy(data); cdata->bSelected = data->bSelected; // ¼±Åà ¿É¼Çµµ º¹»ç // cdata->GroupIndex = 0; // GroupIndex´Â copy¾ÈµÇ°Ô.. => copyµÇµµ·Ï Çϱâ À§ÇØ ÁÖ¼®Ã³¸®ÇÔ. if (bAdd) { DstList->Add(cdata); } else { DstList->Insert(nDstPos, cdata); nDstPos++; } } END_LOG; return true; fail: END_LOG; return false; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } // --------------------------------------------------------------------------- /** TVecData ±¸Á¶¸¦ °®´Â List¸¦ À̵¿ * by monkman (2005.02.16) * - Pos´Â À§Ä¡, Count´Â °¹¼ö (Pos:-1 Á¦ÀÏ µÚ¿¡(Add), Count:-1 DstList->Count ¸¸Å­) * - bPatternFill (true:PatternFillÆ÷ÇÔ false:PatternFillºñÆ÷ÇÔ) * - bTextBox (true:TextBox Æ÷ÇÔ, false:TextBoxºñÆ÷ÇÔ) */ bool __fastcall TVecDraw::VecDataListMove(TList *DstList, TList *SrcList, int nDstPos, int nSrcPos, int nCount, bool bSelected, bool bPatternFill, bool bTextBox) { BEGIN_LOG(""); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // TVecData ±¸Á¶¸¦ °®´Â List¸¦ À̵¿ - by monkman (2005.02.16) // Pos´Â À§Ä¡, Count´Â °¹¼ö (Pos:-1 Á¦ÀÏ µÚ¿¡(Add), Count:-1 DstList->Count ¸¸Å­) // , bPatternFill (true:PatternFillÆ÷ÇÔ false:PatternFillºñÆ÷ÇÔ), bTextBox (true:TextBox Æ÷ÇÔ, false:TextBoxºñÆ÷ÇÔ) TVecData *data = NULL; bool bAdd = false; if (nSrcPos == -1 && nDstPos == -1) bAdd = true; if (nSrcPos == -1) nSrcPos = 0; if (nDstPos == -1) nDstPos = 0; if (nCount == -1) nCount = SrcList->Count; // if (nSrcPos < -1 || nDstPos < -1 || nCount < -1 || nSrcPos >= SrcList->Count // || nCount + nSrcPos > SrcList->Count) return false; // if (nCount + nSrcPos > DstList->Count) bAdd = true; for (int i = nSrcPos; i < nCount; ) { data = (TVecData*)SrcList->Items[i]; if (bSelected && !data->bSelected && !bTextBox && (data->Kind == V_TEXT || data->Kind == V_TEXTBOX) && !bPatternFill && data->bPatternFill) { i++; } else { if (bAdd) { DstList->Add(data); } else { DstList->Insert(nDstPos, data); nDstPos++; } SrcList->Remove(data); nCount--; } } END_LOG; return true; fail: END_LOG; return false; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } // --------------------------------------------------------------------------- /** TVecData ±¸Á¶¸¦ °®´Â List¸¦ »èÁ¦ * by monkman (2005.02.16) * Pos´Â À§Ä¡, Count´Â °¹¼ö (Pos:-1 Á¦ÀÏ µÚ¿¡(Add), Count:-1 DstList->Count ¸¸Å­) */ bool __fastcall TVecDraw::VecDataListDelete(TList *DelList, int nPos, int nCount, bool bSelected, bool bDelete) { BEGIN_LOG(""); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // TVecData ±¸Á¶¸¦ °®´Â List¸¦ »èÁ¦ - by monkman (2005.02.16) // Pos´Â À§Ä¡, Count´Â °¹¼ö (Pos:-1 Á¦ÀÏ µÚ¿¡(Add), Count:-1 DstList->Count ¸¸Å­) TVecData *data = NULL; if (nPos == -1) nPos = 0; if (nCount == -1) nCount = DelList->Count; if (nPos < -1 || nCount < -1 || nPos >= DelList->Count || nCount + nPos > DelList->Count) { END_LOG; return false; } for (int i = nPos; i < nCount; ) { data = (TVecData*)DelList->Items[i]; if (bSelected && !data->bSelected) { i++; } else { if (bDelete && data) delete data; DelList->Remove(data); nCount--; } } END_LOG; return true; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } // --------------------------------------------------------------------------- /** ±âÁØÁ¡ ÁÂÇ¥¸¦ ±âÁØÀ¸·Î ÁÂÇ¥µéÀ» º¯È¯Çؼ­ º¹»ç, vector data¸¦ ¸¸µé¾î DstList¿¡ Ãß°¡. * ¹ÝÀü °Å¿ï¿¡¼­ »ç¿ëÇÏ¸ç ±âÁØÁ¡ ÁÂÇ¥¸¦ ±âÁØÀ¸·Î ÁÂÇ¥µéÀ» º¯È¯Çؼ­ º¹»ç - by monkman (2005.02.16) * - Pos´Â À§Ä¡, Count´Â °¹¼ö (Pos:-1 Á¦ÀÏ µÚ¿¡(Add), Count:-1 DstList->Count ¸¸Å­) * - bPatternFill (true:PatternFillÆ÷ÇÔ false:PatternFillºñÆ÷ÇÔ) * - bTextBox (true:TextBox Æ÷ÇÔ, false:TextBoxºñÆ÷ÇÔ) * - VH:0-NONE 1-¼öÁ÷±âÁØ 2-¼öÆò±âÁØ * - ReflectionIndex:±âÁØÁ¡ÁÂÇ¥ */ bool __fastcall TVecDraw::VecDataListReflection(TList *DstList, TList *SrcList, int nPos, int nCount, bool bPatternFill, bool bTextBox, int nVH, int nReflectionIndex) { BEGIN_LOG(""); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï¿¡¼­ »ç¿ëÇÏ¸ç ±âÁØÁ¡ ÁÂÇ¥¸¦ ±âÁØÀ¸·Î ÁÂÇ¥µéÀ» º¯È¯Çؼ­ º¹»ç - by monkman (2005.02.16) // Pos´Â À§Ä¡, Count´Â °¹¼ö (Pos:-1 Á¦ÀÏ µÚ¿¡(Add), Count:-1 DstList->Count ¸¸Å­) // , bPatternFill (true:PatternFillÆ÷ÇÔ false:PatternFillºñÆ÷ÇÔ), bTextBox (true:TextBox Æ÷ÇÔ, false:TextBoxºñÆ÷ÇÔ) // VH:0-NONE 1-¼öÁ÷±âÁØ 2-¼öÆò±âÁØ, ReflectionIndex:±âÁØÁ¡ÁÂÇ¥ TVecData *data = NULL, *cdata = NULL, *childdata = NULL; bool bAdd = false; DPOINT dpFirst, dpSecond; double dpMotiveAxis; if (!(nVH == 1 || nVH == 2 || nReflectionIndex < 0)) { END_LOG; return false; } if (nPos <= -1) { bAdd = true; nPos = DstList->Count; } if (nCount == -1) nCount = SrcList->Count; // by siuaa 080501 // ¹ÝÀü °Å¿ï ±â´ÉÀ» ÅëÇØ º¹»çµÉ objectµéÀÇ group index°¡ ÀÌ¹Ì ÀÖ´Â °Í°ú °ãÃÄÁöÁö ¾Ê°Ô Çϱâ À§ÇØ // Áö±Ý Á¸ÀçÇÏ´Â group index¸¦ ¹Ì¸® Á¶»çÇØµÐ´Ù. // ±×¸®°í ¹Ø¿¡¼­ °°Àº group³¢¸® »õ·Î¿î index¸¦ ºÎ¿©ÇØ º¹»çÇÑ´Ù. int srcGroupCnt = 0; int *tempIndexList = new int[nCount]; for (int i = 0; i < nCount; i++) { data = (TVecData*)SrcList->Items[i]; data->GroupIndex -= ((data->GroupIndex % 10000) & 0x000001ff); int cnt = 0; for (cnt = 0; cnt < srcGroupCnt; cnt++) { if (tempIndexList[cnt] == data->GroupIndex) break; } if (cnt == srcGroupCnt) { tempIndexList[srcGroupCnt] = data->GroupIndex; srcGroupCnt++; } } for (int i = 0; i < DstList->Count; i++) { data = (TVecData*)DstList->Items[i]; if ((cdata = new TVecData(data->GetInstNum())) == NULL) goto fail; cdata->Copy(data); // UNDO ó¸®ÇÒ °Í!! // UndoSave(VU_MODIFY, i); // 2009 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï¿¡¼­ ùÁ¡°ú ³¡Á¡ÀÌ ¿¬°áµÇ´Â °ÍÀÎÁö üũ - by monkman (2009.11.27) if (data->bClosed == false) { // ¹®ÀÚ, ÆÐÅÏÇÊ µîÀº µé¾î°¡Áö ¾Ê´Â´Ù if (data->bFirstJoin == true && data->bLastJoin == true) { // ¿ÀºêÁ§Æ® À̵¿, Æ÷ÀÎÆ® ÆíÁý, È®´ë/Ãà¼Ò, ȸÀü, Reflection IndexÀÇ À̵¿ µî // ¿©·¯ °æ¿ì°¡ ¹ß»ýÇÒ ¼ö ÀÖÀ¸¹Ç·Î ´ÙÀ½°ú °°ÀÌ Ã¼Å©ÇÑ´Ù data->pList = (DPOINT*)HeapReAlloc(GetProcessHeap(), 0, data->pList, sizeof(DPOINT) * (data->nCount * 6 + 1)); // 2¹è·Î ´Ã¸°´Ù data->pMask = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, data->pMask, (data->nCount * 6 + 1) % 8 == 0 ? (data->nCount * 6 + 1) / 8 : (data->nCount * 6 + 1) / 8 + 1); HeapCompact(GetProcessHeap(), 0); if ((NVector->ReflectionVH == 1 && int(data->pList[0].x + 0.5) == NVector->ReflectionVIndex && int(data->pList[data->nCount * 3].x + 0.5) == NVector->ReflectionVIndex) || (NVector->ReflectionVH == 2 && int (data->pList[0].y + 0.5) == NVector->ReflectionHIndex && int (data->pList[data->nCount * 3].y + 0.5) == NVector->ReflectionHIndex)) { // ¹ÝÀü Æ÷ÀÎÆ® Ãß°¡ for (int j = 0; j < data->nCount * 3; j++) { // ¼öÁ÷ ±âÁØÁ¡ if (nVH == 1) data->pList[data->nCount * 6 - j].x = nReflectionIndex * 2 - cdata->pList[j].x; else data->pList[data->nCount * 6 - j].x = cdata->pList[j].x; // ¼öÆò ±âÁØÁ¡ if (nVH == 2) data->pList[data->nCount * 6 - j].y = nReflectionIndex * 2 - cdata->pList[j].y; else data->pList[data->nCount * 6 - j].y = cdata->pList[j].y; } data->nCount *= 2; data->bClosed = true; SET_RECT; } } else if (data->bFirstJoin) { if ((NVector->ReflectionVH == 1 && int(data->pList[0].x + 0.5) == NVector->ReflectionVIndex) || (NVector->ReflectionVH == 2 && int (data->pList[0].y + 0.5) == NVector->ReflectionHIndex)) { data->pList = (DPOINT*)HeapReAlloc(GetProcessHeap(), 0, data->pList, sizeof(DPOINT) * (data->nCount * 6 + 1)); // 2¹è·Î ´Ã¸°´Ù data->pMask = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, data->pMask, (data->nCount * 6 + 1) % 8 == 0 ? (data->nCount * 6 + 1) / 8 : (data->nCount * 6 + 1) / 8 + 1); HeapCompact(GetProcessHeap(), 0); // ±âÁ¸ Æ÷ÀÎÆ® µÚ·Î À̵¿ for (int j = 0; j < data->nCount * 3 + 1; j++) { data->pList[data->nCount * 3 + j].x = cdata->pList[j].x; data->pList[data->nCount * 3 + j].y = cdata->pList[j].y; } // ¹ÝÀü Æ÷ÀÎÆ® Ãß°¡ for (int j = 1; j < data->nCount * 3 + 1; j++) { // ¼öÁ÷ ±âÁØÁ¡ if (nVH == 1) data->pList[data->nCount * 3 - j].x = nReflectionIndex * 2 - cdata->pList[j].x; else data->pList[data->nCount * 3 - j].x = cdata->pList[j].x; // ¼öÆò ±âÁØÁ¡ if (nVH == 2) data->pList[data->nCount * 3 - j].y = nReflectionIndex * 2 - cdata->pList[j].y; else data->pList[data->nCount * 3 - j].y = cdata->pList[j].y; } data->nCount *= 2; SET_RECT; } } else if (data->bLastJoin) { if ((NVector->ReflectionVH == 1 && int(data->pList[data->nCount * 3].x + 0.5) == NVector->ReflectionVIndex) || (NVector->ReflectionVH == 2 && int (data->pList[data->nCount * 3].y + 0.5) == NVector->ReflectionHIndex)) { data->pList = (DPOINT*)HeapReAlloc(GetProcessHeap(), 0, data->pList, sizeof(DPOINT) * (data->nCount * 6 + 1)); // 2¹è·Î ´Ã¸°´Ù data->pMask = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, data->pMask, (data->nCount * 6 + 1) % 8 == 0 ? (data->nCount * 6 + 1) / 8 : (data->nCount * 6 + 1) / 8 + 1); HeapCompact(GetProcessHeap(), 0); // ¹ÝÀü Æ÷ÀÎÆ® Ãß°¡ for (int j = 0; j < data->nCount * 3; j++) { // ¼öÁ÷ ±âÁØÁ¡ if (nVH == 1) data->pList[data->nCount * 6 - j].x = nReflectionIndex * 2 - cdata->pList[j].x; else data->pList[data->nCount * 6 - j].x = cdata->pList[j].x; // ¼öÆò ±âÁØÁ¡ if (nVH == 2) data->pList[data->nCount * 6 - j].y = nReflectionIndex * 2 - cdata->pList[j].y; else data->pList[data->nCount * 6 - j].y = cdata->pList[j].y; } data->nCount *= 2; SET_RECT; } } } // ¹ÝÀü °Å¿ï - ´ÙÀ½ ¹ÝÀü °Å¿ïÀ» À§ÇØ ÃʱâÈ­½ÃÄÑÁØ´Ù - by monkman (2009.11.27) data->bFirstJoin = data->bLastJoin = false; if (cdata) delete cdata; cdata = NULL; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } for (int i = 0; i < nCount; i++) { data = (TVecData*)SrcList->Items[i]; if ((data->Kind == V_TEXT || data->Kind == V_TEXTBOX) && !bTextBox) continue; if (data->bPatternFill && !bPatternFill) continue; if ((cdata = new TVecData(data->GetInstNum())) == NULL) goto fail; cdata->Copy(data); for (int index = 0; index < srcGroupCnt; index++) { // cdata->GroupIndex = 0; // GroupIndex´Â º¹»çÇÏÁö ¾Ê´Â´Ù if (data->GroupIndex != 0 && data->GroupIndex == tempIndexList[index]) { cdata->GroupIndex = MainImageForm->GroupIndexState + (index + 1) * 10000; break; } } // GradientFill Ãß°¡ - by monkman (2009.04.15) if (cdata->bGradientFill) { GradientVecDataReflection(cdata, nVH); } if (nVH == 1) { // ¼öÁ÷ ±âÁØÁ¡ cdata->First.x = MaxInt; cdata->Second.x = 0; for (int j = 0; j < cdata->nCount * 3 + 1; j++) { cdata->pList[j].x = nReflectionIndex * 2 - cdata->pList[j].x; cdata->First.x = min(cdata->First.x, cdata->pList[j].x); cdata->Second.x = max(cdata->Second.x, cdata->pList[j].x); } } else if (nVH == 2) { // ¼öÆò ±âÁØÁ¡ cdata->First.y = MaxInt; cdata->Second.y = 0; for (int j = 0; j < cdata->nCount * 3 + 1; j++) { cdata->pList[j].y = nReflectionIndex * 2 - cdata->pList[j].y; cdata->First.y = min(cdata->First.y, cdata->pList[j].y); cdata->Second.y = max(cdata->Second.y, cdata->pList[j].y); } } else continue; // Motive ¹ÝÀü ó¸® - by monkman (2009.05.01) if (cdata->bMotive && cdata->ChildList && cdata->ChildList->Count > 0) { dpFirst.y = MaxInt; dpSecond.y = 0; for (int j = 0; j < cdata->ChildList->Count; j++) { childdata = (TVecData*)cdata->ChildList->Items[j]; for (int k = 0; k < childdata->nCount * 3 + 1; k++) { dpFirst.y = min(dpFirst.y, childdata->pList[k].y); dpSecond.y = max(dpSecond.y, childdata->pList[k].y); } } for (int j = 0; j < cdata->ChildList->Count; j++) { childdata = (TVecData*)cdata->ChildList->Items[j]; dpMotiveAxis = dpFirst.y + (dpSecond.y - dpFirst.y) / 2; for (int k = 0; k < childdata->nCount * 3 + 1; k++) { childdata->pList[k].y = (dpMotiveAxis * 2) - childdata->pList[k].y; } } } // 2009 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï¿¡¼­ ùÁ¡°ú ³¡Á¡ÀÌ ¿¬°áµÇ´Â °ÍÀÎÁö üũ - by monkman (2009.11.27) if ((data->bFirstJoin == false && data->bLastJoin == false) || (data->bFirstJoin == true && (NVector->ReflectionVH == 1 && (int(data->pList[0].x + 0.5) != NVector->ReflectionVIndex) || NVector->ReflectionVH == 2 && (int(data->pList[0].y + 0.5) != NVector->ReflectionHIndex))) || (data->bLastJoin == true && ((NVector->ReflectionVH == 1 && (int(data->pList[data->nCount * 3].x + 0.5) != NVector->ReflectionVIndex) || NVector->ReflectionVH == 2 && (int(data->pList[data->nCount * 3].y + 0.5)) != NVector->ReflectionHIndex)) )) { if (bAdd) { DstList->Add(cdata); } else { DstList->Insert(nPos, cdata); nPos++; } } else { if (cdata) delete cdata; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // 2009 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï - ´ÙÀ½ ¹ÝÀü °Å¿ïÀ» À§ÇØ ÃʱâÈ­½ÃÄÑÁØ´Ù - by monkman (2009.11.27) data->bFirstJoin = data->bLastJoin = false; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } MainImageForm->GroupIndexState += (srcGroupCnt * 10000); if (tempIndexList) delete[]tempIndexList; tempIndexList = NULL; END_LOG; return true; fail: if (tempIndexList) delete[]tempIndexList; tempIndexList = NULL; END_LOG; return false; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } // --------------------------------------------------------------------------- // 090417 by david void __fastcall TVecDraw::GradientVecDataReflection(TVecData *data, int nVH) { BEGIN_LOG(""); // VecData°¡ Gradient FillÀÏ ¶§ ¹ÝÀü °Å¿ï Àû¿ë - by monkman (2009.04.15) RGBQUAD *rgbColors = NULL; bool bColorReverse = false; if (nVH == 1) { // ¼öÁ÷ ±âÁØÁ¡ if (data->gradientItem == G_LINEAR_SIMPLE) { switch(data->gAngle) { case 0: bColorReverse = true; break; case 1: data->gAngle = 3; break; case 2: break; case 3: data->gAngle = 1; break; } } else if (data->gradientItem == G_LINEAR_CENTER) { switch(data->gAngle) { case 0: break; case 1: data->gAngle = 3; break; case 2: break; case 3: data->gAngle = 1; break; } } else if (data->gradientItem == G_CORNER) { switch(data->gAngle) { case 0: data->gAngle = 1; break; case 1: data->gAngle = 0; break; case 2: data->gAngle = 3; break; case 3: data->gAngle = 2; break; } } } else if (nVH == 2) { // ¼öÆò ±âÁØÁ¡ if (data->gradientItem == G_LINEAR_SIMPLE) { switch(data->gAngle) { case 0: break; case 1: bColorReverse = true; data->gAngle = 3; break; case 2: bColorReverse = true; break; case 3: bColorReverse = true; data->gAngle = 1; break; } } else if (data->gradientItem == G_LINEAR_CENTER) { switch(data->gAngle) { case 0: break; case 1: data->gAngle = 3; break; case 2: break; case 3: data->gAngle = 1; break; } } else if (data->gradientItem == G_CORNER) { switch(data->gAngle) { case 0: data->gAngle = 3; break; case 1: data->gAngle = 2; break; case 2: data->gAngle = 1; break; case 3: data->gAngle = 0; break; } } } if (bColorReverse) { rgbColors = new RGBQUAD[data->gradientColorCount]; if (rgbColors) { memcpy(rgbColors, data->gradientColors, sizeof(RGBQUAD) * data->gradientColorCount); for (int i = 0; i < data->gradientColorCount; i++) { data->gradientColors[i] = rgbColors[data->gradientColorCount - i - 1]; } delete[]rgbColors; rgbColors = NULL; } } rgbColors = NULL; END_LOG; } // --------------------------------------------------------------------------- /// DataList¾È¿¡ ¾î¶² ¼Ó¼ºµéÀÌ µé¾îÀÖ´ÂÁö Á¶»ç°¡ ÇÊ¿äÇÒ¶§.. bSelected (true:¼±ÅÃµÈ °Í¸¸, false:¸ðµÎ) ElementSet __fastcall TVecDraw::ElementsInList(TList *EleList, bool bSelected) { // DataList¾È¿¡ ¾î¶² ¼Ó¼ºµéÀÌ µé¾îÀÖ´ÂÁö Á¶»ç°¡ ÇÊ¿äÇÒ¶§.. bSelected (true:¼±ÅÃµÈ °Í¸¸, false:¸ðµÎ) // - by monkman (2005.05.07) TVecData *data = NULL; ElementSet element; element.Clear(); for (int i = 0; i < EleList->Count; i++) { data = (TVecData*)EleList->Items[i]; if (bSelected && !data->bSelected) continue; switch(data->Kind) { case V_LINE: element << E_LINE; break; case V_CURVE: element << E_CURVE; break; case V_RECT: element << E_RECT; break; case V_ELLIPSE: element << E_ELLIPSE; break; case V_TEXT: element << E_TEXT; break; case V_TEXTBOX: element << E_TEXTBOX; break; } switch(data->PenStyle) { case P_SOLID: element << E_SOLID; break; case P_DASH: element << E_DASH; break; case P_DOT: element << E_DOT; break; case P_DASHDOT: element << E_DASHDOT; break; case P_DASHDOTDOT: element << E_DASHDOTDOT; break; case P_USERSTYLE: element << E_USERSTYLE; break; } switch(int(data->DashValues[0])) { case 0: element << E_DASHDOTNONE; break; case 2: element << E_DASHDOT1PAIR; break; case 4: element << E_DASHDOT2PAIR; break; case 6: element << E_DASHDOT3PAIR; break; } switch(data->PenEndCap) { case P_ENDCAP_FLAT: element << E_ENDCAP_FLAT; break; case P_ENDCAP_ROUND: element << E_ENDCAP_ROUND; break; case P_ENDCAP_SQUARE: element << E_ENDCAP_SQUARE; break; } switch(data->PenJoin) { case P_JOIN_MITER: element << E_JOIN_MITER; break; case P_JOIN_ROUND: element << E_JOIN_ROUND; break; case P_JOIN_BEVEL: element << E_JOIN_BEVEL; break; } if (data->CapStyle[0] > 0 || data->CapStyle[1] > 0) element << E_CAPSTYLE; if (data->bRound) element << E_ROUND; if (data->bFill) element << E_CFILL; if (data->bPatternFill) element << E_PFILL; if (data->bWinding) element << E_WINDING; if (data->bSelected) element << E_SELECTED; if (data->bClosed) element << E_CLOSED; if (data->bLocked) element << E_LOCKED; if (data->bModified) element << E_MODIFIED; if (data->bAntialiasing) element << E_ANTIALIAS; // -->by linuxjun for CurvedVectorText if (data->ParentTextBox) element << E_PTEXTBOX; // <--by linuxjun for CurvedVectorText if (data->bGradientFill) element << E_GRADIENTFILL; } return element; } // --------------------------------------------------------------------------- /// À§Ä¡¿¡¼­ °¡Àå °¡±îÀÌ ÀÖ´Â ¿ÀºêÁ§Æ®ÀÇ ¹øÈ£¸¦ ¸®ÅÏ POINT __fastcall TVecDraw::ApproachObject(TList *DataList, double X, double Y, bool bSelected, bool bPoint) { // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // À§Ä¡¿¡¼­ °¡Àå °¡±îÀÌ ÀÖ´Â ¿ÀºêÁ§Æ®ÀÇ ¹øÈ£¸¦ ¸®ÅÏ (2005.06.22) POINT Index = Point(-1, -1); double MinDist = MaxInt, CurDist = MaxInt; int MinIndex = -1; TVecData *tData = NULL; double PointPosX, PointPosY; // ±ÙÁ¢Á¡ ã±â º¯¼ö (±ÙÁ¢Á¡À» ãÀ» ¶§¸¶´Ù ÀúÀå) - by monkman (2005.01.25) int pListPos; // ±ÙÁ¢Á¡ Áß pListÀÇ À§Ä¡ - by monkman (2005.01.25) // ±ÙÁ¢Á¡ ã±âÀÇ Á¤È®µµ¸¦ ³ôÀ̱â À§ÇØ - by monkman (2007.10.02) DRECT rt; rt.DRect(MainImageForm->iMainImage->RealPosX - 5, MainImageForm->iMainImage->RealPosY - 5, MainImageForm->iMainImage->RealPosX + 5, MainImageForm->iMainImage->RealPosY + 5); // ¿ÀºêÁ§Æ® ¿©·¯°³°¡ ¼±ÅõǾúÀ» ¶§ ÀÚ¸£°íÀÚÇÏ´Â ¿ÀºêÁ§Æ®°¡ ¾î¶²°ÍÀÎÁö ãÀ½ // ãÀº ¿ÀºêÁ§Æ® : MinIndex¹øÂ° Item for (int i = 0; i < DataList->Count; i++) { tData = (TVecData*)DataList->Items[i]; if (!tData->Equal(MainImageForm->Number)) continue; if (bSelected && !tData->bSelected) continue; if (tData->Kind == V_LINE || tData->Kind == V_CURVE) { // Á÷¼±, °î¼±¾ÈÀÇ ¿µ¿ª¿¡ ÀÖ´ÂÁö °Ë»ç // ¼Óµµ °³¼± - »ç°¢ ¿µ¿ª¾È¿¡ µé¾î¿Â ¿ÀºêÁ§Æ®¸¸ °Ë»ö - by monkman (2005.07.11) if (X < tData->First.x - 5 || X > tData->Second.x + 5 || Y < tData->First.y - 5 || Y > tData->Second.y + 5) continue; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // Vector Line ¼±Åà ±â´É - ±âÁ¸ÀÇ PointOnCurvePath ÇÔ¼ö¸¦ ´õ Á¤¹ÐÇÏ°Ô ¼öÁ¤ - by monkman (2005.03.21) CurDist = PointOnCurvePath(tData, X, Y); if (CurDist >= 0 && MinDist >= CurDist) { MinIndex = i; MinDist = CurDist; } if (bPoint && (MinDist > 0 && CurDist > 0 && MinDist == CurDist)) { PointPosX = MaxInt; PointPosY = MaxInt; pListPos = -1; for (int j = 0; j < tData->nCount * 3 + 1; j++) { // ¸ðµç Á¡À» °Ë»ö if (rt.DPtInRect(tData->pList[j].x, tData->pList[j].y)) { // ¾Æ·¡´Â ÃÖ±ÙÁ¢Á¡À» ã±â À§ÇÑ ÀÛ¾÷ if ((PointPosX + PointPosY) > (fabs(MainImageForm->iMainImage->RealPosX - tData->pList[j].x)) + fabs(MainImageForm->iMainImage->RealPosY - tData->pList[j].y)) { PointPosX = fabs (MainImageForm->iMainImage->RealPosX - tData->pList[j].x); PointPosY = fabs (MainImageForm->iMainImage->RealPosY - tData->pList[j].y); pListPos = j; if (MinIndex == -1) MinIndex = i; } } } } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } } Index.x = MinIndex; if (bPoint) Index.y = pListPos; return Index; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } // --------------------------------------------------------------------------- /// À§Ä¡¿¡¼­ °¡Àå °¡±îÀÌ ÀÖ´Â Æ÷ÀÎÆ®ÀÇ ¹øÈ£¸¦ ¸®ÅÏ int __fastcall TVecDraw::ApproachPoint(TVecData *tData, double X, double Y, bool bSelected) { // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // À§Ä¡¿¡¼­ °¡Àå °¡±îÀÌ ÀÖ´Â Æ÷ÀÎÆ®ÀÇ ¹øÈ£¸¦ ¸®ÅÏ (2005.06.22) double PointPosX = MaxInt, PointPosY = MaxInt; // ±ÙÁ¢Á¡ ã±â º¯¼ö (±ÙÁ¢Á¡À» ãÀ» ¶§¸¶´Ù ÀúÀå) - by monkman (2005.01.25) int pListPos = -1; // ±ÙÁ¢Á¡ Áß pListÀÇ À§Ä¡ - by monkman (2005.01.25) // ±ÙÁ¢Á¡ ã±âÀÇ Á¤È®µµ¸¦ ³ôÀ̱â À§ÇØ - by monkman (2007.10.02) DRECT rt; rt.DRect(MainImageForm->iMainImage->RealPosX - 5, MainImageForm->iMainImage->RealPosY - 5, MainImageForm->iMainImage->RealPosX + 5, MainImageForm->iMainImage->RealPosY + 5); if (bSelected && !tData->bSelected) return pListPos; if (tData->Kind != V_LINE && tData->Kind != V_CURVE) return pListPos; // Line°ú curve¿¡¼­¸¸ Point Edit °¡´É for (int j = 0; j < tData->nCount * 3 + 1; j++) { // ¸ðµç Á¡À» °Ë»ö if (rt.DPtInRect(tData->pList[j].x, tData->pList[j].y)) { // ¾Æ·¡´Â ÃÖ±ÙÁ¢Á¡À» ã±â À§ÇÑ ÀÛ¾÷ if ((PointPosX + PointPosY) > (fabs(X - tData->pList[j].x)) + fabs (Y - tData->pList[j].y)) { PointPosX = fabs(X - tData->pList[j].x); PointPosY = fabs(Y - tData->pList[j].y); pListPos = j; } } } return pListPos; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } // --------------------------------------------------------------------------- /** CurvedVectorTextÀÇ ¿µ¿ª°è»ê * CurvedVectorTextÀÇ Rect¸¦ °è»êÇÑ´Ù - by monkman (2005.07.14) */ void __fastcall TVecDraw::GetCurvedVectorTextRect(RECT *RealRect, TVecData *data) { // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // CurvedVectorTextÀÇ Rect¸¦ °è»êÇÑ´Ù - by monkman (2005.07.14) RECT CurrentRect; TList *DataList = NULL; DataList = NVector->DataList; CurrentRect = TRect(MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height, 0, 0); if (data == NULL && DataList->Count > 0) { // ¸¶Áö¸· µ¥ÀÌÅ͸¦ ²¨³»¿Â ÈÄ data = (TVecData*)DataList->Items[DataList->Count - 1]; } // CurvedVectorTextÀÇ Rect¸¦ ±¸ÇÑ´Ù if (data->ListOfAllLine && data->ListOfAllLine->CurveData) { TVecData *CurveData; CurveData = data->ListOfAllLine->CurveData; int Margin; try { Margin = data->ListOfAllLine->GetLineTextBox(0)->lineHeight * 3; } catch(...) { Margin = 0; } CurrentRect.left = CurveData->First.x - Margin - 20; CurrentRect.right = CurveData->Second.x + Margin + 20; CurrentRect.top = CurveData->First.y - Margin - 20; CurrentRect.bottom = CurveData->Second.y + Margin + 20; RealRect->left = min(RealRect->left, CurrentRect.left); RealRect->right = max(RealRect->right, CurrentRect.right); RealRect->top = min(RealRect->top, CurrentRect.top); RealRect->bottom = max(RealRect->bottom, CurrentRect.bottom); return; } else return; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } // --------------------------------------------------------------------------- /** tDataÀÇ °¢ Æ÷ÀÎÆ®µéÀ» ¸ðµÎ °è»êÇØ¼­ ¿Ü°û¿µ¿ª °è»ê * CurveÀÇ °æ¿ì ÇöÀç ±×·ÁÁö´Â ¶óÀÎÀÌ ¸¹ÀÌ ²©ÀÏ °æ¿ì Á¤È®ÇÑ Object¸¦ ÀâÁö ¸øÇÏ´Â °æ¿ì°¡ ÀÖ´Ù ±×·² °æ¿ì »ç¿ëÇÑ´Ù - by monkman (2005.06.14) */ void __fastcall TVecDraw::GetPointListRect(RECT *RealRect, TVecData *data) { // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // CurveÀÇ °æ¿ì ÇöÀç ±×·ÁÁö´Â ¶óÀÎÀÌ ¸¹ÀÌ ²©ÀÏ °æ¿ì Á¤È®ÇÑ Object¸¦ ÀâÁö ¸øÇÏ´Â °æ¿ì°¡ ÀÖ´Ù ±×·² °æ¿ì »ç¿ëÇÑ´Ù - by monkman (2005.06.14) RECT CurrentRect; RECT PointListRect; TList *DataList = NULL; POINT pFst, pScd, pTan2, Temp2, Temp3, Temp4; DataList = NVector->DataList; PointListRect = TRect(MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height, 0, 0); if (RealRect) { // ÀÜ»óÀ» ¾ø¾Ö±â À§ÇØ ¿µ¿ªÀ» Á¶±Ý ´õ Å©°Ô Àâ´Â´Ù CurrentRect.left = RealRect->left - 10; CurrentRect.top = RealRect->top - 10; CurrentRect.right = RealRect->right + 10; CurrentRect.bottom = RealRect->bottom + 10; } else { CurrentRect = TRect(MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height, 0, 0); } if (data == NULL && DataList->Count > 0) { // ¸¶Áö¸· µ¥ÀÌÅ͸¦ ²¨³»¿Â ÈÄ data = (TVecData*)DataList->Items[DataList->Count - 1]; } if (data && !(NVector->bFstLine )) { if (data->Kind == V_CURVE && data->nCount > 0) { // ¸¶Áö¸· µ¥ÀÌÅÍÀÇ ½ÇÁ¦Á¡°ú Á¶ÀýÁ¡À» ²¨³»¿Â ÈÄ ¿µ¿ªÀ» ±¸ÇÑ´Ù for (int i = (data->nCount - 1) * 3 + 2; i < data->nCount * 3 + 1; i++) { PointListRect.left = min(data->pList[i].x, PointListRect.left); PointListRect.top = min(data->pList[i].y, PointListRect.top); PointListRect.right = max(data->pList[i].x, PointListRect.right); PointListRect.bottom = max(data->pList[i].y, PointListRect.bottom); } } // ¸¶Áö¸·À¸·Î Âï¾ú´ø Á¡À» °¡Á®¿Í ¿µ¿ªÀ» ±¸ÇÑ´Ù // ----> CurveAdd() ÀÌ¿ëÇØ¼­ ±¸ÇÔ pFst = Point(NVector->Lsx, NVector->Lsy); pScd = Point(NVector->Csx, NVector->Csy); pTan2 = Point(NVector->Lex, NVector->Ley); pTan2.x = pScd.x * 2 - pTan2.x; // IllustraterÀÇ ¹æ½ÄÀ» µû¸£±â À§ÇÔ pTan2.y = pScd.y * 2 - pTan2.y; if (!(NVector->bFstLine)) { // ¿¬¼ÓµÈ °î¼± Temp2 = data->pList[data->nCount * 3 - 1].P(); Temp3 = data->pList[data->nCount * 3].P(); if (VectorForm->LineType == 1) { // ±â¿ï±â °øÀ¯ÇÏÁö ¾Ê´Â °î¼± Temp4.x = Temp3.x; Temp4.y = Temp3.y; } else if (VectorForm->LineType == 3) { // ±â¿ï±â À̾îÁö´Â °î¼± Temp4.x = Temp3.x * 2 - Temp2.x; Temp4.y = Temp3.y * 2 - Temp2.y; } PointListRect.left = min(Temp4.x, PointListRect.left); PointListRect.top = min(Temp4.y, PointListRect.top); PointListRect.right = max(Temp4.x, PointListRect.right); PointListRect.bottom = max(Temp4.y, PointListRect.bottom); } // <---- CurveAdd() ÀÌ¿ëÇØ¼­ ±¸ÇÔ // °¡Àå Å« ¿µ¿ªÀ» ±¸ÇÑ´Ù RealRect->left = min(CurrentRect.left, PointListRect.left); RealRect->top = min(CurrentRect.top, PointListRect.top); RealRect->right = max(CurrentRect.right, PointListRect.right); RealRect->bottom = max(CurrentRect.bottom, PointListRect.bottom); // ¿µ¿ªÀÇ Å©±â¸¦ º¼ ¶§ À¯¿ëÇÑ ¼Ò½º /* HDC dcDst = MainImageForm->iMainImage->Canvas->Handle; HBRUSH hOldBrush = NULL, hBrush = NULL; LOGBRUSH logbrush; RECT UnionRect; logbrush.lbStyle = BS_SOLID; logbrush.lbColor = clBlue; logbrush.lbHatch = 0; hBrush=CreateSolidBrush(0xFF0000); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); FillRect(dcDst, RealRect, hBrush); hBrush = (HBRUSH)SelectObject(dcDst, hOldBrush); if (hBrush) DeleteObject(hBrush); hBrush = NULL; */ } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } // --------------------------------------------------------------------------- /// ¼±ÅÃµÈ objectÀÇ ½ÇÁ¦ ¿µ¿ª°ú ¹ÝÀü ¿µ¿ª Àüü °è»ê void __fastcall TVecDraw::GetRealAndReflectionRect(RECT *RealRect) { // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - RectPaintÇÒ ¹ÝÀü °Å¿ïÀÇ Object Rect¸¦ ±¸ÇÏ°í ½ÇÁ¦ ObjectÀÇ Rect¿Í min, max ¿¬»êÀ» ÇÑ´Ù - by monkman(2005.03.16) POINT First, Second; if (NVector->bVectorReflectionMode) { if (NVector->ReflectionVH == 1) { // ¼öÁ÷ ±âÁؼ± Second.x = NVector->ReflectionVIndex * 2 - RealRect->left; First.y = RealRect->top; First.x = NVector->ReflectionVIndex * 2 - RealRect->right; Second.y = RealRect->bottom; } if (NVector->ReflectionVH == 2) { // ¼öÆò ±âÁؼ± First.x = RealRect->left; Second.y = NVector->ReflectionHIndex * 2 - RealRect->top; Second.x = RealRect->right; First.y = NVector->ReflectionHIndex * 2 - RealRect->bottom; } } RealRect->left = min(RealRect->left, First.x); RealRect->right = max(RealRect->right, Second.x); RealRect->top = min(RealRect->top, First.y); RealRect->bottom = max(RealRect->bottom, Second.y); // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } // --------------------------------------------------------------------------- /// ¼±ÅÃµÈ objectÀÇ ½ÇÁ¦ ¿µ¿ª °è»ê void __fastcall TVecDraw::GetRealObjectRect(RECT *RealRect, bool bSel) { // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - RectPaintÇÒ ObjectÀÇ Rect¸¦ ±¸ÇÑ´Ù - by monkman(2005.03.16) TList *DataList = NVector->DataList; TVecData *data; *RealRect = Rect(MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height, 0, 0); if (bSel) if (!NVector->bSelected) return; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (NVector->bSelected) if (!data->bSelected) continue; // ¼±ÅÃµÈ ¿ÀºêÁ§Æ®µéÀÇ ¿µ¿ª¸¸Å­¸¸ RectPaintÇϱâ À§ÇØ.. SET_RECT; RealRect->left = min(RealRect->left, (data->First.x - data->PenThick)); RealRect->top = min(RealRect->top, (data->First.y - data->PenThick)); RealRect->right = max(RealRect->right, (data->Second.x + data->PenThick)); RealRect->bottom = max(RealRect->bottom, (data->Second.y + data->PenThick)); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } // --------------------------------------------------------------------------- /// ¼±ÅÃµÈ objectÀÇ ¹ÝÀü¿µ¿ª °è»ê void __fastcall TVecDraw::GetReflectionRect(RECT *RefletionRect, bool bSel) { // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - RectPaintÇÒ ¹ÝÀü °Å¿ïÀÇ Object Rect¸¦ ±¸ÇÑ´Ù - by monkman(2005.03.16) TList *DataList = NVector->DataList; TVecData *data; *RefletionRect = Rect(MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height, 0, 0); POINT First, Second; if (bSel) if (!NVector->bSelected) return; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (NVector->bSelected) if (!data->bSelected) continue; // ¼±ÅÃµÈ ¿ÀºêÁ§Æ®µéÀÇ ¿µ¿ª¸¸Å­¸¸ RectPaintÇϱâ À§ÇØ.. SET_RECT; if (NVector->bVectorReflectionMode) { if (NVector->ReflectionVH == 1) { // ¼öÁ÷ ±âÁؼ± Second.x = NVector->ReflectionVIndex * 2 - data->First.x; First.x = data->First.y; First.x = NVector->ReflectionVIndex * 2 - data->Second.x; Second.y = data->Second.y; } if (NVector->ReflectionVH == 2) { // ¼öÆò ±âÁؼ± First.x = data->First.x; Second.y = NVector->ReflectionHIndex * 2 - data->First.y; Second.x = data->Second.x; First.y = NVector->ReflectionHIndex * 2 - data->Second.y; } } RefletionRect->left = min(RefletionRect->left, (First.x - data->PenThick)); RefletionRect->top = min(RefletionRect->top, (First.y - data->PenThick)); RefletionRect->right = max(RefletionRect->right, (Second.x + data->PenThick)); RefletionRect->bottom = max(RefletionRect->bottom, (Second.y + data->PenThick)); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } // --------------------------------------------------------------------------- void __fastcall TVecDraw::CheckSelected() { int selectedcount = SelectedObjectCount(); if (selectedcount) { NVector->bSelected = true; } else { NVector->bSelected = false; } } // --------------------------------------------------------------------------- /// ¼±ÅÃµÈ objectµéÀÇ °¹¼ö ¹Ýȯ int __fastcall TVecDraw::SelectedObjectCount() { TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) int count = 0, index; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (data->bSelected) { count++; index = i; } } if (count) NVector->bSelected = true; else NVector->bSelected = false; if (count == 1) Index = index; // 1°³ÀÇ °æ¿ìÀÇ index¸¦ º¸³»Áà~ return count; } // --------------------------------------------------------------------------- /// ¼±ÅÃµÈ objectµéÀÇ ¿Ü°û¿µ¿ª °è»ê TRect __fastcall TVecDraw::GetObjectRect() { TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) long minx = MaxInt, miny = MaxInt, maxx = 0, maxy = 0; int maxthick = 0; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; minx = min(minx, data->First.x); minx = min(minx, data->Second.x); maxx = max(maxx, data->First.x); maxx = max(maxx, data->Second.x); miny = min(miny, data->First.y); miny = min(miny, data->Second.y); maxy = max(maxy, data->First.y); maxy = max(maxy, data->Second.y); maxthick = max(maxthick, data->PenThick); } return Rect(minx - maxthick, miny - maxthick, maxx + maxthick, maxy + maxthick); } // --------------------------------------------------------------------------- /// ¼±ÅÃµÈ objectÀÇ Á¤º¸¸¦ ¾òÀ½. void __fastcall TVecDraw::GetSingleObjectData(double &PenThick, int &PenStyle, int &num, bool &PenShape, EVecKind &kind, String &text) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) text = ""; data = (TVecData*)DataList->Items[Index]; kind = data->Kind; if (kind != V_TEXT) { PenThick = data->PenThick; PenStyle = data->PenStyle; PenShape = data->bRound; GetDashPattern(data); // 2005 Vector Upgrade Shin 0315 : num Ãß°¡ if (PenStyle == P_USERSTYLE) { num = data->DashValues[0]; } } else { // TextÀÇ °æ¿ì¿¡´Â Penthick´ë½Å¿¡ °¢µµ¸¦ ¹ÝȯÇÑ´Ù PenThick = data->Font.lfEscapement / 10; text = data->TextString; } if (data->ParentTextBox) kind = V_TEXTBOX; // Curved TextÀÇ °æ¿ì¿¡µµ ¹®ÀڷΠó¸® - by monkman (2009.05.01) END_LOG; } // --------------------------------------------------------------------------- /// Àüü ¼±Åà void __fastcall TVecDraw::SelectAll() { TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (data->ListOfAllLine && data->ListOfAllLine->CurveData) continue; // ÆÐ½º¹®ÀÚÀÇ ¹®ÀÚ´Â bSelect°¡ Ç×»ó false if (data->bLocked) { data->bSelected = false; continue; } data->bSelected = true; } if (DataList->Count > 0) NVector->bSelected = true; else NVector->bSelected = false; NVector->bUndosw = true; } // --------------------------------------------------------------------------- /// Àüü ¼±ÅÃÇØÁ¦ void __fastcall TVecDraw::deSelect() { TList *DataList = NVector->DataList; TVecData *data = NULL, *childdata = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; data->bSelected = false; } } // --------------------------------------------------------------------------- /// ¼± ±×¸®±â µµÁß ÇÑÁ¡µÚ·Î void __fastcall TVecDraw::PointBack(int &Lsx, int &Lsy) { TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) RECT rc1; BEGIN_LOG(""); // °î¼±À» ±×¸®´Â Áß ÇÑÁ¡ µÚ·Î ÇÒ °æ¿ìµµ ó¸®ÇϱâÀ§ÇØ ¼ø¼­¸¦ º¯°æÇϰí // dataÀÇ NULL À¯¹«·Î üũÇÏ¿´´Ù - by monkman (2012.01.16) if (0 < DataList->Count) { if (NVector->bExtend) data = (TVecData*)DataList->Items[Index]; else data = (TVecData*)DataList->Items[DataList->Count - 1]; } if (NVector->step == 2) { // °î¼± ±â¿ï±â ±×¸®°í ÀÖ´Â µµÁß NVector->step = 1; rc1.top = 0; rc1.left = 0; } else if (NVector->step == 1 && NVector->bFstLine) { if (data) { rc1.top = data->First.y - data->PenThick - 5; rc1.left = data->First.x - data->PenThick - 5; } goto next; } else { if (data == NULL || data->nCount == 0) { END_LOG; return; } rc1.top = data->First.y - data->PenThick - 5; rc1.left = data->First.x - data->PenThick - 5; 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); Lsx = data->pList[data->nCount * 3].x; Lsy = data->pList[data->nCount * 3].y; } if (data) { if (data->nCount > 0) { // ±â¿ï±â À̾îÁø ¼±À» À§ÇØ pTan.x = data->pList[data->nCount * 3].x * 2 - data->pList [data->nCount * 3 - 1].x; pTan.y = data->pList[data->nCount * 3].y * 2 - data->pList [data->nCount * 3 - 1].y; } SET_RECT; } next: rc1.bottom = MainImageForm->iMainImage->uBitmap->Height; rc1.right = MainImageForm->iMainImage->uBitmap->Width; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - ¹ÝÀü °Å¿ïÀÇ º¤ÅÍ ¿µ¿ªÀ» °°ÀÌ ±¸ÇÑ´Ù - by monkman(2005.03.16) if (NVector->bVectorReflectionMode) { GetRealAndReflectionRect(&rc1); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // º¯È­µÈ data->pList¿¡ µû¶ó PatternFillÀ» ´Ù½Ã °è»êÇØÁØ´Ù - by monkman (2005.08.03) if (data && data->bPatternFill) MakePatternBitmap(data); MainImageForm->iMainImage->RectPaint(rc1); END_LOG; } // --------------------------------------------------------------------------- /** rgn¾È¿¡ Á¡ÀÌ Æ÷ÇԵǴÂÁöÀÇ ¿©ºÎ·Î object ¼±Åà * ¿Ã°¡¹Ì ÁÂÇ¥ Æ÷ÀÎÆ®¸®½ºÆ®¸¦ ÂüÁ¶ÇÏ¿© º¤ÅÍ ¿ÀºêÁ§Æ® ¼±ÅÃÇϱâ - by monkman (2005.02.04) * IrregularState (0:¿Ã°¡¹Ì¸¸ ¼±Åà 1:±âÁ¸ ¿µ¿ª¿¡ ¿Ã°¡¹Ì ¿µ¿ªÀ» Ãß°¡ 2:±âÁ¸ ¿µ¿ª¿¡¼­ ¿Ã°¡¹Ì ¿µ¿ªÀ» Á¦°Å) * bPoint (true:Object¸¦ Point´ÜÀ§·Î ¼±Åà false:Object ´ÜÀ§·Î ¼±ÅÃ) */ void __fastcall TVecDraw::RegionToObjectSelect(HRGN *rgn, short IrregularState, bool bPoint) { BEGIN_LOG(""); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¿Ã°¡¹Ì ÁÂÇ¥ Æ÷ÀÎÆ®¸®½ºÆ®¸¦ ÂüÁ¶ÇÏ¿© º¤ÅÍ ¿ÀºêÁ§Æ® ¼±ÅÃÇϱâ - by monkman (2005.02.04) // IrregularState (0:¿Ã°¡¹Ì¸¸ ¼±Åà 1:±âÁ¸ ¿µ¿ª¿¡ ¿Ã°¡¹Ì ¿µ¿ªÀ» Ãß°¡ 2:±âÁ¸ ¿µ¿ª¿¡¼­ ¿Ã°¡¹Ì ¿µ¿ªÀ» Á¦°Å) // bPoint (true:Object¸¦ Point´ÜÀ§·Î ¼±Åà false:Object ´ÜÀ§·Î ¼±ÅÃ) TList *DataList = NVector->DataList; TVecData *data; bool bUnionSelectedPoint; // ÇÑ °³¶óµµ ¼±ÅÃµÈ ¿ÀºêÁ§Æ®°¡ ÀÖ´ÂÁö.. bool bSubSelectedPoint; // ÇÑ Æ÷ÀÎÆ®¶óµµ ¼±ÅÃµÈ ¿ÀºêÁ§Æ®ÀÇ Æ÷ÀÎÆ®°¡ ÀÖ´ÂÁö.. bUnionSelectedPoint = false; if (IrregularState == 0) { VecDraw->deSelect(); // ¿Ã°¡¹Ì¸¸ ¼±Åà ½Ã ÀÏ´Ü ¸ðµç ¼±ÅÃÀ» ÇØÁ¦ NVector->bSelected = false; } for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (data->bLocked) continue; // -->by linuxjun for CurvedVectorText if (data->Kind == V_TEXTBOX) { if (data->ListOfAllLine->CurveData) continue; } // <--by linuxjun for CurvedVectorText if (data->Kind == V_LINE || data->Kind == V_CURVE) { if (IrregularState == 0) { if (data->pMask) { memset(data->pMask, 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); } } for (int j = 0; j < data->nCount * 3 + 1; j += 3) { // ½ÇÁ¦Á¡¸¸ ã¾Æ¼­ °Ë»çÇÑ´Ù if (PtInRegion(*rgn, (int)(data->pList[j].x + 0.5), (int)(data->pList[j].y + 0.5))) { // ¿µ¿ª¾È¿¡ ¿ÀºêÁ§Æ®ÀÇ Æ÷ÀÎÆ® ÁÂÇ¥°¡ ÀÖ´Ù¸é.. if (IrregularState == 0) { // ¿Ã°¡¹Ì¸¸ ¼±Åà ½Ã.. data->bSelected = true; if (data->bSelected) bUnionSelectedPoint = true; if (bPoint) { data->pMask[j / 8] |= (0x01 << (j % 8)); // Ãß°¡ } else break; } if (IrregularState == 1) { // ±âÁ¸ ¿µ¿ª¿¡ ¿Ã°¡¹Ì ¿µ¿ªÀ» Ãß°¡ data->bSelected = true; if (data->bSelected) bUnionSelectedPoint = true; if (bPoint) { data->pMask[j / 8] |= (0x01 << (j % 8)); // Ãß°¡ } else break; } if (IrregularState == 2) { // ±âÁ¸ ¿µ¿ª¿¡¼­ ¿Ã°¡¹Ì ¿µ¿ªÀ» Á¦°Å if (bPoint) { data->pMask[j / 8] &= ~(0x01 << (j % 8)); // Á¦°Å } else { data->bSelected = false; break; } } } } if (bPoint && IrregularState == 2) { // Object¸¦ Point´ÜÀ§·Î ¼±ÅÃÀÇ °æ¿ìÀ̰í, ±âÁ¸ ¿µ¿ª¿¡¼­ ¿Ã°¡¹Ì ¿µ¿ªÀ» Á¦°Å ½Ã.. bSubSelectedPoint = false; for (int k = 0; k < data->nCount * 3 + 1; k += 3) { // ½ÇÁ¦Á¡¸¸ ã¾Æ¼­ °Ë»çÇÑ´Ù // ÇÑ ¿ÀºêÁ§Æ®¿¡¼­ Çϳª¶óµµ ¼±ÅÃµÈ Æ÷ÀÎÆ®°¡ ÀÖ´Ù¸é bSubSelectedPoint |= (bool)(data->pMask[k / 8] >> (0x01 << (k % 8))); } if (bSubSelectedPoint) { // ¼±ÅÃÇÑ´Ù data->bSelected = true; bUnionSelectedPoint = true; } else { // ¸ðµç Æ÷ÀÎÆ®°¡ ºüÁ³´Ù¸é ¼±ÅÃÀ» ÇØÁ¦ÇÑ´Ù data->bSelected = false; memset(data->pMask, 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); } } } else if (data->Kind == V_TEXTBOX) { // todo : ¹®Á¦°¡ À־ ¾ÆÁ÷Àº »ç¿ëÇÏÁö ¾Ê´Â´Ù ³ªÁß¿¡ ¼öÁ¤Çؼ­ »ç¿ëÇØ¾ßÇÒ µí.. - by monkman (2005.06.22) // if (PtInRegion(*rgn, (int)data->First.x+0.5, (int)data->First.y+0.5) // || PtInRegion(*rgn, (int)data->First.x+0.5, (int)data->Second.y+0.5) // || PtInRegion(*rgn, (int)data->Second.x+0.5, (int)data->First.y+0.5) // || PtInRegion(*rgn, (int)data->Second.x+0.5, (int)data->Second.y+0.5)) { // if (IrregularState==0) { // ¿Ã°¡¹Ì¸¸ ¼±Åà ½Ã.. // data->bSelected = true; // bUnionSelectedPoint = true; // } // if (IrregularState==1) { // ±âÁ¸ ¿µ¿ª¿¡ ¿Ã°¡¹Ì ¿µ¿ªÀ» Ãß°¡ // data->bSelected = true; // bUnionSelectedPoint = true; // } // if (IrregularState==2) { // ±âÁ¸ ¿µ¿ª¿¡¼­ ¿Ã°¡¹Ì ¿µ¿ªÀ» Á¦°Å // data->bSelected = false; // } // } } } if (bUnionSelectedPoint) NVector->bSelected = true; // ¿ÀºêÁ§Æ®°¡ ¼±ÅõǾú´Ù¸é // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- END_LOG; } // --------------------------------------------------------------------------- /** X, Y À§Ä¡ÀÇ VectorÀÇ Color ÃßÃâ * Vector Color¸¦ ÃßÃâÇÏ¿© ¼±ÅõǾîÀÖ´Â PaletteÀÇ »ö»óÀ» º¯°æÇϰí, * PenManagerÀÇ »ö»óÀ» ¹Ù²Ù±â */ bool __fastcall TVecDraw::GetVectorColor(int X, int Y, COLORREF *PosColor) { BEGIN_LOG(""); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // Vector Color¸¦ ÃßÃâÇÏ¿© ¼±ÅõǾîÀÖ´Â PaletteÀÇ »ö»óÀ» º¯°æÇϰí, // PenManagerÀÇ »ö»óÀ» ¹Ù²Ù±â TList *DataList = NVector->DataList; TVecData *data; bool bRtn = false; DWORD color = 0; BYTE *pData = NULL; int nColorMode; for (int i = DataList->Count - 1; i >= 0; i--) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; nColorMode = IsInObject(data, X, Y); // ¸¶¿ì½º À§Ä¡¿¡ ÇØ´çÇÏ´Â Vector°¡ Á¸Àç if (nColorMode == 1) { // Line Color if (data->Kind == V_TEXTBOX) { // TextBox // todo : ³ªÁß¿¡ ó¸® *PosColor = (COLORREF)GetCharacterColor(data, X, Y); bRtn = true; break; } else { // Etc color = data->Color; *PosColor = (COLORREF)color; bRtn = true; break; } } else if (nColorMode == 2) { // Fill Color if (data->bFill) { // ColorFill color = data->Brush; *PosColor = (COLORREF)color; bRtn = true; break; } else if (data->bPatternFill) { // PatternFill if (!data->TBitmap) goto fail; if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { MainImageForm->iMainImage->uBitmap->StartScanLine(); pData = MainImageForm->iMainImage->uBitmap->GetScanLine (Y - data->First.y, X - data->First.x, 1); *PosColor = *pData; MainImageForm->iMainImage->uBitmap->StopScanLine(); } else { *PosColor = (COLORREF)data->TBitmap->GetPixelColor(X - data->First.x, Y - data->First.y); } bRtn = true; break; } } } END_LOG; return bRtn; fail: bRtn = false; END_LOG; return bRtn; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } // --------------------------------------------------------------------------- /** ÁÂÇ¥°ªÀÌ data ¾È¿¡ ÀÖ´ÂÁö °Ë»çÇÑ´Ù * Return °ª (0:None, 1:Line, 2:Object(Filling)) */ int __fastcall TVecDraw::IsInObject(TVecData *data, int X, int Y, bool bSelect) { // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ÁÂÇ¥°ªÀÌ Vector ¾È¿¡ ÀÖ´ÂÁö °Ë»çÇÑ´Ù // Return °ª (0:None, 1:Line, 2:Object(Filling)) int FirstX, FirstY, SecondX, SecondY; HRGN rgnData; HDC dcData; bool bOnObject = false; int nRtn = 0; POINT *pPoints = NULL; // pPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) if (data->Kind == V_TEXTBOX) { // V_TEXTBOXÀÇ ¿µ¿ªÀ» ±¸ÇÏ°í ±× ¾È¿¡ ÀÖ´ÂÁö °Ë»ç MakeTextBoxPointList(data); // ¿µ¿ª ±¸Çϱâ if (CursorInTextBox(X, Y, data)) nRtn = 1; // ¿µ¿ª ¾È¿¡ ÀÖ´ÂÁö °Ë»ç } else { if (data->Kind == V_TEXT) { // V_TEXT´Â ¿µ¿ª ¾È¿¡¸¸ ÀÖÀ¸¸é OK FirstY = min(data->First.y, data->Second.y); SecondY = max(data->First.y, data->Second.y); FirstX = min(data->First.x, data->Second.x); SecondX = max(data->First.x, data->Second.x); if (!(X < FirstX || X > SecondX || Y < FirstY || Y > SecondY)) nRtn = 1; } else { // ±× ¿ÜÀÇ °æ¿ì ÀÏ´Ü Å׵θ® ¿µ¿ªÀ» ±¸Çϰí, ¾Æ·¡¿¡¼­ ½ÇÁ¦ ¿µ¿ªÀ» ±¸ÇÑ´Ù FirstX = data->First.x - data->PenThick; FirstY = data->First.y - data->PenThick; SecondX = data->Second.x + data->PenThick; SecondY = data->Second.y + data->PenThick; } if (!(X < FirstX || X > SecondX || Y < FirstY || Y > SecondY)) bOnObject = true; if (bOnObject) { // ¿µ¿ª ¾È¿¡ µé¾î°¬À» ¶§.. if (data->Kind == V_LINE || data->Kind == V_CURVE) { // ÀÌ ¿ÜÀÇ °æ¿ì´Â ¾ø´Ù!! if (PointOnCurvePath(data, X, Y, 0, 0, 0) >= 0) nRtn = 1; // Á÷¼±À̳ª °î¼± À§¿¡ ÀÖ´ÂÁö °Ë»ç else { if (bSelect || data->bFill || data->bPatternFill) { //bSelectÃß°¡ if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new POINT[(data->nCount + 1) * 3 + 1]; } else { pPoints = new POINT[data->nCount * 3 + 1]; } // FillÀ̳ª PatternFillÀÌ µÇ¾ú´ÂÁö °Ë»ç // ½ÇÁ¦ ¿µ¿ªÀ» ±¸ÇÑ´Ù dcData = GetDC(hWnd); // 0); //shin 070327 Vista¿¡¼± GetDC(NULL)ÇÏ¸é ¾ÈµÊ. (¾Æ¹« DC³ª ¸¸µé¾îÁÖ¸é ´Ù µÊ) if (dcData) { BeginPath(dcData); for (int i = 0; i < data->nCount * 3 + 1; i++) { pPoints[i].x = (int)data->pList[i].x + 0.5; pPoints[i].y = (int)data->pList[i].y + 0.5; } MoveToEx(dcData, pPoints[0].x, pPoints[0].y, NULL); PolyBezierTo(dcData, pPoints + 1, data->nCount * 3); CloseFigure(dcData); EndPath(dcData); rgnData = PathToRegion(dcData); if (PtInRegion(rgnData, X, Y)) nRtn = 2; // ÁÂÇ¥°¡ ¿µ¿ª¾È¿¡ ÀÖ´ÂÁö °Ë»ç else nRtn = 0; ReleaseDC(0, dcData); } if (pPoints) delete[]pPoints; pPoints = NULL; } } } } else nRtn = 0; } pPoints = NULL; // Return °ª (0:None, 1:Line, 2:Object(Filling)) return nRtn; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // Group Handling // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- /// ¼±ÅÃµÈ ¿ÀºêÁ§Æ®µéÀ» number¹ø ±×·ìÀ¸·Î ¼³Á¤ void __fastcall TVecDraw::MakeGroup(int number) { // GroupÀ» Number·Î ±¸ºÐÇÏ¿© Á÷Á¢ ¼±Åà (Popupmenu¾È¿¡ ÀÖÀ½) TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if ((data->GroupIndex % 10000) & (1 << number)) // by siuaa 080501 data->GroupIndex -= 1 << number; if (!data->bSelected) continue; if (!((data->GroupIndex % 10000) & (1 << number))) data->GroupIndex += 1 << number; } } // --------------------------------------------------------------------------- /// ¼±ÅÃµÈ ¿ÀºêÁ§Æ®µéÀÇ ±×·ì¼³Á¤ void __fastcall TVecDraw::MakeGroup() { // illustrator¹æ½ÄÀÇ Group À» »ý¼º TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) int index = 0; bool sw = true; if (!(NVector->bSelected)) return; if (SelectedObjectCount() == 1) return; BEGIN_LOG(""); // ======= index Á¤Çϱâ (group number Á¤Çϱâ) /* for (int i = 0; i < DataList->Count; i++) { data = (TVecData *)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->GroupIndex) continue; index |= data->GroupIndex; } for (int i = 10; i < 32; i++) { if (index & (1 << i)) continue; index = i; break; } */ // by siuaa 080501 // ¹øÈ£°¡ ¾ø´Â groupÀÇ index´Â global·Î º¯¼ö¸¦ Àâ¾Æ¼­ 10000ºÎÅÍ Â÷·Ê·Î Áõ°¡ ½ÃÄÑ index¸¦ ºÎ¿© ÇÑ´Ù. // ¹øÈ£°¡ ÀÖ´Â groupÀÇ index´Â ±âÁ¸°ú µ¿ÀÏÇÏ°Ô bit¿¬»êÀ¸·Î 1~9±îÁö ¹øÈ£¸¦ ºÎ¿©ÇÑ´Ù. MainImageForm->GroupIndexState += 10000; index = MainImageForm->GroupIndexState; // == Group Index´Â 1~9±îÁö´Â ¹øÈ£ÁöÁ¤ ±×·ì, ±× ÀÌ»óÀº ¹ÌÁöÁ¤ ±×·ìÀ¸·Î ÇÑ´Ù. for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; // if (data->GroupIndex & (1<GroupIndex -= 1<bSelected) continue; UndoSave(VU_MODIFY, i, sw); sw = false; // data->GroupIndex &= 0x000001ff; data->GroupIndex = (data->GroupIndex % 10000) & 0x000001ff; // if (!(data->GroupIndex & (1<GroupIndex += 1<GroupIndex += index; } END_LOG; } // --------------------------------------------------------------------------- /// ObjectÀÇ Group¼Ó¼ºÀ» Á¦°Å void __fastcall TVecDraw::UnGroup() { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) bool sw = true; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; UndoSave(VU_MODIFY, i, sw); sw = false; // data->GroupIndex &= 0x000001ff; data->GroupIndex = (data->GroupIndex % 10000) & 0x000001ff; // by siuaa 080501 } END_LOG; } // --------------------------------------------------------------------------- /// data¿Í °°Àº ±×·ìÀÇ dataµéÀ» select¿¡ µû¶ó ¼±ÅÃ, ¼±ÅÃÇØÁ¦ÇÔ void __fastcall TVecDraw::ModifyGroup(TVecData *data, bool select) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *temp; for (int i = 0; i < DataList->Count; i++) { temp = (TVecData*)DataList->Items[i]; if (!temp->Equal(MainImageForm->Number)) continue; if (!temp->GroupIndex) continue; // if ((temp->GroupIndex & 0xfffffe00) == (data->GroupIndex & 0xfffffe00)) if (temp->GroupIndex / 10000 == data->GroupIndex / 10000) // by siuaa 080501 temp->bSelected = select; } END_LOG; } // --------------------------------------------------------------------------- /// Group ±â´ÉÀÌ GroupÀ¸·Î ÀÛ¿ëÇÒÁö UnGroupÀ¸·Î ÀÛ¿ëÇÒÁö ÆÇº° bool __fastcall TVecDraw::GroupUpdate() { TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) int index = 0; if (!(NVector->bSelected)) return false; BEGIN_LOG(""); for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; /* if (!(data->GroupIndex & 0xfffffe00)) return false; if (index && (~index & (data->GroupIndex & 0xfffffe00))) return false; index |= (data->GroupIndex & 0xfffffe00); */ if (data->GroupIndex / 10000 == 0) { END_LOG; return false; // by siuaa 080501 } } END_LOG; return true; } // --------------------------------------------------------------------------- /// ±×¸®´Â µµÁß - ù¹øÂ° ¶óÀÎÀÎÁö üũ bool __fastcall TVecDraw::CheckFirstLine() { TList *DataList = NULL; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) // ¸¶Áö¸· µ¥ÀÌÅͰ¡ ÇöÀç ±×·ÁÁö°í ÀÖ´Â µ¥ÀÌÅÍ DataList = NVector->DataList; if (0 < DataList->Count) data = (TVecData*)DataList->Last(); else return false; if (data->Color != PenManagerForm->PenShape->Pen->Color || data->bRound == PenManagerForm->Pen->Shape || // data->PenThick != PenManagerForm->Pen->Thick || data->PenThick != VectorForm->DrawingThick || // 2005 Vector Upgrade Shin 0315 (data->Kind != V_LINE && data->Kind != V_CURVE)) NVector->bFstLine = true; if (!data->Equal(MainImageForm->Number)) NVector->bFstLine = true; return NVector->bFstLine; } // --------------------------------------------------------------------------- /// number¹ø GroupÀÎ objectµéÀ» ¼±ÅýÃÅ´ void __fastcall TVecDraw::SelectGroup(int number) { TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; data->bSelected = false; // if (data->GroupIndex & (1<GroupIndex % 10000) & (1 << number)) { // by siuaa 080501 data->bSelected = true; NVector->bSelected = true; } } MainImageForm->iMainImage->Repaint(); } // --------------------------------------------------------------------------- /// ¼±ÅÃµÈ object¿¡ lock ¼³Á¤ void __fastcall TVecDraw::ObjectLock(bool unlock) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) bool sw = true; if (!unlock) { // lockÀ» °Å´Â °æ¿ì for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; UndoSave(VU_MODIFY, i, sw); sw = false; data->bLocked = true; data->bSelected = false; } NVector->bSelected = false; NVector->bLocked = true; } else { // lock À» ÇØÁ¦ÇÏ´Â °æ¿ì for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bLocked) continue; UndoSave(VU_MODIFY, i, sw); sw = false; data->bLocked = false; } NVector->bLocked = false; } END_LOG; } // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // ------- Merge Function Part ----------------------------------------- // --------------------------------------------------------------------------- /// data merge¸¦ À§ÇÑ À§Ä¡, ¿µ¿ª °è»ê void __fastcall TVecDraw::InitMerge(HANDLE fh, int width, bool mirror, bool bLib) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL, *childdata = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) RECT rect; if (NVector->bMergeMode) DeleteVectorObject(false); deSelect(); NVector->bMergeMode = true; NVector->bSelected = true; LoadFromFile(fh); PasteRange = Rect(50000, 50000, 0, 0); MaxThick = 0; if (bLib) { // Style Lib ¿¡¼­´Â º¤ÅÍ ¿ÀºêÁ§Æ®¸¸ÀÇ ¹üÀ§¸¦ ¼³Á¤ÇØ ÁÖ¾î¾ß ÇÑ´Ù for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->Kind == V_TEXTBOX) { MakeTextBoxPointList(data); GetRectForMouseMove(data, rect); PasteRange.left = min(PasteRange.left, rect.left); PasteRange.right = max(PasteRange.right, rect.right); PasteRange.top = min(PasteRange.top, rect.top); PasteRange.bottom = max(PasteRange.bottom, rect.bottom); } else { MaxThick = max(MaxThick, data->PenThick); PasteRange.left = min(PasteRange.left, min(data->First.x, data->Second.x)); PasteRange.right = max(PasteRange.right, max(data->First.x, data->Second.x)); PasteRange.top = min(PasteRange.top, min(data->First.y, data->Second.y)); PasteRange.bottom = max(PasteRange.bottom, max(data->First.y, data->Second.y)); } } for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; data->First.x -= PasteRange.left; data->Second.x -= PasteRange.left; data->First.y -= PasteRange.top; data->Second.y -= PasteRange.top; if (data->Kind == V_LINE || data->Kind == V_CURVE) for (int j = 0; j < data->nCount * 3 + 1; j++) { data->pList[j].x -= PasteRange.left; data->pList[j].y -= PasteRange.top; } if (data->Kind == V_TEXTBOX) { data->StartPoint.x -= PasteRange.left; data->StartPoint.y -= PasteRange.top; data->CenterPoint.x = (data->First.x + data->Second.x) / 2; data->CenterPoint.y = (data->First.y + data->Second.y) / 2; MakeTextBoxPointList(data); // todo: ij·ÔÀ» ó¸®Çϱâ À§Çؼ­ (¹Ú»óÈÆ) CenterPoint.x = data->CenterPoint.x; CenterPoint.y = data->CenterPoint.y; } // MotiveÀÇ °æ¿ì - by monkman(2009.04.02) if (data->bMotive && data->ChildList && data->ChildList->Count) { for (int j = 0; j < data->ChildList->Count; j++) { childdata = (TVecData*)data->ChildList->Items[j]; childdata->bSelected = true; } } } width = PasteRange.right - PasteRange.left; } if (mirror) { for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; int tempx = data->First.x; data->First.x = width - data->Second.x; data->Second.x = width - tempx; if (data->Kind == V_CURVE || data->Kind == V_LINE) for (int i = 0; i < data->nCount * 3 + 1; i++) data->pList[i].x = width - data->pList[i].x; /* if (data->Kind == V_TEXTBOX) { data->StartPoint.x = width - data->StartPoint.x; for (int j = 0; j < 5; j++) data->pList[j].x = width - data->pList[j].x; } */ } } END_LOG; } // --------------------------------------------------------------------------- /// data mergeµµÁß Áß´Ü void __fastcall TVecDraw::ExitMerge() { if (!(NVector->bMergeMode)) return; BEGIN_LOG(""); if (VectorForm && VectorForm->nMoveCopy == 1) { // º¤ÅÍ À̵¿±â´É »ç¿ëÁß Ãë¼ÒÇÏ´Â °æ¿ì UndoRead(); TPVectorUndo * Undo = (TPVectorUndo*)MainImageForm->VecUndo; Undo->RemoveLast(); } else { DeleteVectorObject(false); } deSelect(); NVector->bMergeMode = false; END_LOG; } // --------------------------------------------------------------------------- /// MergeÇÒ À§Ä¡ °è»ê RECT __fastcall TVecDraw::SetMergePosition(int &X, int &Y, RECT range, bool paint, bool isspray) { // paint°¡ falseÀÌ¸é ³¡ÀÌ´Ù TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) RECT returnRect = range; if (!(NVector->bMergeMode)) return returnRect; if (!DataList->Count) return returnRect; BEGIN_LOG(""); int width = range.right - range.left, height = range.bottom - range.top; int temp, oldMergeX = MergeX, oldMergeY = MergeY; if (bZKey && VectorForm && VectorForm->V_MainItem == 2) { //MoveCopy Mode MergeX = PasteObjRange.left + width / 2; //Àӽà »ç¿ë MergeY = PasteObjRange.top + height / 2; //Àӽà »ç¿ë if (abs(X-MergeX) > abs(Y-MergeY)) { //XÃà À̵¿ Y = PasteObjRange.top + height / 2; } else {//YÃà À̵¿ X = PasteObjRange.left + width / 2; } } MergeX = X - width / 2; MergeY = Y - height / 2; if (!isspray) { if (MergeX < 0) MergeX = 0; if (MergeY < 0) MergeY = 0; if (MergeX > (MainImageForm->iMainImage->uBitmap->Width - width)) MergeX = MainImageForm->iMainImage->uBitmap->Width - width; if (MergeY > (MainImageForm->iMainImage->uBitmap->Height - height)) MergeY = MainImageForm->iMainImage->uBitmap->Height - height; } if (!paint) { // Merge Mode ³¡³»±â for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; // -->by linuxjun for CurvedVectorText if (data->Kind == V_TEXTBOX) { if (data->ListOfAllLine->CurveData) continue; } // <--by linuxjun for CurvedVectorText data->First.x += MergeX; data->First.y += MergeY; data->Second.x += MergeX; data->Second.y += MergeY; if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int i = 0; i < data->nCount * 3 + 1; i++) { data->pList[i].x += MergeX; data->pList[i].y += MergeY; } } if (data->Kind == V_TEXTBOX) { data->StartPoint.x += MergeX; data->StartPoint.y += MergeY; data->CenterPoint.x = (data->First.x + data->Second.x) / 2; data->CenterPoint.y = (data->First.y + data->Second.y) / 2; MakeTextBoxPointList(data); // todo: ij·ÔÀ» ó¸®Çϱâ À§Çؼ­ (¹Ú»óÈÆ) CenterPoint.x = data->CenterPoint.x; CenterPoint.y = data->CenterPoint.y; } } NVector->bMergeMode = false; MergeX = 0; MergeY = 0; } else if (oldMergeX == 0 && oldMergeY == 0) { // Merge¸¦ Çϱâ Àü¿¡ MergeÇÒ object¸¦ Left, Top(0,0)À» ±âÁØÀ¸·Î °è»êÇØ¼­ °¡Áö°í Àִµ¥ // Repaint¸¦ ÇÒ ¶§ ±× ºÎºÐÀ» ±×·ÁÁÖ°í Merger°¡ ³¡³¯¶§±îÁö ±× ºÎºÐ¿¡ ¸¶¿ì½º¸¦ À§Ä¡ÇÏÁö ¾ÊÀ¸¸é // RepaintÇÏÁö ¾Ê¾Æ ÃʱâÈ­ ÈÄ¿¡ Repaint¸¦ Çϵµ·Ï Ãß°¡ÇÔ. TRect basePaint = TRect(0, 0, range.right - range.left, range.bottom - range.top); MainImageForm->iMainImage->RectPaint(basePaint); } // -->by linuxjun for CurvedVectorText // if(data->ParentTextBox) /* for (int i = 0; i < DataList->Count; i++) { data = (TVecData *)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; break; } */ // data=(TVecData *)DataList->Items[DataList->Count-1]; /* if(data->ListOfAllLine) { if(data->ListOfAllLine->CurveData) { // MakeTextBoxPointList(data->ParentTextBox); MakeTextBoxPointList(data); if (paint) { TSWordData * tsWordData; for(int i=0;iListOfAllLine->Count;i++) { tsWordData = (TSWordData *)data->ListOfAllLine->Items(i); tsWordData->px += MergeX;; tsWordData->py += MergeY;; } } } } */ for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->ParentTextBox) { MakeTextBoxPointList(data->ParentTextBox); // MakeTextBoxPointList(data); if (paint && !data->ParentTextBox->bSelected) { TSWordData * tsWordData; for (int i = 0; i < data->ParentTextBox->ListOfAllLine->Count; i++) { tsWordData = (TSWordData*)data->ParentTextBox->ListOfAllLine->Items (i); tsWordData->px += MergeX; ; tsWordData->py += MergeY; ; } } } int plusRange = data->PenThick + 100; if (data->ArrowCap){ plusRange = data->PenThick*data->ArrowCap->LineCapWidthScale*(data->ArrowCap->LineCapWidth + 1)/2; } temp = data->First.x + MergeX - plusRange; returnRect.left = returnRect.left < temp ? returnRect.left : temp; temp = data->First.y + MergeY - plusRange; returnRect.top = returnRect.top < temp ? returnRect.top : temp; temp = data->Second.x + MergeX + plusRange; returnRect.right = returnRect.right > temp ? returnRect.right : temp; temp = data->Second.y + MergeY + plusRange; returnRect.bottom = returnRect.bottom > temp ? returnRect.bottom : temp; } // <--by linuxjun for CurvedVectorText END_LOG; return returnRect; } // --------------------------------------------------------------------------- /// Clipboard º¹»ç (º¹»ç ¶Ç´Â À̵¿) void __fastcall TVecDraw::InitCopy(bool isCut) { if (BeReadyEdit) return; BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) TVecData *cdata = NULL, *childdata = NULL; int CopyCount = 0; int Allocatesize = 0; Byte *lpData; PasteRange = Rect(50000, 50000, 0, 0); TRect tempPasteRange = Rect(50000, 50000, 0, 0); MaxThick = 0; int linecount, count; RECT rect; int tfx, tfy, tsx, tsy; // º¤ÅÍ ¹öÀü Ãß°¡ - by monkman (2005.06.29) // ÆÄÀÏ µî¿¡¼­ »ç¿ëÇÏ´Â º¤ÅÍ ¹öÀü°ú µ¿ÀÏÇÏ°Ô Áõ°¡ // Version = 150 : 2005.06.29 // Version = 160 : 2008.04. textile 9.2 // Version = 170 : 2009.03 motiveÃß°¡ // Version = 180 : Unicode (TextBox) // Version = 181 : Arrow ¼öÁ¤ int Version = 181; HGLOBAL hMem = NULL; TPException ec = EC_NONE; // UINT VectorFormat = RegisterClipboardFormat("Vector"); for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; // -->by linuxjun for CurvedVectorText if (data->ParentTextBox) continue; // <--by linuxjun for CurvedVectorText CopyCount++; if (data->Kind == V_TEXTBOX) { MakeTextBoxPointList(data); GetRectForMouseMove(data, rect); PasteRange.left = min(PasteRange.left, rect.left); PasteRange.right = max(PasteRange.right, rect.right); PasteRange.top = min(PasteRange.top, rect.top); PasteRange.bottom = max(PasteRange.bottom, rect.bottom); } else { tfx = 55555; tfy = 55555; tsx = 0; tsy = 0; for (int i = 0; i < data->nCount * 3 + 1; i++) { if (data->pList == NULL) continue; if (tfx > data->pList[i].x) tfx = data->pList[i].x; if (tfy > data->pList[i].y) tfy = data->pList[i].y; if (tsx < data->pList[i].x) tsx = data->pList[i].x; if (tsy < data->pList[i].y) tsy = data->pList[i].y; } tempPasteRange.left = min(tempPasteRange.left, min(tfx, tsx) - (data->PenThick + 1) * 2); tempPasteRange.right = max(tempPasteRange.right, max(tfx, tsx) + (data->PenThick + 1) * 2); tempPasteRange.top = min(tempPasteRange.top, min(tfy, tsy) - (data->PenThick + 1) * 2); tempPasteRange.bottom = max(tempPasteRange.bottom, max(tfy, tsy) + (data->PenThick + 1) * 2); PasteRange.left = min(PasteRange.left, min(data->First.x, data->Second.x) - data->PenThick * 2); PasteRange.right = max(PasteRange.right, max(data->First.x, data->Second.x) + data->PenThick * 2); PasteRange.top = min(PasteRange.top, min(data->First.y, data->Second.y) - data->PenThick * 2); PasteRange.bottom = max(PasteRange.bottom, max(data->First.y, data->Second.y) + data->PenThick * 2); MaxThick = max(MaxThick, data->PenThick); } switch(data->Kind) { case V_LINE: case V_CURVE: Allocatesize += (sizeof(data->PenStyle)+sizeof(data->PenThick)+sizeof (data->nCount)+sizeof(data->bRound)+sizeof(data->bFill)+sizeof (data->bWinding)+sizeof(data->bAntialiasing)+sizeof(data->Color) +sizeof(data->Brush)+sizeof(data->bClosed)+sizeof(data->GroupIndex) +sizeof(DPOINT) * (data->nCount * 3 + 1))+sizeof(data->bPatternFill); // bAntialiasing Ãß°¡, penthick double·Î ¹Ù²Þ Shin if (data->bPatternFill) { Allocatesize += sizeof(data->PatternAngle)+sizeof(data->PatternAdjustX) +sizeof(data->PatternAdjustY)+sizeof(data->RatioX)+sizeof (data->RatioY)+sizeof(data->TBitmapSource->Width)+sizeof (data->TBitmapSource->Height)+sizeof(Byte) * (data->TBitmapSource->Width * data->TBitmapSource->Height * 3); } Allocatesize += sizeof(data->DashValues)+sizeof(data->CapStyle[0])+sizeof(data->CapStyle[1]); if (data->CapStyle[0] && data->ArrowCap){ Allocatesize += data->ArrowCap->GetClipboardSize(); // Allocatesize += sizeof(data->ArrowCap->bFillLineCap); // Allocatesize += sizeof(data->ArrowCap->bShowArrowBoth); // Allocatesize += sizeof(data->ArrowCap->LineCapWidthScale); // Allocatesize += sizeof(data->ArrowCap->LineCapWidth); // Allocatesize += sizeof(data->ArrowCap->LineCapHeight); } // DashValues Ãß°¡, CapStyle (Begin & End) Allocatesize += sizeof(data->bGradientFill); // shin gradientfill if (data->bGradientFill) { Allocatesize += sizeof(data->gradientItem)+sizeof(data->gAngle)+sizeof (data->gradientColorCount)+sizeof(data->gradientColors) * (data->gradientColorCount); } Allocatesize += sizeof(data->bMotive); // embakum motive 090317 if (data->bMotive) { Allocatesize += sizeof(data->ChildCount)+sizeof(data->mode)+sizeof (data->gap)+sizeof(data->motivecount)+sizeof(data->proportion) +sizeof(data->childwidth)+sizeof(data->childheight)+sizeof (data->centerX)+sizeof(data->centerY); for (int i = 0; i < data->ChildCount; i++) { TVecData *child = (TVecData*)data->ChildList->Items[i]; Allocatesize += ChildAllocate(child); } } break; case V_TEXT: Allocatesize += (sizeof(LOGFONT)+sizeof(int)+sizeof(TColor)+sizeof(Char) * data->nCount)+sizeof(bool); // bAntialiasing Ãß°¡ break; case V_TEXTBOX: Allocatesize += sizeof(data->CharH)+sizeof(data->CharW)+sizeof (data->TextAngle)+sizeof(data->bAntialiasing)+sizeof (data->StartPoint)+sizeof(data->CenterPoint); Allocatesize += sizeof(data->ListOfAllLine->LineCount)+sizeof (data->bAntialiasing); // data->ListOfAllLine->LineCountÀ» ÀúÀåÇØ¾ß Çϱ⠶§¹®¿¡ // bAntialiasing Ãß°¡ Allocatesize += sizeof(data->GroupIndex); // TextBoxµµ GroupIndex Ãß°¡ for (int j = 0; j < data->ListOfAllLine->LineCount; j++) { count = data->ListOfAllLine->GetLineTextBox(j)->LineDataList->Count; Allocatesize += sizeof(int); // count¸¦ ÀúÀåÇØ¾ß Çϱ⠶§¹®¿¡ for (int k = 0; k < count; k++) Allocatesize += sizeof(TSWordData); Allocatesize += sizeof(int); } Allocatesize += (sizeof(DPOINT) * 5); break; } } if (CopyCount == 0) { END_LOG; return; } PasteObjRange = PasteRange; //ZŰ·Î ¼öÁ÷/¼öÆò À̵¿/º¹»ç¿¡ »ç¿ë // Allocatesize += (CopyCount*(sizeof(int) + sizeof(EVecKind) + sizeof(EDataCode) + 2*sizeof(POINT))); // À§ÀÇ ÄÚµåó·³ ¸¹ÀÌ Àâ¾ÆÁÙ Çʿ䰡 ¾ø´Ù, // ±âÁ¸ º¤ÅÍ µ¥ÀÌÅÍÀÇ Å©±â¿¡ ¿ÀºêÁ§Æ® Àüü °³¼ö, µ¥ÀÌÅÍ ÄÚµå, ¹öÀü Á¤µµ¸¸ Ãß°¡ÀûÀ¸·Î Àâ¾ÆÁÖ¸é µÈ´Ù - by monkman (2005.07.05) Allocatesize += (sizeof(CopyCount)+sizeof(Version)+sizeof(EDataCode) + CopyCount * (sizeof(EVecKind) + 2 * sizeof(POINT))); hMem = GlobalAlloc(GHND, Allocatesize); lpData = (Byte*)GlobalLock(hMem); memcpy(lpData, &CopyCount, sizeof(int)); lpData += sizeof(int); memcpy(lpData, &DataCode, sizeof(EDataCode)); lpData += sizeof(EDataCode); // º¤ÅÍ ¹öÀü Ãß°¡ - by monkman (2005.06.29) memcpy(lpData, &Version, sizeof(Version)); lpData += sizeof(Version); for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; // -->by linuxjun for CurvedVectorText if (data->ParentTextBox) continue; // <--by linuxjun for CurvedVectorText cdata = new TVecData(MainImageForm->Number); cdata->Copy(data); cdata->First.x -= PasteRange.left; cdata->Second.x -= PasteRange.left; cdata->First.y -= PasteRange.top; cdata->Second.y -= PasteRange.top; // cdata->GroupIndex = 0; // GroupIndex´Â copy¾ÈµÇ°Ô.. => copyµÇµµ·Ï Çϱâ À§ÇØ ÁÖ¼®Ã³¸®ÇÔ. if (cdata->Kind == V_LINE || cdata->Kind == V_CURVE) { for (int j = 0; j < cdata->nCount * 3 + 1; j++) { if (cdata->bMotive) { cdata->pList[j].x -= tempPasteRange.left; cdata->pList[j].y -= tempPasteRange.top; } else { cdata->pList[j].x -= PasteRange.left; cdata->pList[j].y -= PasteRange.top; } } } if (cdata->Kind == V_TEXTBOX) { cdata->StartPoint.x -= PasteRange.left; cdata->StartPoint.y -= PasteRange.top; cdata->CenterPoint.x = (cdata->First.x + cdata->Second.x) / 2; cdata->CenterPoint.y = (cdata->First.y + cdata->Second.y) / 2; MakeTextBoxPointList(cdata); // todo: ij·ÔÀ» ó¸®Çϱâ À§Çؼ­ (¹Ú»óÈÆ) CenterPoint.x = data->CenterPoint.x; CenterPoint.y = data->CenterPoint.y; /* for (int k = 0; k < 5; k++) { cdata->pList[k].x -= PasteRange.left; cdata->pList[k].y -= PasteRange.top; } */ } memcpy(lpData, &cdata->Kind, sizeof(EVecKind)); lpData += sizeof(EVecKind); memcpy(lpData, &cdata->First, sizeof(POINT)); lpData += sizeof(POINT); memcpy(lpData, &cdata->Second, sizeof(POINT)); lpData += sizeof(POINT); switch(cdata->Kind) { case V_LINE: case V_CURVE: *(EPenStyle*)lpData = cdata->PenStyle; lpData += sizeof(EPenStyle); *(double*)lpData = cdata->PenThick; // int -> double 2005 Vector Upgrade 0316 lpData += sizeof(double); *(int*)lpData = cdata->nCount; lpData += sizeof(int); *(bool*)lpData = cdata->bRound; lpData += sizeof(bool); *(bool*)lpData = cdata->bFill; lpData += sizeof(bool); *(bool*)lpData = cdata->bWinding; lpData += sizeof(bool); *(bool*)lpData = cdata->bAntialiasing; // 2005 Vector Upgrade 0316 lpData += sizeof(bool); *(TColor*)lpData = cdata->Color; lpData += sizeof(TColor); *(TColor*)lpData = cdata->Brush; lpData += sizeof(TColor); *(bool*)lpData = cdata->bClosed; lpData += sizeof(bool); *(int*)lpData = cdata->GroupIndex; lpData += sizeof(int); memcpy(lpData, cdata->pList, sizeof(DPOINT) * (cdata->nCount * 3 + 1)); lpData += (sizeof(DPOINT) * (cdata->nCount * 3 + 1)); *(bool*)lpData = cdata->bPatternFill; lpData += sizeof(bool); if (cdata->bPatternFill) { Byte *byte; *(int*)lpData = cdata->PatternAngle; lpData += sizeof(int); *(int*)lpData = cdata->PatternAdjustX; lpData += sizeof(int); *(int*)lpData = cdata->PatternAdjustY; lpData += sizeof(int); *(int*)lpData = cdata->RatioX; lpData += sizeof(int); *(int*)lpData = cdata->RatioY; lpData += sizeof(int); *(int*)lpData = cdata->TBitmapSource->Width; lpData += sizeof(int); *(int*)lpData = cdata->TBitmapSource->Height; lpData += sizeof(int); cdata->TBitmapSource->StartScanLine(); for (int k = 0; k < cdata->TBitmapSource->Height; k++) { byte = cdata->TBitmapSource->GetScanLine(k); memcpy(lpData, byte, sizeof(Byte) * cdata->TBitmapSource->Width * 3); lpData += (sizeof(Byte) * cdata->TBitmapSource->Width * 3); } cdata->TBitmapSource->StopScanLine(); } memcpy(lpData, cdata->DashValues, sizeof(double) * 7); // DashValues Ãß°¡ lpData += sizeof(double) * 7; *(int*)lpData = cdata->CapStyle[0]; lpData += sizeof(int); *(int*)lpData = cdata->CapStyle[1]; lpData += sizeof(int); if (cdata->CapStyle[0] && cdata->ArrowCap){ cdata->ArrowCap->SaveClipboard(lpData); lpData += data->ArrowCap->GetClipboardSize(); // *(bool*)lpData = cdata->ArrowCap->bFillLineCap; // lpData += sizeof(bool); // *(bool*)lpData = cdata->ArrowCap->bShowArrowBoth; // lpData += sizeof(bool); // *(double*)lpData = cdata->ArrowCap->LineCapWidthScale; // lpData += sizeof(double); // *(double*)lpData = cdata->ArrowCap->LineCapWidth; // lpData += sizeof(double); // *(double*)lpData = cdata->ArrowCap->LineCapHeight; // lpData += sizeof(double); } *(bool*)lpData = cdata->bGradientFill; // GradientFill Ãß°¡ lpData += sizeof(bool); if (cdata->bGradientFill) { *(int*)lpData = cdata->gradientItem; lpData += sizeof(int); *(int*)lpData = cdata->gAngle; lpData += sizeof(int); *(int*)lpData = cdata->gradientColorCount; lpData += sizeof(int); memcpy(lpData, cdata->gradientColors, sizeof(RGBQUAD) * (cdata->gradientColorCount)); // GradientFill Ãß°¡ lpData += sizeof(RGBQUAD) * (cdata->gradientColorCount); } *(bool*)lpData = cdata->bMotive; // embakum Motive 090317 lpData += sizeof(bool); if (cdata->bMotive) { *(int*)lpData = cdata->ChildCount; lpData += sizeof(int); *(int*)lpData = cdata->mode; lpData += sizeof(int); *(double*)lpData = cdata->gap; lpData += sizeof(double); *(int*)lpData = cdata->motivecount; lpData += sizeof(int); *(double*)lpData = cdata->proportion; lpData += sizeof(double); *(double*)lpData = cdata->childwidth; lpData += sizeof(double); *(double*)lpData = cdata->childheight; lpData += sizeof(double); *(double*)lpData = cdata->centerX; lpData += sizeof(double); *(double*)lpData = cdata->centerY; lpData += sizeof(double); for (int i = 0; i < cdata->ChildCount; i++) { childdata = new TVecData(MainImageForm->Number); childdata->Copy((TVecData*)cdata->ChildList->Items[i]); memcpy(lpData, &childdata->Kind, sizeof(EVecKind)); lpData += sizeof(EVecKind); memcpy(lpData, &childdata->First, sizeof(POINT)); lpData += sizeof(POINT); memcpy(lpData, &childdata->Second, sizeof(POINT)); lpData += sizeof(POINT); switch(childdata->Kind) { case V_LINE: case V_CURVE: *(EPenStyle*)lpData = childdata->PenStyle; lpData += sizeof(EPenStyle); *(double*)lpData = childdata->PenThick; // 2005 Vector upgrade 20050225 lpData += sizeof(double); *(int*)lpData = childdata->nCount; lpData += sizeof(int); *(bool*)lpData = childdata->bRound; lpData += sizeof(bool); *(bool*)lpData = childdata->bFill; lpData += sizeof(bool); *(bool*)lpData = childdata->bWinding; lpData += sizeof(bool); *(bool*)lpData = childdata->bAntialiasing; // 20050222 shin lpData += sizeof(bool); *(TColor*)lpData = childdata->Color; lpData += sizeof(TColor); *(TColor*)lpData = childdata->Brush; lpData += sizeof(TColor); *(bool*)lpData = childdata->bClosed; lpData += sizeof(bool); *(int*)lpData = childdata->GroupIndex; lpData += sizeof(int); memcpy(lpData, childdata->pList, sizeof(DPOINT) * (childdata->nCount * 3 + 1)); lpData += (sizeof(DPOINT) * (childdata->nCount * 3 + 1)); *(bool*)lpData = childdata->bPatternFill; lpData += sizeof(bool); if (childdata->bPatternFill) { Byte *byte; *(int*)lpData = childdata->PatternAngle; lpData += sizeof(int); *(int*)lpData = childdata->PatternAdjustX; lpData += sizeof(int); *(int*)lpData = childdata->PatternAdjustY; lpData += sizeof(int); *(int*)lpData = childdata->RatioX; lpData += sizeof(int); *(int*)lpData = childdata->RatioY; lpData += sizeof(int); *(int*)lpData = childdata->TBitmapSource->Width; lpData += sizeof(int); *(int*)lpData = childdata->TBitmapSource->Height; lpData += sizeof(int); childdata->TBitmapSource->StartScanLine(); for (int k = 0; k < childdata->TBitmapSource->Height; k++) { byte = childdata->TBitmapSource->GetScanLine(k); memcpy(lpData, byte, sizeof(Byte) * childdata->TBitmapSource->Width * 3); lpData += (sizeof(Byte) * childdata->TBitmapSource->Width * 3); } childdata->TBitmapSource->StopScanLine(); } memcpy(lpData, childdata->DashValues, sizeof(double) * 7); // DashValues Ãß°¡ lpData += sizeof(double) * 7; *(int*)lpData = childdata->CapStyle[0]; lpData += sizeof(int); *(int*)lpData = childdata->CapStyle[1]; lpData += sizeof(int); if (childdata->CapStyle[0] && childdata->ArrowCap){ childdata->ArrowCap->SaveClipboard(lpData); lpData += childdata->ArrowCap->GetClipboardSize(); // *(bool*)lpData = childdata->ArrowCap->bFillLineCap; // lpData += sizeof(bool); // *(bool*)lpData = childdata->ArrowCap->bShowArrowBoth; // lpData += sizeof(bool); // *(double*)lpData = childdata->ArrowCap->LineCapWidthScale; // lpData += sizeof(double); // *(double*)lpData = childdata->ArrowCap->LineCapWidth; // lpData += sizeof(double); // *(double*)lpData = childdata->ArrowCap->LineCapHeight; // lpData += sizeof(double); } *(bool*)lpData = childdata->bGradientFill; // shin GradientFill Ãß°¡ 080514 lpData += sizeof(bool); if (childdata->bGradientFill) { *(int*)lpData = childdata->gradientItem; lpData += sizeof(int); *(int*)lpData = childdata->gAngle; lpData += sizeof(int); *(int*)lpData = childdata->gradientColorCount; lpData += sizeof(int); memcpy(lpData, childdata->gradientColors, sizeof(RGBQUAD) * (childdata->gradientColorCount)); // GradientFill Ãß°¡ lpData += sizeof(RGBQUAD) * (childdata->gradientColorCount); } *(bool*)lpData = childdata->bMotive; // embakum Motive 090317 lpData += sizeof(bool); if (childdata->bMotive) { *(int*)lpData = childdata->ChildCount; lpData += sizeof(int); *(int*)lpData = childdata->mode; lpData += sizeof(int); *(double*)lpData = childdata->gap; lpData += sizeof(double); *(int*)lpData = childdata->motivecount; lpData += sizeof(int); *(double*)lpData = childdata->proportion; lpData += sizeof(double); *(double*)lpData = childdata->childwidth; lpData += sizeof(double); *(double*)lpData = childdata->childheight; lpData += sizeof(double); *(double*)lpData = childdata->centerX; lpData += sizeof(double); *(double*)lpData = childdata->centerY; lpData += sizeof(double); } break; case V_TEXT: *(bool*)lpData = childdata->bAntialiasing; // 20050222 shin lpData += sizeof(bool); *(TColor*)lpData = childdata->Color; lpData += sizeof(TColor); *(LOGFONT*)lpData = childdata->Font; lpData += sizeof(LOGFONT); *(int*)lpData = childdata->nCount; lpData += sizeof(int); memcpy(lpData, childdata->TextString.c_str(), sizeof(Char) * childdata->nCount); lpData += (sizeof(Char) * childdata->nCount); break; case V_TEXTBOX: *(bool*)lpData = childdata->bAntialiasing; // 20050222 shin lpData += sizeof(bool); *(int*)lpData = childdata->CharH; // ±ÛÀÚÀÇ Å©±â lpData += sizeof(int); *(int*)lpData = childdata->CharW; lpData += sizeof(int); *(double*)lpData = childdata->TextAngle; // TextBoxÀÇ Angle·Î »ç¿ëµÊ lpData += sizeof(double); memcpy(lpData, &childdata->StartPoint, sizeof(POINT)); // ù±ÛÀÚ°¡ ÀÖ´Â À§Ä¡ lpData += sizeof(POINT); memcpy(lpData, &childdata->CenterPoint, sizeof(POINT)); // BoxÀÇ ¹«°ÔÁß½ÉÁ¡ lpData += sizeof(POINT); TSWordData *srcWordData; // °¢°¢ÀÇ ¶óÀÎÀ» ÀúÀåÇϰí ÀÖ´Â ºÎºÐÀ» Copy linecount = childdata->ListOfAllLine->LineCount; *(int*)lpData = linecount; // childdata->ListOfAllLine->LineCountÀúÀå lpData += sizeof(int); for (int i = 0; i < linecount; i++) { count = childdata->ListOfAllLine->GetLineTextBox(i) ->LineDataList->Count; *(int*)lpData = count; // count ÀúÀå lpData += sizeof(int); for (int j = 0; j < count; j++) { srcWordData = (TSWordData*) childdata->ListOfAllLine->GetLineTextBox(i) ->LineDataList->Items[j]; *(bool*)lpData = false; // ¹«Á¶°Ç ¼±ÅÃÇÏÁö ¾ÊÀº »óÅ·Π¸¸µç´Ù. lpData += sizeof(bool); *(bool*)lpData = srcWordData->bNameChanged; // 20050222 shin lpData += sizeof(bool); memcpy(lpData, &srcWordData->PPoint, sizeof(POINT)); // ù±ÛÀÚ°¡ ÀÖ´Â À§Ä¡ lpData += sizeof(POINT); *(LOGFONT*)lpData = srcWordData->LFont; lpData += sizeof(LOGFONT); memcpy(lpData, srcWordData->Word, sizeof(Char) * 2); lpData += (sizeof(Char) * 2); *(int*)lpData = srcWordData->UsedByte; lpData += sizeof(int); *(TColor*)lpData = srcWordData->Color; lpData += sizeof(TColor); *(int*)lpData = srcWordData->Interval; lpData += sizeof(int); *(float*)lpData = srcWordData->WidthGap; // º¯°æµÉ ±ÛÀÚ°£°Ý % lpData += sizeof(float); *(float*)lpData = srcWordData->HeightGap; // º¯°æµÉ ÁÙ°£°Ý % lpData += sizeof(float); } *(int*)lpData = childdata->ListOfAllLine->GetLineTextBox(i) ->lineHeight; // lineHeight ÀúÀå lpData += sizeof(int); } memcpy(lpData, childdata->pList, sizeof(DPOINT) * 5); lpData += (sizeof(DPOINT) * 5); *(int*)lpData = childdata->nCount; lpData += sizeof(int); break; } delete childdata; } } break; case V_TEXT: *(TColor*)lpData = cdata->Color; lpData += sizeof(TColor); *(LOGFONT*)lpData = cdata->Font; lpData += sizeof(LOGFONT); *(int*)lpData = cdata->nCount; lpData += sizeof(int); *(bool*)lpData = cdata->bAntialiasing; // 2005 Vector Upgrade 0316 lpData += sizeof(bool); /* *(int *)lpData = cdata->top; lpData += sizeof(int); *(int *)lpData = cdata->bottom; lpData += sizeof(int); */ memcpy(lpData, cdata->TextString.c_str(), sizeof(Char) * cdata->nCount); lpData += (sizeof(Char) * cdata->nCount); break; case V_TEXTBOX: *(int*)lpData = cdata->CharH; // ±ÛÀÚÀÇ Å©±â lpData += sizeof(int); *(int*)lpData = cdata->CharW; lpData += sizeof(int); *(double*)lpData = cdata->TextAngle; // TextBoxÀÇ Angle·Î »ç¿ëµÊ lpData += sizeof(double); *(bool*)lpData = cdata->bAntialiasing; // 2005 Vector Upgrade 0316 lpData += sizeof(bool); memcpy(lpData, &cdata->StartPoint, sizeof(POINT)); // ù±ÛÀÚ°¡ ÀÖ´Â À§Ä¡ lpData += sizeof(POINT); memcpy(lpData, &cdata->CenterPoint, sizeof(POINT)); // BoxÀÇ ¹«°ÔÁß½ÉÁ¡ lpData += sizeof(POINT); *(int*)lpData = cdata->GroupIndex; // GroupIndex lpData += sizeof(int); TSWordData *srcWordData; // °¢°¢ÀÇ ¶óÀÎÀ» ÀúÀåÇϰí ÀÖ´Â ºÎºÐÀ» Copy linecount = cdata->ListOfAllLine->LineCount; *(int*)lpData = linecount; // cdata->ListOfAllLine->LineCountÀúÀå lpData += sizeof(int); for (int i = 0; i < linecount; i++) { count = cdata->ListOfAllLine->GetLineTextBox(i)->LineDataList->Count; *(int*)lpData = count; // count ÀúÀå lpData += sizeof(int); for (int j = 0; j < count; j++) { srcWordData = (TSWordData*)cdata->ListOfAllLine->GetLineTextBox(i) ->LineDataList->Items[j]; // *(bool *)lpData = srcWordData->Selected; *(bool*)lpData = false; // ¸ðµÎ false·Î ÇØµµ µÈ´Ù. lpData += sizeof(bool); *(bool*)lpData = srcWordData->bNameChanged; // 2005 Vector Upgrade 0316 lpData += sizeof(bool); memcpy(lpData, &srcWordData->PPoint, sizeof(POINT)); // ù±ÛÀÚ°¡ ÀÖ´Â À§Ä¡ lpData += sizeof(POINT); *(LOGFONT*)lpData = srcWordData->LFont; lpData += sizeof(LOGFONT); memcpy(lpData, srcWordData->Word, sizeof(Char) * 2); lpData += (sizeof(Char) * 2); *(int*)lpData = srcWordData->UsedByte; lpData += sizeof(int); *(TColor*)lpData = srcWordData->Color; lpData += sizeof(TColor); *(int*)lpData = srcWordData->Interval; lpData += sizeof(int); *(float*)lpData = srcWordData->WidthGap; // º¯°æµÉ ±ÛÀÚ°£°Ý % lpData += sizeof(float); *(float*)lpData = srcWordData->HeightGap; // º¯°æµÉ ÁÙ°£°Ý % lpData += sizeof(float); } *(int*)lpData = cdata->ListOfAllLine->GetLineTextBox(i)->lineHeight; // lineHeight ÀúÀå lpData += sizeof(int); } memcpy(lpData, cdata->pList, sizeof(DPOINT) * 5); lpData += (sizeof(DPOINT) * 5); *(int*)lpData = cdata->nCount; lpData += sizeof(int); break; } // delete cdata->pList; // cdata->pList = NULL; delete cdata; cdata = NULL; } GlobalUnlock(hMem); OpenClipboard(MainImageForm->Handle); // Bitmap Ŭ¸³º¸µå±îÁö ºñ¿ö¹ö¸®±â ¶§¹®¿¡ ÀÏ´Ü ÁÖ¼® ó¸® - by monkman (2004.09.02) // EmptyClipboard(); SetClipboardData(CF_SYLK, hMem); // SetClipboardData(VectorFormat, hMem); CloseClipboard(); if (isCut) DeleteVectorObject(); END_LOG; } // --------------------------------------------------------------------------- int __fastcall TVecDraw::ChildAllocate(TVecData *child) { BEGIN_LOG(""); int count; int memorysize = 0; memorysize += (sizeof(EVecKind) + 2 * sizeof(POINT)); switch(child->Kind) { case V_LINE: case V_CURVE: memorysize += (sizeof(child->PenStyle)+sizeof(child->PenThick)+sizeof (child->nCount)+sizeof(child->bRound)+sizeof(child->bFill)+sizeof (child->bWinding)+sizeof(child->bAntialiasing)+sizeof(child->Color) +sizeof(child->Brush)+sizeof(child->bClosed)+sizeof(child->GroupIndex) +sizeof(DPOINT) * (child->nCount * 3 + 1))+sizeof(child->bPatternFill); // bAntialiasing Ãß°¡, penthick double·Î ¹Ù²Þ Shin if (child->bPatternFill) { memorysize += sizeof(child->PatternAngle)+sizeof(child->PatternAdjustX) +sizeof(child->PatternAdjustY)+sizeof(child->RatioX)+sizeof (child->RatioY)+sizeof(child->TBitmapSource->Width)+sizeof (child->TBitmapSource->Height)+sizeof(Byte) * (child->TBitmapSource->Width * child->TBitmapSource->Height * 3); } memorysize += sizeof(child->DashValues)+sizeof(child->CapStyle[0])+sizeof(child->CapStyle[1]); if (child->CapStyle[0] && child->ArrowCap){ memorysize += child->ArrowCap->GetClipboardSize(); // memorysize += sizeof(child->ArrowCap->bFillLineCap); // memorysize += sizeof(child->ArrowCap->bShowArrowBoth); // memorysize += sizeof(child->ArrowCap->LineCapWidthScale); // memorysize += sizeof(child->ArrowCap->LineCapWidth); // memorysize += sizeof(child->ArrowCap->LineCapHeight); } // DashValues Ãß°¡, CapStyle (Begin & End) memorysize += sizeof(child->bGradientFill); // shin gradientfill 080514 if (child->bGradientFill) { memorysize += sizeof(child->gradientItem)+sizeof(child->gAngle)+sizeof (child->gradientColorCount)+sizeof(child->gradientColors) * (child->gradientColorCount); } memorysize += sizeof(child->bMotive); // embakum motive 090317 if (child->bMotive) { memorysize += sizeof(child->ChildCount)+sizeof(child->mode)+sizeof (child->gap)+sizeof(child->motivecount)+sizeof(child->proportion) +sizeof(child->childwidth)+sizeof(child->childheight)+sizeof (child->centerX)+sizeof(child->centerY); } break; case V_TEXT: memorysize += (sizeof(LOGFONT)+sizeof(int)+sizeof(TColor)+sizeof(Char) * child->nCount); memorysize += sizeof(bool); // bAntialiasing Ãß°¡ 20050222 shin break; case V_TEXTBOX: memorysize += sizeof(child->CharH)+sizeof(child->CharW)+sizeof (child->TextAngle)+sizeof(child->bAntialiasing)+sizeof (child->StartPoint)+sizeof(child->CenterPoint); memorysize += sizeof(child->ListOfAllLine->LineCount)+sizeof (child->bAntialiasing); // child->ListOfAllLine->LineCountÀ» ÀúÀåÇØ¾ß Çϱ⠶§¹®¿¡ // bAntialiasing Ãß°¡ for (int j = 0; j < child->ListOfAllLine->LineCount; j++) { count = child->ListOfAllLine->GetLineTextBox(j)->LineDataList->Count; memorysize += sizeof(int); // count¸¦ ÀúÀåÇØ¾ß Çϱ⠶§¹®¿¡ for (int k = 0; k < count; k++) memorysize += sizeof(TSWordData); memorysize += sizeof(int); } memorysize += (sizeof(DPOINT) * 5); break; } END_LOG; return memorysize; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::InitCopyChild(bool isCut, TList *VecList) { BEGIN_LOG(""); TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) TVecData *cdata = NULL; int CopyCount = 0; int Allocatesize = 0; Byte *lpData; PasteRange = Rect(50000, 50000, 0, 0); MaxThick = 0; int linecount, count; RECT rect; // º¤ÅÍ ¹öÀü Ãß°¡ - by monkman (2005.06.29) // ÆÄÀÏ µî¿¡¼­ »ç¿ëÇÏ´Â º¤ÅÍ ¹öÀü°ú µ¿ÀÏÇÏ°Ô Áõ°¡ // Version = 150 : 2005.06.29 // Version = 160 : 2008.05.08 // Version = 170 : 2009.03.20 int Version = 170; HGLOBAL hMem = NULL; TPException ec = EC_NONE; // UINT VectorFormat = RegisterClipboardFormat("Vector"); for (int i = 0; i < VecList->Count; i++) { data = (TVecData*)VecList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; // -->by linuxjun for CurvedVectorText if (data->ParentTextBox) continue; // <--by linuxjun for CurvedVectorText CopyCount++; if (data->Kind == V_TEXTBOX) { MakeTextBoxPointList(data); GetRectForMouseMove(data, rect); PasteRange.left = min(PasteRange.left, rect.left); PasteRange.right = max(PasteRange.right, rect.right); PasteRange.top = min(PasteRange.top, rect.top); PasteRange.bottom = max(PasteRange.bottom, rect.bottom); } else { PasteRange.left = min(PasteRange.left, min(data->First.x, data->Second.x) - (data->PenThick + 1) * 2); PasteRange.right = max(PasteRange.right, max(data->First.x, data->Second.x) + (data->PenThick + 1) * 2); PasteRange.top = min(PasteRange.top, min(data->First.y, data->Second.y) - (data->PenThick + 1) * 2); PasteRange.bottom = max(PasteRange.bottom, max(data->First.y, data->Second.y) + (data->PenThick + 1) * 2); MaxThick = max(MaxThick, data->PenThick); } // bAntialiasing Ãß°¡ 20050222 shin switch(data->Kind) { case V_LINE: case V_CURVE: Allocatesize += (sizeof(data->PenStyle)+sizeof(data->PenThick)+sizeof (data->nCount)+sizeof(data->bRound)+sizeof(data->bFill)+sizeof (data->bWinding)+sizeof(data->bAntialiasing)+sizeof(data->Color) +sizeof(data->Brush)+sizeof(data->bClosed)+sizeof(data->GroupIndex) +sizeof(DPOINT) * (data->nCount * 3 + 1))+sizeof(data->bPatternFill); // bAntialiasing Ãß°¡, penthick double·Î ¹Ù²Þ Shin if (data->bPatternFill) { Allocatesize += sizeof(data->PatternAngle)+sizeof(data->PatternAdjustX) +sizeof(data->PatternAdjustY)+sizeof(data->RatioX)+sizeof (data->RatioY)+sizeof(data->TBitmapSource->Width)+sizeof (data->TBitmapSource->Height)+sizeof(Byte) * (data->TBitmapSource->Width * data->TBitmapSource->Height * 3); } Allocatesize += sizeof(data->DashValues)+sizeof(data->CapStyle[0])+sizeof(data->CapStyle[1]); if (data->CapStyle[0] && data->ArrowCap){ Allocatesize += data->ArrowCap->GetClipboardSize(); // Allocatesize += sizeof(data->ArrowCap->bFillLineCap); // Allocatesize += sizeof(data->ArrowCap->bShowArrowBoth); // Allocatesize += sizeof(data->ArrowCap->LineCapWidthScale); // Allocatesize += sizeof(data->ArrowCap->LineCapWidth); // Allocatesize += sizeof(data->ArrowCap->LineCapHeight); } // DashValues Ãß°¡, CapStyle (Begin & End) Allocatesize += sizeof(data->bGradientFill); // shin gradientfill 080514 if (data->bGradientFill) { Allocatesize += sizeof(data->gradientItem)+sizeof(data->gAngle)+sizeof (data->gradientColorCount)+sizeof(data->gradientColors) * (data->gradientColorCount); } Allocatesize += sizeof(data->bMotive); // embakum motive 090317 if (data->bMotive) { Allocatesize += sizeof(data->ChildCount)+sizeof(data->mode)+sizeof (data->gap)+sizeof(data->motivecount)+sizeof(data->proportion) +sizeof(data->childwidth)+sizeof(data->childheight)+sizeof (data->centerX)+sizeof(data->centerY); } break; case V_TEXT: Allocatesize += (sizeof(LOGFONT)+sizeof(int)+sizeof(TColor)+sizeof(Char) * data->nCount); Allocatesize += sizeof(bool); // bAntialiasing Ãß°¡ 20050222 shin break; case V_TEXTBOX: Allocatesize += sizeof(data->CharH)+sizeof(data->CharW)+sizeof (data->TextAngle)+sizeof(data->bAntialiasing)+sizeof (data->StartPoint)+sizeof(data->CenterPoint); Allocatesize += sizeof(data->ListOfAllLine->LineCount)+sizeof (data->bAntialiasing); // data->ListOfAllLine->LineCountÀ» ÀúÀåÇØ¾ß Çϱ⠶§¹®¿¡ // bAntialiasing Ãß°¡ for (int j = 0; j < data->ListOfAllLine->LineCount; j++) { count = data->ListOfAllLine->GetLineTextBox(j)->LineDataList->Count; Allocatesize += sizeof(int); // count¸¦ ÀúÀåÇØ¾ß Çϱ⠶§¹®¿¡ for (int k = 0; k < count; k++) Allocatesize += sizeof(TSWordData); Allocatesize += sizeof(int); } Allocatesize += (sizeof(DPOINT) * 5); break; } } if (CopyCount == 0) { END_LOG; return; } hMem = GlobalAlloc(GHND, Allocatesize); lpData = (Byte*)GlobalLock(hMem); for (int i = 0; i < VecList->Count; i++) { data = (TVecData*)VecList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; // -->by linuxjun for CurvedVectorText if (data->ParentTextBox) continue; // <--by linuxjun for CurvedVectorText cdata = new TVecData(MainImageForm->Number); cdata->Copy(data); cdata->First.x -= PasteRange.left; cdata->Second.x -= PasteRange.left; cdata->First.y -= PasteRange.top; cdata->Second.y -= PasteRange.top; // cdata->GroupIndex = 0; // GroupIndex´Â copy¾ÈµÇ°Ô.. => copyµÇµµ·Ï Çϱâ À§ÇØ ÁÖ¼®Ã³¸®ÇÔ. if (cdata->Kind == V_LINE || cdata->Kind == V_CURVE) { for (int j = 0; j < cdata->nCount * 3 + 1; j++) { cdata->pList[j].x -= PasteRange.left; cdata->pList[j].y -= PasteRange.top; } } if (cdata->Kind == V_TEXTBOX) { cdata->StartPoint.x -= PasteRange.left; cdata->StartPoint.y -= PasteRange.top; cdata->CenterPoint.x = (cdata->First.x + cdata->Second.x) / 2; cdata->CenterPoint.y = (cdata->First.y + cdata->Second.y) / 2; MakeTextBoxPointList(cdata); // todo: ij·ÔÀ» ó¸®Çϱâ À§Çؼ­ (¹Ú»óÈÆ) CenterPoint.x = data->CenterPoint.x; CenterPoint.y = data->CenterPoint.y; /* for (int k = 0; k < 5; k++) { cdata->pList[k].x -= PasteRange.left; cdata->pList[k].y -= PasteRange.top; } */ } memcpy(lpData, &cdata->Kind, sizeof(EVecKind)); lpData += sizeof(EVecKind); memcpy(lpData, &cdata->First, sizeof(POINT)); lpData += sizeof(POINT); memcpy(lpData, &cdata->Second, sizeof(POINT)); lpData += sizeof(POINT); switch(cdata->Kind) { case V_LINE: case V_CURVE: *(EPenStyle*)lpData = cdata->PenStyle; lpData += sizeof(EPenStyle); *(double*)lpData = cdata->PenThick; // 2005 Vector upgrade 20050225 lpData += sizeof(double); *(int*)lpData = cdata->nCount; lpData += sizeof(int); *(bool*)lpData = cdata->bRound; lpData += sizeof(bool); *(bool*)lpData = cdata->bFill; lpData += sizeof(bool); *(bool*)lpData = cdata->bWinding; lpData += sizeof(bool); *(bool*)lpData = cdata->bAntialiasing; // 20050222 shin lpData += sizeof(bool); *(TColor*)lpData = cdata->Color; lpData += sizeof(TColor); *(TColor*)lpData = cdata->Brush; lpData += sizeof(TColor); *(bool*)lpData = cdata->bClosed; lpData += sizeof(bool); *(int*)lpData = cdata->GroupIndex; lpData += sizeof(int); memcpy(lpData, cdata->pList, sizeof(DPOINT) * (cdata->nCount * 3 + 1)); lpData += (sizeof(DPOINT) * (cdata->nCount * 3 + 1)); *(bool*)lpData = cdata->bPatternFill; lpData += sizeof(bool); if (cdata->bPatternFill) { Byte *byte; *(int*)lpData = cdata->PatternAngle; lpData += sizeof(int); *(int*)lpData = cdata->PatternAdjustX; lpData += sizeof(int); *(int*)lpData = cdata->PatternAdjustY; lpData += sizeof(int); *(int*)lpData = cdata->RatioX; lpData += sizeof(int); *(int*)lpData = cdata->RatioY; lpData += sizeof(int); *(int*)lpData = cdata->TBitmapSource->Width; lpData += sizeof(int); *(int*)lpData = cdata->TBitmapSource->Height; lpData += sizeof(int); cdata->TBitmapSource->StartScanLine(); for (int k = 0; k < cdata->TBitmapSource->Height; k++) { byte = cdata->TBitmapSource->GetScanLine(k); memcpy(lpData, byte, sizeof(Byte) * cdata->TBitmapSource->Width * 3); lpData += (sizeof(Byte) * cdata->TBitmapSource->Width * 3); } cdata->TBitmapSource->StopScanLine(); } memcpy(lpData, cdata->DashValues, sizeof(double) * 7); // DashValues Ãß°¡ lpData += sizeof(double) * 7; *(int*)lpData = cdata->CapStyle[0]; lpData += sizeof(int); *(int*)lpData = cdata->CapStyle[1]; lpData += sizeof(int); if (cdata->CapStyle[0] && cdata->ArrowCap){ cdata->ArrowCap->SaveClipboard(lpData); lpData += cdata->ArrowCap->GetClipboardSize(); // *(bool*)lpData = cdata->ArrowCap->bFillLineCap; // lpData += sizeof(bool); // *(bool*)lpData = cdata->ArrowCap->bShowArrowBoth; // lpData += sizeof(bool); // *(double*)lpData = cdata->ArrowCap->LineCapWidthScale; // lpData += sizeof(double); // *(double*)lpData = cdata->ArrowCap->LineCapWidth; // lpData += sizeof(double); // *(double*)lpData = cdata->ArrowCap->LineCapHeight; // lpData += sizeof(double); } *(bool*)lpData = cdata->bGradientFill; // shin GradientFill Ãß°¡ 080514 lpData += sizeof(bool); if (cdata->bGradientFill) { *(int*)lpData = cdata->gradientItem; lpData += sizeof(int); *(int*)lpData = cdata->gAngle; lpData += sizeof(int); *(int*)lpData = cdata->gradientColorCount; lpData += sizeof(int); memcpy(lpData, cdata->gradientColors, sizeof(RGBQUAD) * (cdata->gradientColorCount)); // GradientFill Ãß°¡ lpData += sizeof(RGBQUAD) * (cdata->gradientColorCount); } *(bool*)lpData = cdata->bMotive; // embakum Motive 090317 lpData += sizeof(bool); if (cdata->bMotive) { *(int*)lpData = cdata->ChildCount; lpData += sizeof(int); *(int*)lpData = cdata->mode; lpData += sizeof(int); *(double*)lpData = cdata->gap; lpData += sizeof(double); *(int*)lpData = cdata->motivecount; lpData += sizeof(int); *(double*)lpData = cdata->proportion; lpData += sizeof(double); *(double*)lpData = cdata->childwidth; lpData += sizeof(double); *(double*)lpData = cdata->childheight; lpData += sizeof(double); *(double*)lpData = cdata->centerX; lpData += sizeof(double); *(double*)lpData = cdata->centerY; lpData += sizeof(double); } /* *(int *)lpData = cdata->LayerIndex; lpData += sizeof(int); *(int *)lpData = cdata->top; lpData += sizeof(int); *(int *)lpData = cdata->bottom; lpData += sizeof(int); memcpy(lpData, cdata->GridIndex, sizeof(int)*8); lpData += (sizeof(int)*8); *(int *)lpData = cdata->GridCount; lpData += sizeof(int); */ break; case V_TEXT: *(bool*)lpData = cdata->bAntialiasing; // 20050222 shin lpData += sizeof(bool); *(TColor*)lpData = cdata->Color; lpData += sizeof(TColor); *(LOGFONT*)lpData = cdata->Font; lpData += sizeof(LOGFONT); *(int*)lpData = cdata->nCount; lpData += sizeof(int); /* *(int *)lpData = cdata->top; lpData += sizeof(int); *(int *)lpData = cdata->bottom; lpData += sizeof(int); */ memcpy(lpData, cdata->TextString.c_str(), sizeof(Char) * cdata->nCount); lpData += (sizeof(Char) * cdata->nCount); break; case V_TEXTBOX: *(bool*)lpData = cdata->bAntialiasing; // 20050222 shin lpData += sizeof(bool); *(int*)lpData = cdata->CharH; // ±ÛÀÚÀÇ Å©±â lpData += sizeof(int); *(int*)lpData = cdata->CharW; lpData += sizeof(int); *(double*)lpData = cdata->TextAngle; // TextBoxÀÇ Angle·Î »ç¿ëµÊ lpData += sizeof(double); memcpy(lpData, &cdata->StartPoint, sizeof(POINT)); // ù±ÛÀÚ°¡ ÀÖ´Â À§Ä¡ lpData += sizeof(POINT); memcpy(lpData, &cdata->CenterPoint, sizeof(POINT)); // BoxÀÇ ¹«°ÔÁß½ÉÁ¡ lpData += sizeof(POINT); TSWordData *srcWordData; // °¢°¢ÀÇ ¶óÀÎÀ» ÀúÀåÇϰí ÀÖ´Â ºÎºÐÀ» Copy linecount = cdata->ListOfAllLine->LineCount; *(int*)lpData = linecount; // cdata->ListOfAllLine->LineCountÀúÀå lpData += sizeof(int); for (int i = 0; i < linecount; i++) { count = cdata->ListOfAllLine->GetLineTextBox(i)->LineDataList->Count; *(int*)lpData = count; // count ÀúÀå lpData += sizeof(int); for (int j = 0; j < count; j++) { srcWordData = (TSWordData*)cdata->ListOfAllLine->GetLineTextBox(i) ->LineDataList->Items[j]; // *(bool *)lpData = srcWordData->Selected; *(bool*)lpData = false; // ¹«Á¶°Ç ¼±ÅÃÇÏÁö ¾ÊÀº »óÅ·Π¸¸µç´Ù. lpData += sizeof(bool); *(bool*)lpData = srcWordData->bNameChanged; // 20050222 shin lpData += sizeof(bool); memcpy(lpData, &srcWordData->PPoint, sizeof(POINT)); // ù±ÛÀÚ°¡ ÀÖ´Â À§Ä¡ lpData += sizeof(POINT); *(LOGFONT*)lpData = srcWordData->LFont; lpData += sizeof(LOGFONT); memcpy(lpData, srcWordData->Word, sizeof(Char) * 2); lpData += (sizeof(Char) * 2); *(int*)lpData = srcWordData->UsedByte; lpData += sizeof(int); *(TColor*)lpData = srcWordData->Color; lpData += sizeof(TColor); *(int*)lpData = srcWordData->Interval; lpData += sizeof(int); *(float*)lpData = srcWordData->WidthGap; // º¯°æµÉ ±ÛÀÚ°£°Ý % lpData += sizeof(float); *(float*)lpData = srcWordData->HeightGap; // º¯°æµÉ ÁÙ°£°Ý % lpData += sizeof(float); } *(int*)lpData = cdata->ListOfAllLine->GetLineTextBox(i)->lineHeight; // lineHeight ÀúÀå lpData += sizeof(int); } memcpy(lpData, cdata->pList, sizeof(DPOINT) * 5); lpData += (sizeof(DPOINT) * 5); *(int*)lpData = cdata->nCount; lpData += sizeof(int); break; } // delete cdata->pList; // cdata->pList = NULL; delete cdata; cdata = NULL; } GlobalUnlock(hMem); OpenClipboard(MainImageForm->Handle); // Bitmap Ŭ¸³º¸µå±îÁö ºñ¿ö¹ö¸®±â ¶§¹®¿¡ ÀÏ´Ü ÁÖ¼® ó¸® - by monkman (2004.09.02) // EmptyClipboard(); SetClipboardData(CF_SYLK, hMem); // SetClipboardData(VectorFormat, hMem); CloseClipboard(); if (isCut) DeleteVectorObject(); END_LOG; } // --------------------------------------------------------------------------- /// Clipboard·Î º¹»çÇÑ µ¥ÀÌÅÍ ºÙÀ̱â void __fastcall TVecDraw::InitPaste() { if (BeReadyEdit) return; BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) TVecData *Child = NULL; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï °ü·Ã - ¹ÝÀü °Å¿ï »óÅ¿¡¼­ TextBox¿Í PatternFillÀº ºÙ¿©³Ö±â¸¦ ¸·¾Æ¾ßÇÔ - by monkman (2005.05.24) TList *TempList = NULL; TVecData *tData = NULL; TempList = new TList; bool bTextOrPatternFill = false; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Byte *lpData; bool sw = true; HGLOBAL hMem = NULL; int CopyCount = 0; EDataCode Code; int linecount, count; RECT rect; // º¤ÅÍ ¹öÀü Ãß°¡ - by monkman (2005.06.29) // ÆÄÀÏ µî¿¡¼­ »ç¿ëÇÏ´Â º¤ÅÍ ¹öÀü°ú µ¿ÀÏÇÏ°Ô Áõ°¡ // Version = 150 : 2005.06.29 // Version = 160 : 2008.04. textile 9.2 // Version = 170 : 2009.03 motive Ãß°¡ // Version = 180 : Unicode (TextBox) // Version = 181 : Arrow ¼öÁ¤ int Version = 181; TSWordData *srcWordData; // °¢°¢ÀÇ ¶óÀÎÀ» ÀúÀåÇϰí ÀÖ´Â ºÎºÐÀ» Copy TLineTextBox *tempTLineTextBox; Byte *byte; int w, h; // UINT VectorFormat = RegisterClipboardFormat("Vector"); // if (IsClipboardFormatAvailable(VectorFormat)) { // ºÙ¿©³Ö±â ÇÑ ¹ø¿¡ Çϳª¾¿¸¸ µÇµµ·Ï ¼öÁ¤ - by monkman (2009.04.15) if (NVector->bMergeMode == false && IsClipboardFormatAvailable(CF_SYLK)) { deSelect(); NVector->bMergeMode = true; NVector->bSelected = true; OpenClipboard(MainImageForm->Handle); hMem = GetClipboardData(CF_SYLK); // hMem = GetClipboardData(VectorFormat); lpData = (Byte*)GlobalLock(hMem); CopyCount = *(int*)lpData; lpData += sizeof(int); Code = *(EDataCode*)lpData; lpData += sizeof(EDataCode); Version = *(int*)lpData; lpData += sizeof(int); // Version = 150 : 2005.06.29 if (Version < 150 || Version > 181) { GlobalUnlock(hMem); CloseClipboard(); for (int i = 0; i < TempList->Count; i++) { tData = (TVecData*)TempList->Items[i]; delete tData; } TempList->Clear(); delete TempList; TempList = NULL; END_LOG; return; } for (int i = 0; i < CopyCount; i++) { data = new TVecData(MainImageForm->Number); data->Kind = *(EVecKind*)lpData; lpData += sizeof(EVecKind); data->First = *(POINT*)lpData; lpData += sizeof(POINT); data->Second = *(POINT*)lpData; lpData += sizeof(POINT); switch(data->Kind) { case V_LINE: case V_CURVE: data->PenStyle = *(EPenStyle*)lpData; lpData += sizeof(EPenStyle); data->PenThick = *(double*)lpData; // 2005 Vector Upgrade 0316 Shin int -> double lpData += sizeof(double); data->nCount = *(int*)lpData; lpData += sizeof(int); data->bRound = *(bool*)lpData; lpData += sizeof(bool); data->bFill = *(bool*)lpData; lpData += sizeof(bool); data->bWinding = *(bool*)lpData; lpData += sizeof(bool); data->bAntialiasing = *(bool*)lpData; // 2005 Vector Upgrade 0316 Shin lpData += sizeof(bool); data->Color = *(TColor*)lpData; lpData += sizeof(TColor); data->Brush = *(TColor*)lpData; lpData += sizeof(TColor); data->bClosed = *(bool*)lpData; lpData += sizeof(bool); data->GroupIndex = *(int*)lpData; lpData += sizeof(int); data->pList = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * (data->nCount * 3 + 1)); memcpy(data->pList, lpData, 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); memset(data->pMask, 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); lpData += (sizeof(DPOINT) * (data->nCount * 3 + 1)); data->bPatternFill = *(bool*)lpData; lpData += sizeof(bool); if (data->bPatternFill) { // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï °ü·Ã - ¹ÝÀü °Å¿ï »óÅ¿¡¼­ TextBox¿Í PatternFillÀº ºÙ¿©³Ö±â¸¦ ¸·¾Æ¾ßÇÔ - by monkman (2005.05.24) if (NVector->bVectorReflectionMode) { bTextOrPatternFill = true; goto fail; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- data->PatternAngle = *(int*)lpData; lpData += sizeof(int); data->PatternAdjustX = *(int*)lpData; lpData += sizeof(int); data->PatternAdjustY = *(int*)lpData; lpData += sizeof(int); data->RatioX = *(int*)lpData; lpData += sizeof(int); data->RatioY = *(int*)lpData; lpData += sizeof(int); w = *(int*)lpData; lpData += sizeof(int); h = *(int*)lpData; lpData += sizeof(int); data->TBitmapSource = new TTexpiaBitmap; data->TBitmapSource->Create(w, h, 24); data->TBitmapSource->StartScanLine(); for (int k = 0; k < h; k++) { byte = data->TBitmapSource->GetScanLine(k); memcpy(byte, lpData, sizeof(Byte) * w * 3); lpData += (sizeof(Byte) * w * 3); data->TBitmapSource->PutScanLine(k); } data->TBitmapSource->StopScanLine(); MakePatternBitmap(data); } memcpy(data->DashValues, lpData, sizeof(double) * 7); // DashValues Ãß°¡ lpData += sizeof(double) * 7; data->CapStyle[0] = *(int*)lpData; lpData += sizeof(int); data->CapStyle[1] = *(int*)lpData; lpData += sizeof(int); if (Version >= 181){ // data->CapStyle[0] == 2 ¿¡ ´ëÇØ¼­ arrowcapÀ» clipboard¿¡ ÀúÀåÇÏÁö ¾Ê¾Æ¼­ capstyleÀÌ 2 À϶§ ¹®Á¦°¡ µÈ´Ù. - 190418 ½Å½Â¹Î if ((data->CapStyle[0] == 1 || data->CapStyle[0] == 2) && data->ArrowCap){ int dataSize = data->ArrowCap->GetClipboard(lpData); lpData += dataSize; // data->ArrowCap->bFillLineCap = *(bool*)lpData; // lpData += sizeof(bool); // data->ArrowCap->bShowArrowBoth = *(bool*)lpData; // lpData += sizeof(bool); // data->ArrowCap->LineCapWidthScale = *(double*)lpData; // lpData += sizeof(double); // data->ArrowCap->LineCapWidth = *(double*)lpData; // lpData += sizeof(double); // data->ArrowCap->LineCapHeight = *(double*)lpData; // lpData += sizeof(double); } } if (Version >= 160) { data->bGradientFill = *(bool*)lpData; // GradientFill Ãß°¡ lpData += sizeof(bool); if (data->bGradientFill) { data->gradientItem = *(int*)lpData; lpData += sizeof(int); data->gAngle = *(int*)lpData; lpData += sizeof(int); data->gradientColorCount = *(int*)lpData; lpData += sizeof(int); data->gradientColors = new RGBQUAD[data->gradientColorCount]; memcpy(data->gradientColors, lpData, sizeof(RGBQUAD) * (data->gradientColorCount)); lpData += sizeof(RGBQUAD) * (data->gradientColorCount); } } if (Version >= 170) { data->bMotive = *(bool*)lpData; lpData += sizeof(bool); if (data->bMotive) { data->ChildCount = *(int*)lpData; lpData += sizeof(int); data->mode = *(int*)lpData; lpData += sizeof(int); data->gap = *(double*)lpData; lpData += sizeof(double); data->motivecount = *(int*)lpData; lpData += sizeof(int); data->proportion = *(double*)lpData; lpData += sizeof(double); data->childwidth = *(double*)lpData; lpData += sizeof(double); data->childheight = *(double*)lpData; lpData += sizeof(double); data->centerX = *(double*)lpData; lpData += sizeof(double); data->centerY = *(double*)lpData; lpData += sizeof(double); for (int i = 0; i < data->ChildCount; i++) { Child = new TVecData(MainImageForm->Number); Child->Kind = *(EVecKind*)lpData; lpData += sizeof(EVecKind); Child->First = *(POINT*)lpData; lpData += sizeof(POINT); Child->Second = *(POINT*)lpData; lpData += sizeof(POINT); switch(Child->Kind) { case V_LINE: case V_CURVE: Child->PenStyle = *(EPenStyle*)lpData; lpData += sizeof(EPenStyle); Child->PenThick = *(double*)lpData; lpData += sizeof(double); // 2005 Vector upgrade 0225 shin Child->nCount = *(int*)lpData; lpData += sizeof(int); Child->bRound = *(bool*)lpData; lpData += sizeof(bool); Child->bFill = *(bool*)lpData; lpData += sizeof(bool); Child->bWinding = *(bool*)lpData; lpData += sizeof(bool); Child->bAntialiasing = *(bool*)lpData; // 20050222 shin lpData += sizeof(bool); Child->Color = *(TColor*)lpData; lpData += sizeof(TColor); Child->Brush = *(TColor*)lpData; lpData += sizeof(TColor); Child->bClosed = *(bool*)lpData; lpData += sizeof(bool); Child->GroupIndex = *(int*)lpData; lpData += sizeof(int); Child->pList = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * (Child->nCount * 3 + 1)); memcpy(Child->pList, lpData, sizeof(DPOINT) * (Child->nCount * 3 + 1)); Child->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, (Child->nCount * 3 + 1) % 8 == 0 ? (Child->nCount * 3 + 1) / 8 : (Child->nCount * 3 + 1) / 8 + 1); lpData += (sizeof(DPOINT) * (Child->nCount * 3 + 1)); Child->bPatternFill = *(bool*)lpData; lpData += sizeof(bool); if (Child->bPatternFill) { // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï °ü·Ã - ¹ÝÀü °Å¿ï »óÅ¿¡¼­ TextBox¿Í PatternFillÀº ºÙ¿©³Ö±â¸¦ ¸·¾Æ¾ßÇÔ - by monkman (2005.05.24) if (NVector->bVectorReflectionMode) { bTextOrPatternFill = true; goto fail; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Child->PatternAngle = *(int*)lpData; lpData += sizeof(int); Child->PatternAdjustX = *(int*)lpData; lpData += sizeof(int); Child->PatternAdjustY = *(int*)lpData; lpData += sizeof(int); Child->RatioX = *(int*)lpData; lpData += sizeof(int); Child->RatioY = *(int*)lpData; lpData += sizeof(int); w = *(int*)lpData; lpData += sizeof(int); h = *(int*)lpData; lpData += sizeof(int); Child->TBitmapSource = new TTexpiaBitmap; Child->TBitmapSource->Create(w, h, 24); Child->TBitmapSource->StartScanLine(); for (int k = 0; k < h; k++) { byte = Child->TBitmapSource->GetScanLine(k); memcpy(byte, lpData, sizeof(Byte) * w * 3); lpData += (sizeof(Byte) * w * 3); Child->TBitmapSource->PutScanLine(k); } Child->TBitmapSource->StopScanLine(); MakePatternBitmap(Child); } memcpy(Child->DashValues, lpData, sizeof(double) * 7); // DashValues Ãß°¡ lpData += sizeof(double) * 7; Child->CapStyle[0] = *(int*)lpData; lpData += sizeof(int); Child->CapStyle[1] = *(int*)lpData; lpData += sizeof(int); if (Version >= 181){ if (Child->CapStyle[0] == 1 && Child->ArrowCap){ int dataSize = Child->ArrowCap->GetClipboard(lpData); lpData += dataSize; // Child->ArrowCap->bFillLineCap = *(bool*)lpData; // lpData += sizeof(bool); // Child->ArrowCap->bShowArrowBoth = *(bool*)lpData; // lpData += sizeof(bool); // Child->ArrowCap->LineCapWidthScale = *(double*)lpData; // lpData += sizeof(double); // Child->ArrowCap->LineCapWidth = *(double*)lpData; // lpData += sizeof(double); // Child->ArrowCap->LineCapHeight = *(double*)lpData; // lpData += sizeof(double); } } if (Version >= 160) { Child->bGradientFill = *(bool*)lpData; // shin GradientFill Ãß°¡ 080514 lpData += sizeof(bool); if (Child->bGradientFill) { Child->gradientItem = *(int*)lpData; lpData += sizeof(int); Child->gAngle = *(int*)lpData; lpData += sizeof(int); Child->gradientColorCount = *(int*)lpData; lpData += sizeof(int); Child->gradientColors = new RGBQUAD [Child->gradientColorCount]; memcpy(Child->gradientColors, lpData, sizeof(RGBQUAD) * (Child->gradientColorCount)); lpData += sizeof(RGBQUAD) * (Child->gradientColorCount); } } if (Version >= 170) { Child->bMotive = *(bool*)lpData; lpData += sizeof(bool); if (Child->bMotive) { Child->ChildCount = *(int*)lpData; lpData += sizeof(int); Child->mode = *(int*)lpData; lpData += sizeof(int); Child->gap = *(double*)lpData; lpData += sizeof(double); Child->motivecount = *(int*)lpData; lpData += sizeof(int); Child->proportion = *(double*)lpData; lpData += sizeof(double); Child->childwidth = *(double*)lpData; lpData += sizeof(double); Child->childheight = *(double*)lpData; lpData += sizeof(double); Child->centerX = *(double*)lpData; lpData += sizeof(double); Child->centerY = *(double*)lpData; lpData += sizeof(double); } } break; case V_TEXT: Child->bAntialiasing = *(bool*)lpData; // 20050222 shin lpData += sizeof(bool); Child->Color = *(TColor*)lpData; lpData += sizeof(TColor); Child->Font = *(LOGFONT*)lpData; lpData += sizeof(LOGFONT); Child->nCount = *(int*)lpData; lpData += sizeof(int); Char tempchar; for (int k = 0; k < Child->nCount; k++) { tempchar = *(Char*)lpData; Child->TextString += tempchar; lpData += sizeof(Char); } break; case V_TEXTBOX: // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï °ü·Ã - ¹ÝÀü °Å¿ï »óÅ¿¡¼­ TextBox¿Í PatternFillÀº ºÙ¿©³Ö±â¸¦ ¸·¾Æ¾ßÇÔ - by monkman (2005.05.24) if (NVector->bVectorReflectionMode) { bTextOrPatternFill = true; goto fail; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Child->bAntialiasing = *(bool*)lpData; // 20050222 shin lpData += sizeof(bool); Child->CharH = *(int*)lpData; // ±ÛÀÚÀÇ Å©±â lpData += sizeof(int); Child->CharW = *(int*)lpData; lpData += sizeof(int); Child->TextAngle = *(double*)lpData; // TextBoxÀÇ Angle·Î »ç¿ëµÊ lpData += sizeof(double); Child->StartPoint = *(POINT*)lpData; // ù±ÛÀÚ°¡ ÀÖ´Â À§Ä¡ lpData += sizeof(POINT); Child->CenterPoint = *(POINT*)lpData; // BoxÀÇ ¹«°ÔÁß½ÉÁ¡ lpData += sizeof(POINT); Child->ListOfAllLine = new TWordList; linecount = *(int*)lpData; // cdata->ListOfAllLine->LineCountÀúÀå lpData += sizeof(int); for (int i = 0; i < linecount; i++) { tempTLineTextBox = new TLineTextBox; count = *(int*)lpData; // count ÀúÀå lpData += sizeof(int); for (int j = 0; j < count; j++) { srcWordData = new TSWordData; srcWordData->Selected = *(bool*)lpData; lpData += sizeof(bool); srcWordData->bNameChanged = *(bool*)lpData; // 20050222 shin lpData += sizeof(bool); srcWordData->PPoint = *(POINT*)lpData; lpData += sizeof(POINT); if (Version <= 170) { LOGFONTA tempLFont = *(LOGFONTA*)lpData; lpData += sizeof(LOGFONTA); char tempWord[2]; memcpy(tempWord, lpData, sizeof(char) * 2); String wString; wString = String(tempWord); srcWordData->Word[0] = wString.c_str()[0]; srcWordData->Word[1] = 0; Copy_From_LOGFONTA_To_LOGFONTW(tempLFont, srcWordData->LFont); lpData += (sizeof(char) * 2); } else { srcWordData->LFont = *(LOGFONT*)lpData; lpData += sizeof(LOGFONT); memcpy(srcWordData->Word, lpData, sizeof(Char) * 2); lpData += (sizeof(Char) * 2); } srcWordData->UsedByte = *(int*)lpData; lpData += sizeof(int); srcWordData->Color = *(TColor*)lpData; lpData += sizeof(TColor); srcWordData->Interval = *(int*)lpData; lpData += sizeof(int); srcWordData->WidthGap = *(float*)lpData; // º¯°æµÉ ±ÛÀÚ°£°Ý % lpData += sizeof(float); srcWordData->HeightGap = *(float*)lpData; // º¯°æµÉ ÁÙ°£°Ý % lpData += sizeof(float); tempTLineTextBox->LineDataList->Add(srcWordData); } tempTLineTextBox->lineHeight = *(int*)lpData; // lineHeight ÀúÀå lpData += sizeof(int); Child->ListOfAllLine->Add(tempTLineTextBox); } Child->pList = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * 5); memcpy(Child->pList, lpData, sizeof(DPOINT) * 5); Child->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, (Child->nCount * 3 + 1) % 8 == 0 ? (Child->nCount * 3 + 1) / 8 : (Child->nCount * 3 + 1) / 8 + 1); lpData += (sizeof(DPOINT) * 5); Child->nCount = *(int*)lpData; lpData += sizeof(int); break; } Child->bSelected = true; // º¹»ç ºÙ¿©³Ö±â ½Ã º¸¿©Áöµµ·Ï - by monkman (2009.04.02) if (!data->ChildList) { data->ChildList = new TList; data->ChildList->Add(Child); } else { data->ChildList->Add(Child); } } } } /* data->LayerIndex = *(int *)lpData; lpData += sizeof(int); data->top = *(int *)lpData; lpData += sizeof(int); data->bottom = *(int *)lpData; lpData += sizeof(int); memcpy(data->GridIndex, lpData, sizeof(int)*8); lpData += (sizeof(int)*8); data->GridCount = *(int *)lpData; lpData += sizeof(int); */ break; case V_TEXT: data->Color = *(TColor*)lpData; lpData += sizeof(TColor); data->Font = *(LOGFONT*)lpData; lpData += sizeof(LOGFONT); data->nCount = *(int*)lpData; lpData += sizeof(int); data->bAntialiasing = *(bool*)lpData; // 2005 Vector Upgrade 0316 Shin lpData += sizeof(bool); Char tempchar; for (int k = 0; k < data->nCount; k++) { tempchar = *(Char*)lpData; data->TextString += tempchar; lpData += sizeof(Char); } break; case V_TEXTBOX: // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï °ü·Ã - ¹ÝÀü °Å¿ï »óÅ¿¡¼­ TextBox¿Í PatternFillÀº ºÙ¿©³Ö±â¸¦ ¸·¾Æ¾ßÇÔ - by monkman (2005.05.24) if (NVector->bVectorReflectionMode) { bTextOrPatternFill = true; goto fail; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- data->CharH = *(int*)lpData; // ±ÛÀÚÀÇ Å©±â lpData += sizeof(int); data->CharW = *(int*)lpData; lpData += sizeof(int); data->TextAngle = *(double*)lpData; // TextBoxÀÇ Angle·Î »ç¿ëµÊ lpData += sizeof(double); data->bAntialiasing = *(bool*)lpData; // 2005 Vector Upgrade Shin 0316 lpData += sizeof(bool); data->StartPoint = *(POINT*)lpData; // ù±ÛÀÚ°¡ ÀÖ´Â À§Ä¡ lpData += sizeof(POINT); data->CenterPoint = *(POINT*)lpData; // BoxÀÇ ¹«°ÔÁß½ÉÁ¡ lpData += sizeof(POINT); if (Version >= 170) { data->GroupIndex = *(int*)lpData; // GroupIndex lpData += sizeof(int); } data->ListOfAllLine = new TWordList; linecount = *(int*)lpData; // cdata->ListOfAllLine->LineCountÀúÀå lpData += sizeof(int); for (int i = 0; i < linecount; i++) { tempTLineTextBox = new TLineTextBox; count = *(int*)lpData; // count ÀúÀå lpData += sizeof(int); for (int j = 0; j < count; j++) { srcWordData = new TSWordData; srcWordData->Selected = *(bool*)lpData; lpData += sizeof(bool); srcWordData->bNameChanged = *(bool*)lpData; // 2005 Vector Upgrade 0316 Shin lpData += sizeof(bool); srcWordData->PPoint = *(POINT*)lpData; lpData += sizeof(POINT); if (Version <= 170) { LOGFONTA tempLFont = *(LOGFONTA*)lpData; lpData += sizeof(LOGFONTA); char tempWord[2]; memcpy(tempWord, lpData, sizeof(char) * 2); String wString; wString = String(tempWord); srcWordData->Word[0] = wString.c_str()[0]; srcWordData->Word[1] = 0; Copy_From_LOGFONTA_To_LOGFONTW(tempLFont, srcWordData->LFont); lpData += (sizeof(char) * 2); } else { srcWordData->LFont = *(LOGFONT*)lpData; lpData += sizeof(LOGFONT); memcpy(srcWordData->Word, lpData, sizeof(Char) * 2); lpData += (sizeof(Char) * 2); } srcWordData->UsedByte = *(int*)lpData; lpData += sizeof(int); srcWordData->Color = *(TColor*)lpData; lpData += sizeof(TColor); srcWordData->Interval = *(int*)lpData; lpData += sizeof(int); srcWordData->WidthGap = *(float*)lpData; // º¯°æµÉ ±ÛÀÚ°£°Ý % lpData += sizeof(float); srcWordData->HeightGap = *(float*)lpData; // º¯°æµÉ ÁÙ°£°Ý % lpData += sizeof(float); tempTLineTextBox->LineDataList->Add(srcWordData); } tempTLineTextBox->lineHeight = *(int*)lpData; // lineHeight ÀúÀå lpData += sizeof(int); data->ListOfAllLine->Add(tempTLineTextBox); } data->pList = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * 5); memcpy(data->pList, lpData, sizeof(DPOINT) * 5); data->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, 1); memset(data->pMask, 0, 1); lpData += (sizeof(DPOINT) * 5); data->nCount = *(int*)lpData; lpData += sizeof(int); break; } data->bSelected = true; if (Code == T_TEX3D) { if (data->bClosed) data->bFill = true; } TempList->Add(data); // DataList->Add(data); // UndoSave(VU_CREATE, DataList->Count-1, sw); // sw = false; } GlobalUnlock(hMem); CloseClipboard(); } PasteRange = Rect(50000, 50000, 0, 0); { // À§¿¡ ÀÖ´Â goto ¶§¹®¿¡ º¯¼ö¸¦ ¾Æ·¡¿¡ ¼±¾ðÇÒ ¼ö ¾ø´Âµ¥ ¿©±â¼­¸¸ »ç¿ëÇÒ º¯¼öÀ̹ǷΠÀ§¿¡ º¯¼ö¸¦ ¼±¾ðÇϱ⠺¸´Ù ±×³É // ±âÁ¸ object¸¦ º¹»çÇÏ¿© ºÙ¿©³ÖÀ» ¶§ ±×·ìÀÌ ¼³Á¤µÈ °æ¿ì¿¡µµ // ±×·ì ¼³Á¤ÀÌ Ç®¸®µµ·Ï(Áï, GroupIndex = 0) µÇ¾î ÀÖ´ø °ÍÀ» // »õ·Î¿î GroupIndex¸¦ ¼³Á¤ÇÏ¿© ±×·ìÀ» À¯Áö Çϵµ·Ï Çϱâ À§ÇØ ¾Æ·¡¿Í °°ÀÌ ¼öÁ¤ // º¹»çµÇ¾î ¿À´Â objectµéÀÇ GroupIndex¸¦ ¹Ì¸® Á¶»çÇÏ¿© tempIndexlist¿¡ ÀúÀå int srcGroupCnt = 0; int *tempIndexList = new int[TempList->Count]; for (int i = 0; i < TempList->Count; i++) { tData = (TVecData*)TempList->Items[i]; tData->GroupIndex -= ((tData->GroupIndex % 10000) & 0x000001ff); int cnt = 0; for (cnt = 0; cnt < srcGroupCnt; cnt++) { if (tempIndexList[cnt] == tData->GroupIndex) break; } if (cnt == srcGroupCnt) tempIndexList[srcGroupCnt++] = tData->GroupIndex; } // object¸¦ DataList¿¡ Ãß°¡ ÇÒ¶§ °°Àº group³¢¸® °°Àº GroupIndex¸¦ °¡Áöµµ·Ï ¼³Á¤ ÇÑ ÈÄ Ãß°¡ for (int i = 0; i < TempList->Count; i++) { tData = (TVecData*)TempList->Items[i]; for (int idx = 0; idx < srcGroupCnt; idx++) { if (tData->GroupIndex != 0 && tData->GroupIndex == tempIndexList[idx]) { tData->GroupIndex = MainImageForm->GroupIndexState + (idx + 1) * 10000; break; } } DataList->Add(tData); UndoSave(VU_CREATE, DataList->Count - 1, sw); sw = false; } MainImageForm->GroupIndexState += (srcGroupCnt * 10000); if (tempIndexList) delete[]tempIndexList; tempIndexList = NULL; } /* for (int i = 0; i < TempList->Count; i++) { tData = (TVecData *)TempList->Items[i]; DataList->Add(tData); UndoSave(VU_CREATE, DataList->Count-1, sw); sw = false; } */ if (TempList) { delete TempList; TempList = NULL; } MaxThick = 0; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->Kind == V_TEXTBOX && data->TextAngle) { MakeTextBoxPointList(data); GetRectForMouseMove(data, rect); PasteRange.left = min(PasteRange.left, rect.left - data->PenThick * 2); PasteRange.right = max(PasteRange.right, rect.right + data->PenThick * 2); PasteRange.top = min(PasteRange.top, rect.top - data->PenThick * 2); PasteRange.bottom = max(PasteRange.bottom, rect.bottom + data->PenThick * 2); } else { // if (data->bMotive) SET_RECT; // ¹ÝÀü º¹»çÀÇ °æ¿ì ¿µ¿ªÀ» ´Ù½Ã ±¸ÇÔ - by monkman (2009.04.16) SET_RECT; // else { MaxThick = max(MaxThick, data->PenThick + 1); PasteRange.left = min(PasteRange.left, min(data->First.x, data->Second.x) - data->PenThick * 2); PasteRange.right = max(PasteRange.right, max(data->First.x, data->Second.x) + data->PenThick * 2); PasteRange.top = min(PasteRange.top, min(data->First.y, data->Second.y) - data->PenThick * 2); PasteRange.bottom = max(PasteRange.bottom, max(data->First.y, data->Second.y) + data->PenThick * 2); // } } } /* TVecData *cdata = NULL; bool sw = true; deSelect(); NVector->bMergeMode = true; NVector->bSelected = true; for (int i = 0; i < CopyList->Count; i++) { cdata = (TVecData *)CopyList->Items[i]; data = new TVecData(MainImageForm->Number); data->Copy(cdata); data->bSelected = true; DataList->Add(data); UndoSave(VU_CREATE, DataList->Count-1, sw); sw = false; } */ END_LOG; return; fail: // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï °ü·Ã - ¹ÝÀü °Å¿ï »óÅ¿¡¼­ TextBox¿Í PatternFillÀº ºÙ¿©³Ö±â¸¦ ¸·¾Æ¾ßÇÔ - by monkman (2005.05.24) GlobalUnlock(hMem); CloseClipboard(); if (TempList) { for (int i = 0; i < TempList->Count; i++) { tData = (TVecData*)TempList->Items[i]; delete tData; } TempList->Clear(); delete TempList; TempList = NULL; }; // ¸Þ½ÃÁö : ¹ÝÀü °Å¿ï »óÅ¿¡¼­ ¹®ÀÚ¿Í ÆÐÅÏ Ã¤¿ì±â´Â »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù. Application->MessageBox(IDS_MESSAGE007.c_str(), L"Error", MB_ICONERROR); // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- END_LOG; } // --------------------------------------------------------------------------- // »ç¿ëÇÏÁö ¾Ê´Â ÇÔ¼ö void __fastcall TVecDraw::InitPasteChild(TVecData *Parent, TVecData *Child) { BEGIN_LOG(""); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï °ü·Ã - ¹ÝÀü °Å¿ï »óÅ¿¡¼­ TextBox¿Í PatternFillÀº ºÙ¿©³Ö±â¸¦ ¸·¾Æ¾ßÇÔ - by monkman (2005.05.24) bool bTextOrPatternFill = false; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) Byte *lpData; bool sw = true; HGLOBAL hMem = NULL; int CopyCount = 0; EDataCode Code; int linecount, count; RECT rect; // º¤ÅÍ ¹öÀü Ãß°¡ - by monkman (2005.06.29) // ÆÄÀÏ µî¿¡¼­ »ç¿ëÇÏ´Â º¤ÅÍ ¹öÀü°ú µ¿ÀÏÇÏ°Ô Áõ°¡ // Version = 150 : 2005.06.29 // Version = 160 : 2008.05.08 // Version = 170 : 2009.03.20 int Version = 170; TSWordData *srcWordData; // °¢°¢ÀÇ ¶óÀÎÀ» ÀúÀåÇϰí ÀÖ´Â ºÎºÐÀ» Copy TLineTextBox *tempTLineTextBox; Byte *byte; int w, h; if (IsClipboardFormatAvailable(CF_SYLK)) { deSelect(); NVector->bMergeMode = true; NVector->bSelected = true; OpenClipboard(MainImageForm->Handle); Child->Kind = *(EVecKind*)lpData; lpData += sizeof(EVecKind); Child->First = *(POINT*)lpData; lpData += sizeof(POINT); Child->Second = *(POINT*)lpData; lpData += sizeof(POINT); switch(Child->Kind) { case V_LINE: case V_CURVE: Child->PenStyle = *(EPenStyle*)lpData; lpData += sizeof(EPenStyle); Child->PenThick = *(double*)lpData; lpData += sizeof(double); // 2005 Vector upgrade 0225 shin Child->nCount = *(int*)lpData; lpData += sizeof(int); Child->bRound = *(bool*)lpData; lpData += sizeof(bool); Child->bFill = *(bool*)lpData; lpData += sizeof(bool); Child->bWinding = *(bool*)lpData; lpData += sizeof(bool); Child->bAntialiasing = *(bool*)lpData; // 20050222 shin lpData += sizeof(bool); Child->Color = *(TColor*)lpData; lpData += sizeof(TColor); Child->Brush = *(TColor*)lpData; lpData += sizeof(TColor); Child->bClosed = *(bool*)lpData; lpData += sizeof(bool); Child->GroupIndex = *(int*)lpData; lpData += sizeof(int); Child->pList = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * (Child->nCount * 3 + 1)); memcpy(Child->pList, lpData, sizeof(DPOINT) * (Child->nCount * 3 + 1)); Child->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, (Child->nCount * 3 + 1) % 8 == 0 ? (Child->nCount * 3 + 1) / 8 : (Child->nCount * 3 + 1) / 8 + 1); lpData += (sizeof(DPOINT) * (Child->nCount * 3 + 1)); Child->bPatternFill = *(bool*)lpData; lpData += sizeof(bool); if (data->bPatternFill) { // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï °ü·Ã - ¹ÝÀü °Å¿ï »óÅ¿¡¼­ TextBox¿Í PatternFillÀº ºÙ¿©³Ö±â¸¦ ¸·¾Æ¾ßÇÔ - by monkman (2005.05.24) if (NVector->bVectorReflectionMode) { bTextOrPatternFill = true; goto fail; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Child->PatternAngle = *(int*)lpData; lpData += sizeof(int); Child->PatternAdjustX = *(int*)lpData; lpData += sizeof(int); Child->PatternAdjustY = *(int*)lpData; lpData += sizeof(int); Child->RatioX = *(int*)lpData; lpData += sizeof(int); Child->RatioY = *(int*)lpData; lpData += sizeof(int); w = *(int*)lpData; lpData += sizeof(int); h = *(int*)lpData; lpData += sizeof(int); Child->TBitmapSource = new TTexpiaBitmap; Child->TBitmapSource->Create(w, h, 24); Child->TBitmapSource->StartScanLine(); for (int k = 0; k < h; k++) { byte = Child->TBitmapSource->GetScanLine(k); memcpy(byte, lpData, sizeof(Byte) * w * 3); lpData += (sizeof(Byte) * w * 3); Child->TBitmapSource->PutScanLine(k); } Child->TBitmapSource->StopScanLine(); MakePatternBitmap(Child); } memcpy(Child->DashValues, lpData, sizeof(double) * 7); // DashValues Ãß°¡ lpData += sizeof(double) * 7; Child->CapStyle[0] = *(int*)lpData; lpData += sizeof(int); Child->CapStyle[1] = *(int*)lpData; lpData += sizeof(int); if (Version >= 181){ if (Child->CapStyle[0] == 1 && Child->ArrowCap){ int dataSize = Child->ArrowCap->GetClipboard(lpData); lpData += dataSize; // Child->ArrowCap->bFillLineCap = *(bool*)lpData; // lpData += sizeof(bool); // Child->ArrowCap->bShowArrowBoth = *(bool*)lpData; // lpData += sizeof(bool); // Child->ArrowCap->LineCapWidthScale = *(double*)lpData; // lpData += sizeof(double); // Child->ArrowCap->LineCapWidth = *(double*)lpData; // lpData += sizeof(double); // Child->ArrowCap->LineCapHeight = *(double*)lpData; // lpData += sizeof(double); } } if (Version >= 160) { Child->bGradientFill = *(bool*)lpData; // shin GradientFill Ãß°¡ 080514 lpData += sizeof(bool); if (Child->bGradientFill) { Child->gradientItem = *(int*)lpData; lpData += sizeof(int); Child->gAngle = *(int*)lpData; lpData += sizeof(int); Child->gradientColorCount = *(int*)lpData; lpData += sizeof(int); Child->gradientColors = new RGBQUAD[data->gradientColorCount]; memcpy(Child->gradientColors, lpData, sizeof(RGBQUAD) * (Child->gradientColorCount)); lpData += sizeof(RGBQUAD) * (data->gradientColorCount); } } if (Version >= 170) { Child->bMotive = *(bool*)lpData; lpData += sizeof(bool); if (Child->bMotive) { Child->ChildCount = *(int*)lpData; lpData += sizeof(int); Child->mode = *(int*)lpData; lpData += sizeof(int); Child->gap = *(double*)lpData; lpData += sizeof(double); Child->motivecount = *(int*)lpData; lpData += sizeof(int); Child->proportion = *(double*)lpData; lpData += sizeof(double); Child->childwidth = *(double*)lpData; lpData += sizeof(double); Child->childheight = *(double*)lpData; lpData += sizeof(double); Child->centerX = *(double*)lpData; lpData += sizeof(double); Child->centerY = *(double*)lpData; lpData += sizeof(double); } } break; case V_TEXT: Child->bAntialiasing = *(bool*)lpData; // 20050222 shin lpData += sizeof(bool); Child->Color = *(TColor*)lpData; lpData += sizeof(TColor); Child->Font = *(LOGFONT*)lpData; lpData += sizeof(LOGFONT); Child->nCount = *(int*)lpData; lpData += sizeof(int); Char tempchar; for (int k = 0; k < Child->nCount; k++) { tempchar = *(Char*)lpData; Child->TextString += tempchar; lpData += sizeof(Char); } break; case V_TEXTBOX: // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï °ü·Ã - ¹ÝÀü °Å¿ï »óÅ¿¡¼­ TextBox¿Í PatternFillÀº ºÙ¿©³Ö±â¸¦ ¸·¾Æ¾ßÇÔ - by monkman (2005.05.24) if (NVector->bVectorReflectionMode) { bTextOrPatternFill = true; goto fail; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Child->bAntialiasing = *(bool*)lpData; // 20050222 shin lpData += sizeof(bool); Child->CharH = *(int*)lpData; // ±ÛÀÚÀÇ Å©±â lpData += sizeof(int); Child->CharW = *(int*)lpData; lpData += sizeof(int); Child->TextAngle = *(double*)lpData; // TextBoxÀÇ Angle·Î »ç¿ëµÊ lpData += sizeof(double); Child->StartPoint = *(POINT*)lpData; // ù±ÛÀÚ°¡ ÀÖ´Â À§Ä¡ lpData += sizeof(POINT); Child->CenterPoint = *(POINT*)lpData; // BoxÀÇ ¹«°ÔÁß½ÉÁ¡ lpData += sizeof(POINT); Child->ListOfAllLine = new TWordList; linecount = *(int*)lpData; // cdata->ListOfAllLine->LineCountÀúÀå lpData += sizeof(int); for (int i = 0; i < linecount; i++) { tempTLineTextBox = new TLineTextBox; count = *(int*)lpData; // count ÀúÀå lpData += sizeof(int); for (int j = 0; j < count; j++) { srcWordData = new TSWordData; srcWordData->Selected = *(bool*)lpData; lpData += sizeof(bool); srcWordData->bNameChanged = *(bool*)lpData; // 20050222 shin lpData += sizeof(bool); srcWordData->PPoint = *(POINT*)lpData; lpData += sizeof(POINT); srcWordData->LFont = *(LOGFONT*)lpData; lpData += sizeof(LOGFONT); memcpy(srcWordData->Word, lpData, sizeof(Char) * 2); lpData += (sizeof(Char) * 2); srcWordData->UsedByte = *(int*)lpData; lpData += sizeof(int); srcWordData->Color = *(TColor*)lpData; lpData += sizeof(TColor); srcWordData->Interval = *(int*)lpData; lpData += sizeof(int); srcWordData->WidthGap = *(float*)lpData; // º¯°æµÉ ±ÛÀÚ°£°Ý % lpData += sizeof(float); srcWordData->HeightGap = *(float*)lpData; // º¯°æµÉ ÁÙ°£°Ý % lpData += sizeof(float); tempTLineTextBox->LineDataList->Add(srcWordData); } tempTLineTextBox->lineHeight = *(int*)lpData; // lineHeight ÀúÀå lpData += sizeof(int); Child->ListOfAllLine->Add(tempTLineTextBox); } Child->pList = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * 5); memcpy(Child->pList, lpData, sizeof(DPOINT) * 5); Child->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, 1); lpData += (sizeof(DPOINT) * 5); Child->nCount = *(int*)lpData; lpData += sizeof(int); break; } Child->bSelected = true; if (Code == T_TEX3D) { if (data->bClosed) data->bFill = true; } if (!Parent->ChildList) { Parent->ChildList = new TList; Parent->ChildList->Add(Child); } else { Parent->ChildList->Add(Child); } GlobalUnlock(hMem); CloseClipboard(); } PasteRange = Rect(50000, 50000, 0, 0); END_LOG; return; fail: // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï °ü·Ã - ¹ÝÀü °Å¿ï »óÅ¿¡¼­ TextBox¿Í PatternFillÀº ºÙ¿©³Ö±â¸¦ ¸·¾Æ¾ßÇÔ - by monkman (2005.05.24) GlobalUnlock(hMem); CloseClipboard(); // ¸Þ½ÃÁö : ¹ÝÀü °Å¿ï »óÅ¿¡¼­ ¹®ÀÚ¿Í ÆÐÅÏ Ã¤¿ì±â´Â »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù. Application->MessageBox(IDS_MESSAGE007.c_str(), L"Error", MB_ICONERROR); // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- END_LOG; } // --------------------------------------------------------------------------- /// ¼±ÅÃµÈ data ¹ÝÀüº¹»ç void __fastcall TVecDraw::InitReverse() { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL, *cdata = NULL, *childdata = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) DPOINT dpFirst, dpSecond; double dpMotiveAxis; PasteRange = Rect(50000, 50000, 0, 0); int nDataListCount; // ÀÌÀü DataList->Count - by monkman (2009.04.02) int tempx; int nVCenter; // ¼öÁ÷ Áß½ÉÁÂÇ¥ bool sw = true; // ========== ÀúÀåµÇ¾ú´ø copydataÁö¿ò for (int i = 0; i < CopyList->Count; i++) { cdata = (TVecData*)CopyList->Items[i]; if (cdata) { if (cdata->ParentTextBox) { delete cdata->ParentTextBox; cdata->ParentTextBox = NULL; } } delete cdata; } CopyList->Clear(); MaxThick = 0; // ========== ¿Ü°û µÑ·¹ ±¸ÇÏ´Â ºÎºÐ for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->Kind != V_LINE && data->Kind != V_CURVE) continue; // Text´Â ¹ÝÀüº¹»ç ¸øÇØ¿ä... // -->by linuxjun for CurvedVectorText if (data->ParentTextBox) continue; // <--by linuxjun for CurvedVectorText MaxThick = max(MaxThick, data->PenThick); PasteRange.left = min(PasteRange.left, min(data->First.x, data->Second.x) - data->PenThick * 2); PasteRange.right = max(PasteRange.right, max(data->First.x, data->Second.x) + data->PenThick * 2); PasteRange.top = min(PasteRange.top, min(data->First.y, data->Second.y) - data->PenThick * 2); PasteRange.bottom = max(PasteRange.bottom, max(data->First.y, data->Second.y) + data->PenThick * 2); } nVCenter = (PasteRange.left + PasteRange.right) / 2; // ========== ¹ÝÀüº¹»ç ÇÏ´Â ºÎºÐ nDataListCount = DataList->Count; for (int i = 0; i < nDataListCount; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->Kind != V_LINE && data->Kind != V_CURVE) continue; // Text´Â ¹ÝÀüº¹»ç ¸øÇØ¿ä... // -->by linuxjun for CurvedVectorText if (data->ParentTextBox) continue; // <--by linuxjun for CurvedVectorText cdata = new TVecData(MainImageForm->Number); cdata->Copy(data); if (cdata->Kind == V_LINE || cdata->Kind == V_CURVE) { for (int j = 0; j < cdata->nCount * 3 + 1; j++) { cdata->pList[j].x = 2 * nVCenter - cdata->pList[j].x - PasteRange.left; cdata->pList[j].y -= PasteRange.top; } } // Motive ¹ÝÀü ó¸® - by monkman (2009.05.01) if (cdata->bMotive && cdata->ChildList && cdata->ChildList->Count > 0) { dpFirst.y = MaxInt; dpSecond.y = 0; for (int j = 0; j < cdata->ChildList->Count; j++) { childdata = (TVecData*)cdata->ChildList->Items[j]; for (int k = 0; k < childdata->nCount * 3 + 1; k++) { dpFirst.y = min(dpFirst.y, childdata->pList[k].y); dpSecond.y = max(dpSecond.y, childdata->pList[k].y); } } for (int j = 0; j < cdata->ChildList->Count; j++) { childdata = (TVecData*)cdata->ChildList->Items[j]; dpMotiveAxis = dpFirst.y + (dpSecond.y - dpFirst.y) / 2; for (int k = 0; k < childdata->nCount * 3 + 1; k++) { childdata->pList[k].y = (dpMotiveAxis * 2) - childdata->pList[k].y; } } } tempx = cdata->First.x; cdata->First.x = 2 * nVCenter - cdata->Second.x - PasteRange.left; cdata->Second.x = 2 * nVCenter - tempx - PasteRange.left; cdata->First.y -= PasteRange.top; cdata->Second.y -= PasteRange.top; // cdata->GroupIndex = 0; // GroupIndex´Â copy¾ÈµÇ°Ô.. => copyµÇµµ·Ï Çϱâ À§ÇØ ÁÖ¼®Ã³¸®ÇÔ. if (cdata->bPatternFill) { cdata->PatternAngle = 360 - cdata->PatternAngle; cdata->TBitmapSource->Reverse(); MakePatternBitmap(cdata); } /* cdata->bSelected = true; data->bSelected = false; DataList->Add(cdata); */ CopyList->Add(cdata); } // ==========ºÙÀÌ´Â ºÎºÐ if (NVector->bMergeMode) DeleteVectorObject(false); deSelect(); NVector->bMergeMode = true; NVector->bSelected = true; // UndoSave(VU_CREATE, DataList->Count-1, sw); /////////////// // ±âÁ¸ object¸¦ º¹»çÇÏ¿© ºÙ¿©³ÖÀ» ¶§ ±×·ìÀÌ ¼³Á¤µÈ °æ¿ì¿¡µµ // ±×·ì ¼³Á¤ÀÌ Ç®¸®µµ·Ï(Áï, GroupIndex = 0) µÇ¾î ÀÖ´ø °ÍÀ» // »õ·Î¿î GroupIndex¸¦ ¼³Á¤ÇÏ¿© ±×·ìÀ» À¯Áö Çϵµ·Ï Çϱâ À§ÇØ ¾Æ·¡¿Í °°ÀÌ ¼öÁ¤ // º¹»çµÇ¾î ¿À´Â objectµéÀÇ GroupIndex¸¦ ¹Ì¸® Á¶»çÇÏ¿© tempIndexlist¿¡ ÀúÀå int srcGroupCnt = 0; int *tempIndexList = new int[CopyList->Count]; for (int i = 0; i < CopyList->Count; i++) { cdata = (TVecData*)CopyList->Items[i]; cdata->GroupIndex -= ((cdata->GroupIndex % 10000) & 0x000001ff); int cnt = 0; for (cnt = 0; cnt < srcGroupCnt; cnt++) { if (tempIndexList[cnt] == cdata->GroupIndex) break; } if (cnt == srcGroupCnt) tempIndexList[srcGroupCnt++] = cdata->GroupIndex; } // object¸¦ DataList¿¡ Ãß°¡ ÇÒ¶§ °°Àº group³¢¸® °°Àº GroupIndex¸¦ °¡Áöµµ·Ï ¼³Á¤ ÇÑ ÈÄ Ãß°¡ for (int i = 0; i < CopyList->Count; i++) { cdata = (TVecData*)CopyList->Items[i]; for (int idx = 0; idx < srcGroupCnt; idx++) { if (cdata->GroupIndex != 0 && cdata->GroupIndex == tempIndexList[idx]) { cdata->GroupIndex = MainImageForm->GroupIndexState + (idx + 1) * 10000; break; } } data = new TVecData(MainImageForm->Number); data->Copy(cdata); data->bSelected = true; DataList->Add(data); UndoSave(VU_CREATE, DataList->Count - 1, sw); sw = false; } MainImageForm->GroupIndexState += (srcGroupCnt * 10000); if (tempIndexList) delete[]tempIndexList; tempIndexList = NULL; END_LOG; } // --------------------------------------------------------------------------- /// ¼±ÅÃµÈ µÎ Á¡ÀÇ ¿¬°á void __fastcall TVecDraw::InitJoin() { BEGIN_LOG(""); TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) TVecData *tData = NULL; TList *DataList = NVector->DataList; int count = 0, pcount = 0, tempcount; bool success, first1, first2, sw = true; // TVecData *data1 = NULL, *data2 = NULL; DPOINT *temp1 = NULL, *temp2 = NULL; // temp1[1024], temp2[1024] ¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) RECT rc; int NumberOfObject = 0; bool NumberErrorExist = 0; for (int i = 0; i < DataList->Count; i++) { // JoinÀÌ °¡´ÉÇÑÁö ÆÇ´Ü data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->ParentTextBox) continue; // by linuxjun for CurvedVectorText if (data->ListOfAllLine && data->ListOfAllLine->CurveData) continue; // by linuxjun for CurvedVectorText if (data->bClosed) goto fail; if (++count > 2) goto fail; // 2°³ ÃʰúÀÇ object°¡ ¼±ÅÃµÈ °æ¿ì // ¿ÀºêÁ§Æ® ´ç 1024 Æ÷ÀÎÆ® Á¦ÇÑ ÇØÁ¦ - by monkman (2011.04.20) /* NumberOfObject += data->nCount; if (NumberOfObject > 340) { NumberErrorExist = 1; goto fail; // ÇÕÃļ­ °¹¼ö°¡ 1024°³ ³Ñ¾î°£´Ù¸é fail } */ for (int j = 0; j < data->nCount * 3 + 1; j += 3) { if ((data->pMask[j / 8] >> j % 8) & 0x01) { if (j != 0 && j != data->nCount * 3) goto fail; // ³¡Á¡ÀÌ ¾Æ´Ñ°æ¿ì if (++pcount > 2) goto fail; // 2°³ ÃʰúÀÇ Á¡ÀÌ ¼±ÅÃµÈ °æ¿ì if (pcount == 1) first1 = j == 0 ? true : false; // ù¹øÂ° Á¡ÀÌ³Ä ¸¶Áö¸· Á¡ÀÌ³Ä if (pcount == 2) first2 = j == 0 ? true : false; } } } if (!pcount || pcount == 1 || !count) goto fail; for (int i = 0; i < DataList->Count; i++) { // Join ¼öÇà data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (count == 1) { // ÇÑ ¿ÀºêÁ§Æ®ÀÇ ¾ç ³¡Á¡ÀÌ ¼±ÅÃµÈ °æ¿ì if ((data->pMask[0] & 0x01) && (data->pMask[data->nCount * 3 / 8] >> data->nCount * 3 % 8) & 0x01) { UndoSave(VU_MODIFY, i); JoinItself(data); // data->bClosed = true; // if (pEqual(data->pList[0].P(), data->pList[data->nCount*3].P())) { // Join Point°¡ °°Àº °æ¿ì (°ãÄ¡´Â Á¡Àΰæ¿ì) // } // else { // ¾Æ´Ñ°æ¿ì // data->nCount++; // data->pList = (DPOINT *)HeapReAlloc(GetProcessHeap(), 0, data->pList, sizeof(DPOINT)*(data->nCount*3+1)); // HeapCompact(GetProcessHeap(), 0); // // data->pList[data->nCount*3-2] = data->pList[data->nCount*3-3]; // data->pList[data->nCount*3-1] = data->pList[0]; // data->pList[data->nCount*3] = data->pList[0]; // } SET_RECT; rc.top = data->First.y - data->PenThick * 2 - 15; rc.bottom = data->Second.y + data->PenThick * 2 + 15; rc.left = data->First.x - data->PenThick * 2 - 15; rc.right = data->Second.x + data->PenThick * 2 + 15; goto success; } else goto fail; // ³¡Á¡µÎ°³°¡ ¾Æ´Ñ°æ¿ì } else if (count == 2) { if (sw) { // ù´Ü°è if (temp1) delete[]temp1; temp1 = new DPOINT[data->nCount * 3 + 1]; for (int j = 0; j < data->nCount * 3 + 1; j++) temp1[j] = data->pList[j]; tempcount = data->nCount; sw = false; UndoSave(VU_DELETE, i, true); if (data->Bitmap) { delete data->Bitmap; data->Bitmap = NULL; } DataList->Delete(i--); if (data) delete data; data = NULL; } else { // µÎ¹øÂ° if (temp2) delete[]temp2; temp2 = new DPOINT[data->nCount * 3 + 1]; UndoSave(VU_MODIFY, i, false); bool equal = false; for (int j = 0; j < data->nCount * 3 + 1; j++) temp2[j] = data->pList[j]; data->pList = (DPOINT*)HeapReAlloc(GetProcessHeap(), 0, data->pList, sizeof(DPOINT) * ((data->nCount + tempcount + 1) * 3 + 1)); data->pMask = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, data->pMask, ((data->nCount + tempcount + 1) * 3 + 1) % 8 == 0 ? ((data->nCount + tempcount + 1) * 3 + 1) / 8 : ((data->nCount + tempcount + 1) * 3 + 1) / 8 + 1); HeapCompact(GetProcessHeap(), 0); if (first1) { if (first2) { // µÑ´Ù ùÁ¡ÀÎ °æ¿ì for (int j = 0; j < tempcount * 3 + 1; j++) { data->pList[j] = temp1[tempcount * 3 - j]; } equal = pEqual(temp1[0].P(), temp2[0].P()); if (equal) { data->pList[tempcount * 3 + 1] = temp2[1]; data->pList[tempcount * 3 + 2] = temp2[2]; } else { data->pList[tempcount * 3 + 1] = temp1[0]; data->pList[tempcount * 3 + 2] = temp2[0]; } for (int j = 0; j < data->nCount * 3 + 1; j++) { // µÎ Á¢ÇÕÁ¡ÀÌ °°À¸¸é Á¡Àº Çϳª »ý·« data->pList[j + (tempcount + 1) * 3] = temp2[j + 3 * equal]; } } else { for (int j = 0; j < tempcount * 3 + 1; j++) { data->pList[j] = temp1[tempcount * 3 - j]; } equal = pEqual(temp1[0].P(), temp2[data->nCount * 3].P()); if (equal) { data->pList[tempcount * 3 + 1] = temp2[data->nCount * 3 - 1]; data->pList[tempcount * 3 + 2] = temp2[data->nCount * 3 - 2]; } else { data->pList[tempcount * 3 + 1] = temp1[0]; data->pList[tempcount * 3 + 2] = temp2[data->nCount * 3]; } for (int j = 0; j < data->nCount * 3 + 1; j++) { if (data->nCount * 3 - j - 3 * equal < 0) break; // Access ¿¡·¯ ¶§¹®¿¡ ¼öÁ¤ - by monkman (2005.03.29) data->pList[j + (tempcount + 1) * 3] = temp2 [data->nCount * 3 - j - 3 * equal]; } } } else { if (first2) { for (int j = 0; j < tempcount * 3 + 1; j++) { data->pList[j] = temp1[j]; } equal = pEqual(temp1[tempcount * 3].P(), temp2[0].P()); if (equal) { data->pList[tempcount * 3 + 1] = temp2[1]; data->pList[tempcount * 3 + 2] = temp2[2]; } else { data->pList[tempcount * 3 + 1] = temp1[tempcount * 3]; data->pList[tempcount * 3 + 2] = temp2[0]; } for (int j = 0; j < data->nCount * 3 + 1; j++) { data->pList[j + (tempcount + 1) * 3] = temp2[j + 3 * equal]; } } else { // µÑ´Ù ³¡Á¡ for (int j = 0; j < tempcount * 3 + 1; j++) { data->pList[j] = temp1[j]; } equal = pEqual(temp1[tempcount * 3].P(), temp2[data->nCount * 3].P()); if (equal) { data->pList[tempcount * 3 + 1] = temp2[data->nCount * 3 - 1]; data->pList[tempcount * 3 + 2] = temp2[data->nCount * 3 - 2]; } else { data->pList[tempcount * 3 + 1] = temp1[tempcount * 3]; data->pList[tempcount * 3 + 2] = temp2[data->nCount * 3]; } for (int j = 0; j < data->nCount * 3 + 1; j++) { if (data->nCount * 3 - j - 3 * equal < 0) break; // Access ¿¡·¯ ¶§¹®¿¡ ¼öÁ¤ - by monkman (2005.03.29) data->pList[j + (tempcount + 1) * 3] = temp2 [data->nCount * 3 - j - 3 * equal]; } } } data->nCount += (tempcount + 1 - equal); memset(data->pMask, 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); SET_RECT; rc.top = data->First.y - data->PenThick * 2 - 5; rc.bottom = data->Second.y + data->PenThick * 2 + 5; rc.left = data->First.x - data->PenThick * 2 - 5; rc.right = data->Second.x + data->PenThick * 2 + 5; } } } success: // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - ¹ÝÀü °Å¿ïÀÇ º¤ÅÍ ¿µ¿ªÀ» °°ÀÌ ±¸ÇÑ´Ù - by monkman(2005.03.16) for (int i = 0; i < DataList->Count; i++) { tData = (TVecData*)DataList->Items[i]; if (tData->bPatternFill) { // PatternFillÀÌ µÈ data°¡ ÀÖ¾ú´Ù¸é ¿©±â¼­ PatternÀ» ÁØ´Ù MakePatternBitmap(tData); // º¯È­µÈ data->pList¿¡ µû¶ó PatternFillÀ» ´Ù½Ã °è»êÇØÁØ´Ù } } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - ¹ÝÀü °Å¿ïÀÇ º¤ÅÍ ¿µ¿ªÀ» °°ÀÌ ±¸ÇÑ´Ù - by monkman(2005.03.16) if (NVector->bVectorReflectionMode) { GetRealAndReflectionRect(&rc); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- MainImageForm->iMainImage->RectPaint(rc); if (temp1) delete[]temp1; temp1 = NULL; if (temp2) delete []temp2; temp2 = NULL; END_LOG; return; fail: if (NumberErrorExist) ShowMessage(IDS_MESSAGE014); else ShowMessage(IDS_MESSAGE001); // ShowMessage("Choose a couple of edge points"); // ShowMessage("µÎ°³ÀÇ ³¡Á¡À» ¼±ÅÃÇϽʽÿÀ."); if (temp1) delete[]temp1; temp1 = NULL; if (temp2) delete[]temp2; temp2 = NULL; END_LOG; return; } // --------------------------------------------------------------------------- /// ¼±ÅÃµÈ objectÀÇ ¼±ÅÃµÈ Á¡µéÀÇ Æò±ÕÀ» ±¸ÇÔ. void __fastcall TVecDraw::InitAverage(bool bVert, bool bHorz) { BEGIN_LOG(""); TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) TVecData *tData = NULL; TList *DataList = NVector->DataList; int vert = 0, horz = 0, number = 0; RECT rc1, rc2, rc3; bool sw = true; if (!(NVector->bSelected)) goto fail; // ======= ¼±ÅÃµÈ ¿ÀºêÁ§Æ®ÀÇ ¼±ÅÃµÈ Á¡µéÀÇ Æò±Õ ³»±â for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; for (int j = 0; j < data->nCount * 3 + 1; j += 3) { if ((data->pMask[j / 8] >> j % 8) & 0x01) { if (data->bClosed && j == data->nCount * 3) continue; // closed path´Â ÁßøÁ¡ °è»ê¿¡ ¾È³ÖÀ½ horz += data->pList[j].x; vert += data->pList[j].y; number++; } } } if (number < 2) goto fail; horz /= number; vert /= number; // ======== ´Ù½Ã ã¾Æ¼­ Æò±ÕÀ» ´ëÀÔ for (int i = 0; i < DataList->Count; i++) { bool paint = false; data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; UndoSave(VU_MODIFY, i, sw); sw = false; for (int j = 0; j < data->nCount * 3 + 1; j += 3) { if ((data->pMask[j / 8] >> j % 8) & 0x01) { if (bHorz) { if (j != 0) data->pList[j - 1].x += horz - data->pList[j].x; if (j != data->nCount * 3) data->pList[j + 1].x += horz - data->pList[j].x; data->pList[j].x = horz; } if (bVert) { if (j != 0) data->pList[j - 1].y += vert - data->pList[j].y; if (j != data->nCount * 3) data->pList[j + 1].y += vert - data->pList[j].y; data->pList[j].y = vert; } paint = true; } } if (!paint) continue; rc1.top = data->First.y - data->PenThick * 2 - 5; rc1.bottom = data->Second.y + data->PenThick * 2 + 5; rc1.left = data->First.x - data->PenThick * 2 - 5; rc1.right = data->Second.x + data->PenThick * 2 + 5; SET_RECT; rc2.top = data->First.y - data->PenThick * 2 - 5; rc2.bottom = data->Second.y + data->PenThick * 2 + 5; rc2.left = data->First.x - data->PenThick * 2 - 5; rc2.right = data->Second.x + data->PenThick * 2 + 5; UnionRect(&rc3, &rc1, &rc2); // µÎ rect¸¦ Æ÷ÇÔÇÏ´Â °¡Àå ÀÛÀº rect rc3 // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - ¹ÝÀü °Å¿ïÀÇ º¤ÅÍ ¿µ¿ªÀ» °°ÀÌ ±¸ÇÑ´Ù - by monkman(2005.03.16) for (int i = 0; i < DataList->Count; i++) { tData = (TVecData*)DataList->Items[i]; if (tData->bPatternFill) { // PatternFillÀÌ µÈ data°¡ ÀÖ¾ú´Ù¸é ¿©±â¼­ PatternÀ» ÁØ´Ù MakePatternBitmap(tData); // º¯È­µÈ data->pList¿¡ µû¶ó PatternFillÀ» ´Ù½Ã °è»êÇØÁØ´Ù } } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - ¹ÝÀü °Å¿ïÀÇ º¤ÅÍ ¿µ¿ªÀ» °°ÀÌ ±¸ÇÑ´Ù - by monkman(2005.03.16) if (NVector->bVectorReflectionMode) { GetRealAndReflectionRect(&rc3); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- MainImageForm->iMainImage->RectPaint(rc3); } success: END_LOG; return; fail: ShowMessage(IDS_MESSAGE002); // ShowMessage("You must select above two points"); // ShowMessage("À§ÀÇ µÎ°³ÀÇ Æ÷ÀÎÆ®¸¦ ¼±ÅÃÇØ¾ß ÇÕ´Ï´Ù."); END_LOG; return; } // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // ------- Point Editing Part ----------------------------------------- // --------------------------------------------------------------------------- /// ¼±ÅÃµÈ Á¡»èÁ¦ void __fastcall TVecDraw::DeletePoint(int X, int Y) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) double MinDist = MaxInt, CurDist = MaxInt; int MinIndex = -1; RECT rc; if ((ptNumber % 3) != 0) { END_LOG; return; // Á¶ÀýÁ¡ÀÌ ¾Æ´Ñ ½ÇÁ¦ Á¡À» Áö¿ì´Â°Í~! } for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->Kind != V_LINE && data->Kind != V_CURVE) continue; // Line°ú curve¿¡¼­¸¸ Point Edit °¡´É if (data->nCount == 1) continue; // 1°³¸¸ ³²¾ÒÀ»¶§´Â Áö¿ìÁö ¸»ÀÚ if (data->Kind == V_LINE || data->Kind == V_CURVE) { // Á÷¼±, °î¼±¾ÈÀÇ ¿µ¿ª¿¡ ÀÖ´ÂÁö °Ë»ç // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // Vector Line ¼±Åà ±â´É - ±âÁ¸ÀÇ PointOnCurvePath ÇÔ¼ö¸¦ ´õ Á¤¹ÐÇÏ°Ô ¼öÁ¤ - by monkman (2005.03.21) CurDist = PointOnCurvePath(data, X, Y); if (CurDist >= 0 && MinDist >= CurDist) { MinIndex = i; MinDist = CurDist; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } } // ±ÙÁ¢Á¡À» °Ë»öÇÏ¿© ÇѰ³ÀÇ Object¿¡¼­¸¸ Áö¿ìµµ·Ï ¼öÁ¤ - by monkman (2009.04.02) if (MinIndex >= 0) { data = (TVecData*)DataList->Items[MinIndex]; UndoSave(VU_MODIFY, MinIndex); if (ptNumber == 0) { // ùÁ¡À» Áö¿ï°æ¿ì if (data->bClosed) { data->pList[data->nCount * 3 - 1] = data->pList[2]; for (int i = 0; i < data->nCount * 3 - 2; i++) data->pList[i] = data->pList[i + 3]; } else { for (int i = 0; i < data->nCount * 3 - 2; i++) data->pList[i] = data->pList[i + 3]; // ÇÑÁ¡ÀÌ Áö¿öÁö¹Ç·Î Á¶ÀýÁ¡2°³¿Í Á¡1°³¸¦ ¶¯±ä´Ù } } else { // ³ª¸ÓÁö °æ¿ì for (int i = ptNumber - 1; i < data->nCount * 3 - 2; i++) { data->pList[i] = data->pList[i + 3]; // ÇÑÁ¡ÀÌ Áö¿öÁö¹Ç·Î Á¶ÀýÁ¡2°³¿Í Á¡1°³¸¦ ¶¯±ä´Ù } } 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); rc.top = data->First.y - data->PenThick; rc.bottom = data->Second.y + data->PenThick; rc.left = data->First.x - data->PenThick; rc.right = data->Second.x + data->PenThick; SET_RECT_ORIGIN; if (data->bPatternFill) MakePatternBitmap(data); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - ¹ÝÀü °Å¿ïÀÇ º¤ÅÍ ¿µ¿ªÀ» °°ÀÌ ±¸ÇÑ´Ù - by monkman(2005.03.16) if (NVector->bVectorReflectionMode) { GetRealAndReflectionRect(&rc); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- if (data->bMotive) { TRect trect; GetRectForMouseMove(data, trect); rc.top = rc.top - trect.Height() / 2; rc.left = rc.left - trect.Width() / 2; rc.bottom = rc.bottom + trect.Height() / 2; rc.right = rc.right + trect.Width() / 2; } MainImageForm->iMainImage->RectPaint(rc); } ptNumber = -1; END_LOG; } // --------------------------------------------------------------------------- /// X, Y À§Ä¡¿¡ Vector data°¡ ÀÖ°í, X, Y°¡ CurveÀ§¿¡ ÀÖÀ¸¸é data¿¡ Á¡ Ãß°¡. void __fastcall TVecDraw::AddPoint(int X, int Y) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) RECT rc; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->Kind != V_LINE && data->Kind != V_CURVE) continue; // Line°ú curve¿¡¼­¸¸ Point Edit °¡´É if (PointOnCurvePath(data, X, Y) < 0) goto fail; // ¿ì¼± ÂïÀº Á¡ÀÌ curveÀ§¿¡ ÀÖ´ÂÁö.. UndoSave(VU_MODIFY, i); if (AddPointInVecData(data, X, Y) < 0){ goto fail; } rc.top = data->First.y - data->PenThick; rc.bottom = data->Second.y + data->PenThick; rc.left = data->First.x - data->PenThick; rc.right = data->Second.x + data->PenThick; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - ¹ÝÀü °Å¿ïÀÇ º¤ÅÍ ¿µ¿ªÀ» °°ÀÌ ±¸ÇÑ´Ù - by monkman(2005.03.16) if (NVector->bVectorReflectionMode) { GetRealAndReflectionRect(&rc); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- MainImageForm->iMainImage->RectPaint(rc); END_LOG; return; } fail: END_LOG; return; } // --------------------------------------------------------------------------- /// data¿¡ Á¡À» Ãß°¡ (X, Y¿Í °¡Àå °¡±î¿î À§Ä¡¸¦ ã¾Æ¼­ Ãß°¡ÇÔ) int __fastcall TVecDraw::AddPointInVecData(TVecData *data, double X, double Y) { BEGIN_LOG(""); HRGN rgn = NULL; HDC dcDst = MainImageForm->iMainImage->Canvas->Handle; HPEN hOldPen = NULL, hPen = NULL; bool bResult = false; int CurveNumber, seg1, seg2; // ÇÑ Object¾ÈÀÇ ¸î¹øÂ° curveÀÎÁö.. POINT ptemp[4]; DPOINT pdiv[101]; // pdiv : 10°³¾¿À¸·Î ³ª´©´Â Á¡µé double distance[101], tempdist, t; int nFillMode; int incount = 0; int rtnNum = -1; nFillMode = GetPolyFillMode(dcDst); SetPolyFillMode(dcDst, WINDING); // hPen = CreatePen(PS_SOLID, data->PenThick>5 ? data->PenThick : 5, RGB(0,0,0)); // hOldPen = (HPEN)SelectObject(dcDst, hPen); int findCurve[5] = { -1, -1, -1, -1, -1 }; int curvecount = 0; /* for (int j = 0; j < data->nCount; j++) { // ¸î¹ø¤Š curve¿¡ ¼ÓÇÑ Á¡ÀÎÁö¸¦ ã´Â °úÁ¤ ptemp[0] = data->pList[j*3].P(); ptemp[1] = data->pList[j*3+1].P(); ptemp[2] = data->pList[j*3+2].P(); ptemp[3] = data->pList[j*3+3].P(); HPEN oldPen, hPen; hPen = CreatePen(psSolid, 1, BLACK_PEN); oldPen = (HPEN)SelectObject(dcDst, hPen); BeginPath(dcDst); PolyBezier (dcDst, ptemp, 4); EndPath(dcDst); WidenPath(dcDst); rgn = PathToRegion(dcDst); SelectObject(dcDst, oldPen); if (PtInRegion(rgn, X, Y)) { bResult = true; findCurve[curvecount] = j; curvecount++; } DeleteObject(rgn); rgn = NULL; } */ int penWidth = 1; bResult = false; while (curvecount < 1) { hPen = CreatePen(psSolid, penWidth, BLACK_PEN); hOldPen = (HPEN)SelectObject(dcDst, hPen); for (int j = 0; j < data->nCount; j++) { // ¸î¹ø¤Š curve¿¡ ¼ÓÇÑ Á¡ÀÎÁö¸¦ ã´Â °úÁ¤ ptemp[0] = data->pList[j * 3].P(); ptemp[1] = data->pList[j * 3 + 1].P(); ptemp[2] = data->pList[j * 3 + 2].P(); ptemp[3] = data->pList[j * 3 + 3].P(); BeginPath(dcDst); PolyBezier(dcDst, ptemp, 4); EndPath(dcDst); WidenPath(dcDst); rgn = PathToRegion(dcDst); if (PtInRegion(rgn, X, Y)) { bResult = true; findCurve[curvecount] = j; curvecount++; } DeleteObject(rgn); rgn = NULL; } DeleteObject(SelectObject(dcDst, hOldPen)); hOldPen = NULL; hPen = NULL; penWidth++; if (penWidth > 4 && curvecount == 0) curvecount = 1; } SetPolyFillMode(dcDst, nFillMode); if (!bResult) goto fail; incount = 0; if (curvecount == 1) { CurveNumber = findCurve[0]; } else { double minDistance = 99999; int minIndex = -1; if (curvecount > 5) curvecount = 5; bool inX[5]; bool inY[5]; CurveNumber = -1; for (int i = 0; i < curvecount; i++) { inX[i] = false; inY[i] = false; if ((data->pList[findCurve[i] * 3].x <= X && data->pList [findCurve[i] * 3 + 3].x >= X) || (data->pList[findCurve[i] * 3].x >= X && data->pList [findCurve[i] * 3 + 3].x <= X)) { inX[i] = true; } if ((data->pList[findCurve[i] * 3].y <= Y && data->pList [findCurve[i] * 3 + 3].y >= Y) || (data->pList[findCurve[i] * 3].y >= Y && data->pList [findCurve[i] * 3 + 3].y <= Y)) { inY[i] = true; } if (inX[i] && inY[i]) { CurveNumber = findCurve[i]; incount++; // break; } } if (incount > 1) { for (int i = 0; i < curvecount; i++) { if (inX[i] && inY[i]) { double distance, distanceP, distanceN; distanceP = sqrt((X - data->pList[findCurve[i] * 3].x) * (X - data->pList[findCurve[i] * 3].x) + (Y - data->pList[findCurve[i] * 3].y) * (Y - data->pList[findCurve[i] * 3].y)); distanceN = sqrt((X - data->pList[findCurve[i] * 3 + 3].x) * (X - data->pList[findCurve[i] * 3 + 3].x) + (Y - data->pList[findCurve[i] * 3 + 3].y) * (Y - data->pList[findCurve[i] * 3 + 3].y)); if (distanceP > distanceN) { distance = distanceN; } else { distance = distanceP; } if (minDistance > distance) { minDistance = distance; minIndex = findCurve[i]; } } } CurveNumber = minIndex; } if (CurveNumber == -1) { int inXCount = 0; for (int i = 0; i < curvecount; i++) { if (inX[i]) { CurveNumber = findCurve[i]; break; } if (inY[i]) { CurveNumber = findCurve[i]; break; } } } } ptemp[0] = data->pList[CurveNumber * 3].P(); ptemp[1] = data->pList[CurveNumber * 3 + 1].P(); ptemp[2] = data->pList[CurveNumber * 3 + 2].P(); ptemp[3] = data->pList[CurveNumber * 3 + 3].P(); for (int k = 0; k <= 100; k++) { t = double(k) / 100; pdiv[k].x = (1 - t) * (1 - t) * (1 - t) * ptemp[0].x + 3 * (1 - t) * (1 - t) * t * ptemp[1].x + 3 * (1 - t) * t * t * ptemp[2] .x + t * t * t * ptemp[3].x; pdiv[k].y = (1 - t) * (1 - t) * (1 - t) * ptemp[0].y + 3 * (1 - t) * (1 - t) * t * ptemp[1].y + 3 * (1 - t) * t * t * ptemp[2] .y + t * t * t * ptemp[3].y; distance[k] = sqrt((pdiv[k].x - X) * (pdiv[k].x - X) + (pdiv[k].y - Y) * (pdiv[k].y - Y)); if (k == 0) { tempdist = distance[k]; seg1 = k; } else { // °Å¸®°¡ ÃÖ¼ÒÀÎÁ¡À» ã´Â´Ù if (tempdist > distance[k]) { tempdist = distance[k]; seg1 = k; } } } if (seg1 != 0 && seg1 != 100) { // P------O--P---------P ÀÌ·¸°Ô ÀÖ´ÂÁö if (distance[seg1 - 1] < distance[seg1 + 1]) { // P---------P---O-----P ÀÌ·¸°Ô ÀÖ´ÂÁö ÆÇ´Ü seg1--; // ÀüÀÚÀ̸é ÀÌÀü Á¡À» ¼±ÅÃÇØ ÁØ´Ù(Á¤È®ÇÑ t°ªÀ» ÆÇ´ÜÇϱâ À§ÇØ) } } else if (seg1 == 100) seg1--; for (int k = 0; k <= 100; k++) { t = (double(seg1) / 100) + (double(k) / 1000); pdiv[k].x = (1 - t) * (1 - t) * (1 - t) * ptemp[0].x + 3 * (1 - t) * (1 - t) * t * ptemp[1].x + 3 * (1 - t) * t * t * ptemp[2] .x + t * t * t * ptemp[3].x; pdiv[k].y = (1 - t) * (1 - t) * (1 - t) * ptemp[0].y + 3 * (1 - t) * (1 - t) * t * ptemp[1].y + 3 * (1 - t) * t * t * ptemp[2] .y + t * t * t * ptemp[3].y; distance[k] = sqrt((pdiv[k].x - X) * (pdiv[k].x - X) + (pdiv[k].y - Y) * (pdiv[k].y - Y)); if (k == 0) { tempdist = distance[k]; seg2 = k; } else { // °Å¸®°¡ ÃÖ¼ÒÀÎÁ¡À» ã´Â´Ù if (tempdist > distance[k]) { tempdist = distance[k]; seg2 = k; } } } t = double(seg1) / 100+double(seg2) / 1000; // ÃÖÁ¾ÀûÀÎ °ª if (t == 0) { rtnNum = CurveNumber; } else if (t == 1) { rtnNum = CurveNumber + 1; } else { 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); if (data->pList == NULL) goto fail; HeapCompact(GetProcessHeap(), 0); for (int l = data->nCount * 3 - 3; l > CurveNumber * 3 + 1; l--) { data->pList[l + 3] = data->pList[l]; } if (ptemp[0].x == ptemp[1].x && ptemp[0].y == ptemp[1].y && ptemp[2] .x == ptemp[3].x && ptemp[2].y == ptemp[3].y) { // ÀâÈù ¼±ÀÌ Á÷¼±ÀÎ °æ¿ì data->pList[CurveNumber * 3 + 3].x = (1 - t) * (1 - t) * (1 - t) * ptemp[0].x + 3 * (1 - t) * (1 - t) * t * ptemp[1].x + 3 * (1 - t) * t * t * ptemp[2].x + t * t * t * ptemp[3].x; data->pList[CurveNumber * 3 + 3].y = (1 - t) * (1 - t) * (1 - t) * ptemp[0].y + 3 * (1 - t) * (1 - t) * t * ptemp[1].y + 3 * (1 - t) * t * t * ptemp[2].y + t * t * t * ptemp[3].y; data->pList[CurveNumber * 3 + 2].x = data->pList[CurveNumber * 3 + 3].x; data->pList[CurveNumber * 3 + 2].y = data->pList[CurveNumber * 3 + 3].y; data->pList[CurveNumber * 3 + 4].x = data->pList[CurveNumber * 3 + 3].x; data->pList[CurveNumber * 3 + 4].y = data->pList[CurveNumber * 3 + 3].y; } else { // °î¼±ÀÎ °æ¿ì // »õ·Î »ý±â´Â Á¡ data->pList[CurveNumber * 3 + 3].x = (1 - t) * (1 - t) * (1 - t) * ptemp[0].x + 3 * (1 - t) * (1 - t) * t * ptemp[1].x + 3 * (1 - t) * t * t * ptemp[2].x + t * t * t * ptemp[3].x; data->pList[CurveNumber * 3 + 3].y = (1 - t) * (1 - t) * (1 - t) * ptemp[0].y + 3 * (1 - t) * (1 - t) * t * ptemp[1].y + 3 * (1 - t) * t * t * ptemp[2].y + t * t * t * ptemp[3].y; // »õ·Î »ý±â´Â Á¡ÀÇ Á¶ÀýÁ¡ 2°³ data->pList[CurveNumber * 3 + 2].x = (1 - t) * (1 - t) * ptemp[0].x + 2 * t * (1 - t) * ptemp[1].x + t * t * ptemp[2].x; data->pList[CurveNumber * 3 + 2].y = (1 - t) * (1 - t) * ptemp[0].y + 2 * t * (1 - t) * ptemp[1].y + t * t * ptemp[2].y; data->pList[CurveNumber * 3 + 4].x = (1 - t) * (1 - t) * ptemp[1].x + 2 * t * (1 - t) * ptemp[2].x + t * t * ptemp[3].x; data->pList[CurveNumber * 3 + 4].y = (1 - t) * (1 - t) * ptemp[1].y + 2 * t * (1 - t) * ptemp[2].y + t * t * ptemp[3].y; // ¾ç¿·ÀÇ Á¶ÀýÁ¡ÀÇ º¯È­ data->pList[CurveNumber * 3 + 1].x = (1 - t) * ptemp[0].x + t * ptemp[1] .x; data->pList[CurveNumber * 3 + 1].y = (1 - t) * ptemp[0].y + t * ptemp[1] .y; data->pList[CurveNumber * 3 + 5].x = (1 - t) * ptemp[2].x + t * ptemp[3] .x; data->pList[CurveNumber * 3 + 5].y = (1 - t) * ptemp[2].y + t * ptemp[3] .y; } if (data->pMask) { memset(data->pMask, 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); // »õ·Î »ý±ä Á¡ÀÇ Á¶ÀýÁ¡À» º¸¿©ÁÖµµ·Ï (DrawSelectedLine¿¡¼­) data->pMask[(CurveNumber * 3 + 3) / 8] |= (0x01 << ((CurveNumber * 3 + 3) % 8)); } rtnNum = CurveNumber + 1; } END_LOG; return rtnNum; fail: END_LOG; return -1; } // --------------------------------------------------------------------------- /// ¼±ÅÃµÈ objectÀÇ X,Y À§Ä¡ÀÇ Á¡À» ÀÚ¸¥´Ù. void __fastcall TVecDraw::Knife(int X, int Y) { BEGIN_LOG(""); // RECT rc; TList *DataList = NVector->DataList; double MinDist = MaxInt, CurDist = MaxInt; int MinIndex = -1; TVecData *data = NULL; if ((ptNumber % 3) != 0) { END_LOG; return; // Á¶ÀýÁ¡ÀÌ ¾Æ´Ñ ½ÇÁ¦ Á¡À» Áö¿ì´Â°Í~! } // ¿ÀºêÁ§Æ® ¿©·¯°³°¡ ¼±ÅõǾúÀ» ¶§ ÀÚ¸£°íÀÚÇÏ´Â ¿ÀºêÁ§Æ®°¡ ¾î¶²°ÍÀÎÁö ãÀ½ // ãÀº ¿ÀºêÁ§Æ® : MinIndex¹øÂ° Item for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->Kind == V_LINE || data->Kind == V_CURVE) { // Á÷¼±, °î¼±¾ÈÀÇ ¿µ¿ª¿¡ ÀÖ´ÂÁö °Ë»ç // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // Vector Line ¼±Åà ±â´É - ±âÁ¸ÀÇ PointOnCurvePath ÇÔ¼ö¸¦ ´õ Á¤¹ÐÇÏ°Ô ¼öÁ¤ - by monkman (2005.03.21) CurDist = PointOnCurvePath(data, X, Y); if (CurDist >= 0 && MinDist >= CurDist) { MinIndex = i; MinDist = CurDist; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } } if (MinIndex >= 0) { data = (TVecData*)DataList->Items[MinIndex]; if (data->Kind != V_LINE && data->Kind != V_CURVE) { END_LOG; return; // Line°ú curve¿¡¼­¸¸ Point Edit °¡´É } // -->by linuxjun for CurvedVectorText if (data->ParentTextBox) { END_LOG; return; } // <--by linuxjun for CurvedVectorText if (data->bClosed) { UndoSave(VU_MODIFY, MinIndex); KnifeInVecData(data, ptNumber); ptNumber = 0; if (data->pMask) { memset(data->pMask, 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); // Point MaskÃʱâÈ­ data->pMask[0] |= 0x01; // ù¹øÂ° point¸¦ Ȱ¼ºÈ­½ÃÄÑÁÜ } } else { if (ptNumber == 0 || ptNumber == data->nCount * 3) { // open path¿¡¼­ ùÁ¡°ú ³¡Á¡Àº ¾ÈµÇ~ ShowMessage(IDS_MESSAGE003); // ShowMessage("Select neither First nor Last Point"); // ShowMessage("ù¹ø¤Š¿Í ¸¶Áö¸· Æ÷ÀÎÆ®¸¦ ¼±ÅÃÇÏ¸é ¾È µË´Ï´Ù."); END_LOG; return; } UndoSave(VU_MODIFY, MinIndex, true); TVecData *newData = NULL; newData = KnifeInVecData(data, ptNumber); if (newData) DataList->Insert(MinIndex + 1, newData); UndoSave(VU_CREATE, MinIndex + 1, false); } } // MainImageForm->iMainImage->RectPaint(rc); END_LOG; } // --------------------------------------------------------------------------- /// ptNum¹øÂ° Á¡¿¡¼­ data¸¦ ÀÚ¸¥´Ù. TVecData *__fastcall TVecDraw::KnifeInVecData(TVecData *data, int ptNum) { BEGIN_LOG(""); TVecData *newData = NULL; DPOINT *pPoints = NULL; // pPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) if (data->bClosed) { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new DPOINT[(data->nCount + 1) * 3 + 1]; } else { pPoints = new DPOINT[data->nCount * 3 + 1]; } for (int i = 0; i < data->nCount * 3 - ptNum; i++) pPoints[i] = data->pList[ptNum + i]; for (int i = data->nCount * 3 - ptNum; i < data->nCount * 3 + 1; i++) pPoints[i] = data->pList[i - data->nCount * 3 + ptNum]; for (int i = 0; i < data->nCount * 3 + 1; i++) data->pList[i] = pPoints[i]; data->bClosed = false; if (pPoints) delete[]pPoints; pPoints = NULL; } else { newData = new TVecData(MainImageForm->Number); newData->Copy(data); // newData->GroupIndex &= 0xfffffe00; // ¹øÈ£ ÁöÁ¤ GroupIndex´Â copy¾ÈµÇ°Ô.. newData->GroupIndex -= (data->GroupIndex % 10000) & 0x000001ff; // ¹øÈ£ ÁöÁ¤ GroupIndex´Â copy¾ÈµÇ°Ô.. by siuaa 080501 newData->nCount = data->nCount - ptNum / 3; for (int j = 0; j < newData->nCount * 3 + 1; j++) { newData->pList[j] = newData->pList[j + ptNum]; } newData->pList = (DPOINT*)HeapReAlloc(GetProcessHeap(), 0, newData->pList, sizeof(DPOINT) * (newData->nCount * 3 + 1)); newData->pMask = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, newData->pMask, (newData->nCount * 3 + 1) % 8 == 0 ? (newData->nCount * 3 + 1) / 8 : (newData->nCount * 3 + 1) / 8 + 1); data->nCount = ptNum / 3; 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); SetRect(newData); SetRect(data); if (newData->bPatternFill) MakePatternBitmap(newData); if (data->bPatternFill) MakePatternBitmap(data); } pPoints = NULL; END_LOG; return newData; } // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // ------- File Handle Part -------------------------------------------- // --------------------------------------------------------------------------- /** file¿¡¼­ load * Version : 140 - TextBox¸¦ ³ÖÀºÈÄ º¯°æ * Version : 150 - Gdiplus Àû¿ë ÈÄ º¯°æ 2005 Vector Upgrade Shin 0317 * Version : 160 - GradientFill Ãß°¡ & group index ±¸Á¶ ¼öÁ¤ ÈÄ º¯°æ * Version : 170 - Motive ObjectÃß°¡ * Version : 180 - Unicode Ãß°¡ * Version : 181 - Arrow ¼öÁ¤ * Version : 182 - Line Arrow ¼öÁ¤ */ bool __fastcall TVecDraw::LoadFromFile(HANDLE fh, TList *_DataList, int nInstNum) { BEGIN_LOG(""); // MainImageForm¿¡ ÀÖ´Â DataList ¸»°í ´Ù¸¥ ¸®½ºÆ®µµ ¹ÞÀ» ¼ö ÀÖµµ·Ï ó¸® TList *DataList = NULL; TVecData *data = NULL, *childdata = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) POINT *pPoints = NULL; // pPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) if (_DataList) DataList = _DataList; else DataList = NVector->DataList; if (nInstNum < 0) nInstNum = MainImageForm->Number; int Version, count; int existindex = 0, index = 0, existcount; // ±âÁ¸¿¡ Á¸ÀçÇÏ´Â indexÆÇº°, »ðÀÔÇÒ index number, ±âÁ¸ÀÇ objectÀÇ °¹¼ö int srcMaxGroupIndex = 0; // load¸¦ ÇØ¿À´Â objectÁß °¡Àå Å« index¸¦ ÀúÀå by siuaa 080501 DWORD dwRead; bool sw = true; int linecount, wordcount, lineheight; if (!ReadFile(fh, &Version, sizeof(int), &dwRead, NULL)) goto fail; // Version : 140 - TextBox¸¦ ³ÖÀºÈÄ º¯°æ // Version : 150 - Gdiplus Àû¿ë ÈÄ º¯°æ 2005 Vector Upgrade Shin 0317 // Version : 160 - GradientFill Ãß°¡ & group index ±¸Á¶ ¼öÁ¤ ÈÄ º¯°æ // Version : 170 - Motive ObjectÃß°¡ // Version : 180 - UniCode ó¸® // Version : 181 - Arrow ¼öÁ¤ // Version : 182 - Line Arrow ¼öÁ¤ if (Version != 100 && Version != 110 && Version != 120 && Version != 130 && Version != 140 && Version != 150 && Version != 160 && Version != 170 && Version != 180 && Version != 181 && Version != 182) goto fail; if (!ReadFile(fh, &count, sizeof(int), &dwRead, NULL)) goto fail; existcount = DataList->Count; for (int i = 0; i < count; i++) { if ((data = new TVecData(nInstNum)) == NULL) goto fail; if (!ReadFile(fh, &data->Kind, sizeof(EVecKind), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->First, sizeof(POINT), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->Second, sizeof(POINT), &dwRead, NULL)) goto fail; // 2005 Vector Upgrade Shin 0317 if (Version >= 150) { if (!ReadFile(fh, &data->bAntialiasing, sizeof(bool), &dwRead, NULL)) goto fail; } else { data->bAntialiasing = false; } int tempThick; switch(data->Kind) { case V_LINE: case V_CURVE: if (!ReadFile(fh, &data->PenStyle, sizeof(EPenStyle), &dwRead, NULL)) goto fail; // Version 150 Ãß°¡ if (Version >= 150) { if (!ReadFile(fh, &data->PenThick, sizeof(double), &dwRead, NULL)) goto fail; } else { if (!ReadFile(fh, &tempThick, sizeof(int), &dwRead, NULL)) goto fail; data->PenThick = (double)tempThick; } // if (!ReadFile(fh, &data->PenThick, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->nCount, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->bRound, sizeof(bool), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->bFill, sizeof(bool), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->bWinding, sizeof(bool), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->Color, sizeof(TColor), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->Brush, sizeof(TColor), &dwRead, NULL)) goto fail; // ===7.41, Version 110 Ãß°¡ if (Version >= 110) { if (!ReadFile(fh, &data->bClosed, sizeof(bool), &dwRead, NULL)) goto fail; // if (!ReadFile(fh, &data->GroupIndex, sizeof(int), &dwRead, NULL)) goto fail; if (Version < 160) // 9.2 ÀÌÇÏ ¹öÀüÀÇ groupÀ» ÀÐ¾î ¿À±â À§ÇØ { int temp; if (!ReadFile(fh, &temp, sizeof(int), &dwRead, NULL)) goto fail; int tempIndex = 0; for (int i = 0; i < 10; i++) // ¹øÈ£°¡ ÀÖ´Â group index¸¦ ÀÐÀ½ { if ((temp & (1 << i))) tempIndex += (1 << i); } for (int i = 10; i < 32; i++) // ¹øÈ£°¡ ¾ø´Â group index¸¦ ÀÐÀ½ { if ((temp & (1 << i))) { tempIndex += ((i - 9) * 10000); break; } } data->GroupIndex = tempIndex; if (srcMaxGroupIndex < tempIndex / 10000) srcMaxGroupIndex = tempIndex / 10000; } else { if (!ReadFile(fh, &data->GroupIndex, sizeof(int), &dwRead, NULL)) goto fail; if (srcMaxGroupIndex < data->GroupIndex / 10000) srcMaxGroupIndex = data->GroupIndex / 10000; } } // ========================= 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); if (Version <= 110) { // 7.41ÀÌÇÏ¿¡¼­´Â DPOINT¸¦ »ç¿ëÇÏÁö ¾Ê¾Ò´Ù if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new POINT[(data->nCount + 1) * 3 + 1]; } else { pPoints = new POINT[data->nCount * 3 + 1]; } if (!ReadFile(fh, pPoints, sizeof(POINT) * (data->nCount * 3 + 1), &dwRead, NULL)) goto fail; for (int j = 0; j < data->nCount * 3 + 1; j++) data->pList[j].DPoint(pPoints[j]); if (pPoints) delete[]pPoints; pPoints = NULL; } else { if (!ReadFile(fh, data->pList, sizeof(DPOINT) * (data->nCount * 3 + 1), &dwRead, NULL)) goto fail; } // ÃʱâÈ­ memset(data->pMask, 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); if (!ReadFile(fh, &data->bPatternFill, sizeof(bool), &dwRead, NULL)) goto fail; if (data->bPatternFill) { int w, h; if (!ReadFile(fh, &data->PatternAngle, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->PatternAdjustX, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->PatternAdjustY, sizeof(int), &dwRead, NULL)) goto fail; // ====7.43, Version 130 Ãß°¡ Added by maxleo21c (2004/05/11) if (Version >= 130) { if (!ReadFile(fh, &data->RatioX, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->RatioY, sizeof(int), &dwRead, NULL)) goto fail; } // ========================== if (!ReadFile(fh, &w, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &h, sizeof(int), &dwRead, NULL)) goto fail; data->TBitmapSource = new TTexpiaBitmap; if (!data->TBitmapSource->Create(w, h, 24)) goto fail; data->TBitmapSource->LoadFromTexpiaFile(fh, cmZLib); if (data->Color == data->Brush) { double doublebrush = 0.0; // Pattern Fill¿¡¼­ °°Àº PatternÀÎÁö¸¦ identifyÇϱâ À§Çؼ­ Brush¿¡ Áß°£ color¸¦ Áý¾î³Ö´Â´Ù for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { doublebrush = doublebrush +double (data->TBitmapSource->GetPixelColor(x, y)) / (w * h); } } data->Brush = TColor(int(doublebrush)); } MakePatternBitmap(data); } // Version 150 Ãß°¡ if (Version >= 150) { if (!ReadFile(fh, data->DashValues, sizeof(double) * 7, &dwRead, NULL)) goto fail; int TempCapStyle[2] = {0, 0}; if (!ReadFile(fh, TempCapStyle, sizeof(int) * 2, &dwRead, NULL)) goto fail; data->CapStyle[0] = TempCapStyle[0]; data->CapStyle[1] = TempCapStyle[1]; if (Version >= 181){ if(Version == 181 && data->CapStyle[0] == 2 && data->ArrowCap){ data->ArrowCap->bShowArrowBoth = true; data->ArrowCap->LineCapWidthScale = 1; data->ArrowCap->LineCapWidth = 5; data->ArrowCap->LineCapHeight = 5; data->ArrowCap->LineCapLine = 1; } else if (data->CapStyle[0] && data->ArrowCap){ if (!data->ArrowCap->LoadFromFile(fh)) goto fail; if (Version >= 182) { if (!ReadFile(fh, &data->ArrowCap->LineCapLine, sizeof(double), &dwRead, NULL)) goto fail; } // if (!ReadFile(fh, &data->ArrowCap->bFillLineCap, sizeof(bool), &dwRead, NULL)) // goto fail; // if (!ReadFile(fh, &data->ArrowCap->bShowArrowBoth, sizeof(bool), &dwRead, NULL)) // goto fail; // if (!ReadFile(fh, &data->ArrowCap->LineCapWidthScale, sizeof(double), &dwRead, NULL)) // goto fail; // if (!ReadFile(fh, &data->ArrowCap->LineCapWidth, sizeof(double), &dwRead, NULL)) // goto fail; // if (!ReadFile(fh, &data->ArrowCap->LineCapHeight, sizeof(double), &dwRead, NULL)) // goto fail; } } else if (data->CapStyle[0] && data->ArrowCap){ data->ArrowCap->SetDefault(); } } // Version 160 Ãß°¡ if (Version >= 160) { if (!ReadFile(fh, &data->bGradientFill, sizeof(int), &dwRead, NULL)) goto fail; if (data->bGradientFill) { if (!ReadFile(fh, &data->gradientItem, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->gAngle, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->gradientColorCount, sizeof(int), &dwRead, NULL)) goto fail; int count = data->gradientColorCount; data->gradientColors = new RGBQUAD[count]; if (!ReadFile(fh, data->gradientColors, sizeof(RGBQUAD) * count, &dwRead, NULL)) goto fail; } } // Version 170 Ãß°¡ 090304 if (Version >= 170) { if (!ReadFile(fh, &data->bMotive, sizeof(int), &dwRead, NULL)) goto fail; if (data->bMotive) { if (!ReadFile(fh, &data->mode, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->gap, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->motivecount, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->proportion, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->childwidth, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->childheight, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->centerX, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->centerY, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->ChildCount, sizeof(int), &dwRead, NULL)) goto fail; for (int i = 0; i < data->ChildCount; i++) { TVecData *childdata = new TVecData(nInstNum); LoadVectorFile(fh, data, childdata, Version); } } } break; case V_RECT: case V_ELLIPSE: if (!ReadFile(fh, &data->PenStyle, sizeof(EPenStyle), &dwRead, NULL)) goto fail; // Version 150 Ãß°¡ if (Version >= 150) { if (!ReadFile(fh, &data->PenThick, sizeof(double), &dwRead, NULL)) goto fail; } else { if (!ReadFile(fh, &tempThick, sizeof(int), &dwRead, NULL)) goto fail; data->PenThick = (double)tempThick; } // if (!ReadFile(fh, &data->PenThick, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->bRound, sizeof(bool), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->bFill, sizeof(bool), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->bWinding, sizeof(bool), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->Color, sizeof(TColor), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->Brush, sizeof(TColor), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->bPatternFill, sizeof(bool), &dwRead, NULL)) goto fail; if (data->bPatternFill) LoadObjectBitmap(fh, data); // Version 150 Ãß°¡ if (Version >= 150) { if (!ReadFile(fh, data->DashValues, sizeof(double) * 7, &dwRead, NULL)) goto fail; int TempCapStyle[2] = {0, 0}; if (!ReadFile(fh, TempCapStyle, sizeof(int) * 2, &dwRead, NULL)) goto fail; data->CapStyle[0] = TempCapStyle[0]; data->CapStyle[1] = TempCapStyle[1]; } // Version 160 Ãß°¡ if (Version >= 160) { if (!ReadFile(fh, &data->bGradientFill, sizeof(int), &dwRead, NULL)) goto fail; if (data->bGradientFill) { if (!ReadFile(fh, &data->gradientItem, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->gAngle, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->gradientColorCount, sizeof(int), &dwRead, NULL)) goto fail; int count = data->gradientColorCount; data->gradientColors = new RGBQUAD[count]; if (!ReadFile(fh, data->gradientColors, sizeof(RGBQUAD) * count, &dwRead, NULL)) goto fail; } } // Version 170 Ãß°¡ 090304 if (Version >= 170) { if (!ReadFile(fh, &data->bMotive, sizeof(int), &dwRead, NULL)) goto fail; if (data->bMotive) { if (!ReadFile(fh, &data->mode, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->gap, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->motivecount, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->proportion, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->childwidth, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->childheight, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->centerX, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->centerY, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->ChildCount, sizeof(int), &dwRead, NULL)) goto fail; for (int i = 0; i < data->ChildCount; i++) { TVecData *childdata = (TVecData*)data->ChildList->Items[i]; LoadVectorFile(fh, data, childdata, Version); } } } break; case V_TEXT: if (!ReadFile(fh, &data->Color, sizeof(TColor), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->Font, sizeof(LOGFONT), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->nCount, sizeof(int), &dwRead, NULL)) goto fail; if (Version >= 180) { // Unicode Char w_tempchar; for (int k = 0; k < data->nCount; k++) { if (!ReadFile(fh, &w_tempchar, sizeof(Char), &dwRead, NULL)) goto fail; data->TextString += w_tempchar; } } else { char tempchar; AnsiString tempString; for (int k = 0; k < data->nCount; k++) { if (!ReadFile(fh, &tempchar, sizeof(char), &dwRead, NULL)) goto fail; tempString += tempchar; } data->TextString = (String)tempString; } /* if (data->nCount == 0 || data->TextString.Length() == 0) { delete data; continue; } data->Kind = V_TEXTBOX; ChangeTextToTextBox(data); */ break; case V_TEXTBOX: if (!ReadFile(fh, &data->CharH, sizeof(int), &dwRead, NULL)) goto fail; // ±ÛÀÚÀÇ Å©±â if (!ReadFile(fh, &data->CharW, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->TextAngle, sizeof(double), &dwRead, NULL)) goto fail; // TextBoxÀÇ Angle·Î »ç¿ëµÊ if (!ReadFile(fh, &data->StartPoint, sizeof(POINT), &dwRead, NULL)) goto fail; // ù±ÛÀÚ°¡ ÀÖ´Â À§Ä¡ if (!ReadFile(fh, &data->CenterPoint, sizeof(POINT), &dwRead, NULL)) goto fail; // BoxÀÇ ¹«°ÔÁß½ÉÁ¡ TSWordData *srcWordData; // °¢°¢ÀÇ ¶óÀÎÀ» ÀúÀåÇϰí ÀÖ´Â ºÎºÐÀ» Copy TLineTextBox *tempTLineTextBox; data->ListOfAllLine = new TWordList; // -->by linuxjun for CurvedVectorText if (Version >= 150 || Version == 120) { // ÀÌÀü¿¡ old version ÀúÀåÇϱ⿡¼­ 120Àε¥ À̺κÐÀÌ ÀúÀåµÈ °æ¿ì°¡ ÀÖ¾úÀ½ int nTemp; if (!ReadFile(fh, &nTemp, sizeof(int), &dwRead, NULL)) goto fail; if (nTemp >= 0) { if (NVector->bMergeMode) { // MergeÀÎ °æ¿ì¿¡ ±Û¾¾µû¶óº¤ÅÍ ÆùÆ® ¿¡·¯³ª´ÂºÎºÐ¼öÁ¤ //by linuxjun for CurvedVectorText nTemp += existcount; } if(DataList->Count > nTemp) //DataList ¹üÀ§ ¾È¿¡ nTemp°¡ ¾øÀ» °æ¿ì error ³ªÁö ¾Ê°Ô ó¸® => ¾Æ·¡¿¡¼­ NULL°ª µé¾î°¨. { data->ListOfAllLine->CurveData = (TVecData*)DataList->Items[nTemp]; data->ListOfAllLine->CurveData->ParentTextBox = data; } } else { data->ListOfAllLine->CurveData = NULL; } } else { data->ListOfAllLine->CurveData = NULL; } // <--by linuxjun for CurvedVectorText if (!ReadFile(fh, &linecount, sizeof(int), &dwRead, NULL)) goto fail; for (int i = 0; i < linecount; i++) { tempTLineTextBox = new TLineTextBox; if (!ReadFile(fh, &wordcount, sizeof(int), &dwRead, NULL)) goto fail; for (int j = 0; j < wordcount; j++) { srcWordData = new TSWordData; if (!ReadFile(fh, &srcWordData->Selected, sizeof(bool), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &srcWordData->PPoint, sizeof(POINT), &dwRead, NULL)) goto fail; if (Version >= 180) { // Unicode if (!ReadFile(fh, &srcWordData->LFont, sizeof(LOGFONT), &dwRead, NULL)) goto fail; if (!ReadFile(fh, srcWordData->Word, sizeof(Char) * 2, &dwRead, NULL)) goto fail; if (!ReadFile(fh, &srcWordData->UsedByte, sizeof(int), &dwRead, NULL)) goto fail; } else { char tword[2]; String wString; LOGFONTA LFont; if (!ReadFile(fh, &LFont, sizeof(LOGFONTA), &dwRead, NULL)) goto fail; if (!ReadFile(fh, tword, sizeof(char) * 2, &dwRead, NULL)) goto fail; wString = String(tword); srcWordData->Word[0] = wString.c_str()[0]; srcWordData->Word[1] = 0; Copy_From_LOGFONTA_To_LOGFONTW(LFont, srcWordData->LFont); if (!ReadFile(fh, &srcWordData->UsedByte, sizeof(int), &dwRead, NULL)) goto fail; srcWordData->UsedByte = 1; } if (!ReadFile(fh, &srcWordData->Color, sizeof(TColor), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &srcWordData->Interval, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &srcWordData->HeightGap, sizeof(float), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &srcWordData->WidthGap, sizeof(float), &dwRead, NULL)) goto fail; // Version 150 Ãß°¡ if (Version >= 150) { if (!ReadFile(fh, &srcWordData->bNameChanged, sizeof(bool), &dwRead, NULL)) goto fail; // -->by linuxjun for CurvedVectorText if (!ReadFile(fh, &srcWordData->px, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &srcWordData->py, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &srcWordData->tx, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &srcWordData->ty, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &srcWordData->nx, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &srcWordData->ny, sizeof(int), &dwRead, NULL)) goto fail; // <--by linuxjun for CurvedVectorText } else { srcWordData->bNameChanged = false; } tempTLineTextBox->LineDataList->Add(srcWordData); } if (!ReadFile(fh, &lineheight, sizeof(int), &dwRead, NULL)) goto fail; tempTLineTextBox->lineHeight = lineheight; // lineHeight ÀúÀå data->ListOfAllLine->Add(tempTLineTextBox); } data->pList = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * 5); data->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, 1); if (!ReadFile(fh, data->pList, sizeof(DPOINT) * 5, &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->nCount, sizeof(int), &dwRead, NULL)) goto fail; // ÃʱâÈ­ memset(data->pMask, 0, 1); break; } //pList¿¡ Á¤»óÀûÀÎ °ªÀÌ µé¾î°¡ ÀÖÁö ¾ÊÀ» °æ¿ì °ü·Ã µ¥ÀÌÅ͸¦ Ãß°¡ÇÏÁö ¾Êµµ·Ï ó¸® if (data->pList && (CheckFloatingPoint(data->pList[0].x) || CheckFloatingPoint(data->pList[0].y))) { delete data; } else if (data->nCount > 0) { DataList->Add(data); if (NVector->bMergeMode) { // MergeÀÎ °æ¿ì¸¸ Undo save¸¦ ÇÑ´Ù UndoSave(VU_CREATE, DataList->Count - 1, sw); sw = false; } } else { delete data; } } // 2005 Vector Upgrade 0317 shin // font check, open ¿©ºÎ ¹Ýȯ : falseÀÌ¸é ¿­Áö ¾ÊÀ½. FontCheckAndChange(); // if (!FontCheckAndChange()) goto fail; // =========== Group Index¸¦ ÀçÁöÁ¤ÇØÁÖ´Â ºÎºÐ // ===========±âÁ¸ objectµéÀÇ indexÃ߸®±â /* for (int i = 0; i < existcount; i++) { data = (TVecData *)DataList->Items[i]; if (!data->Equal(nInstNum) continue; if (!data->GroupIndex) continue; existindex |= data->GroupIndex; } //========= Group Index ÁöÁ¤ (»õ·Î¿î index·Î »ðÀÔ) for (int k = 10; k < 32; k++) { // µé¾î°¥ GroupindexÁöÁ¤ for (int i = 10; i < 32; i++) { if (existindex & (1 << i)) continue; index = i; break; } for (int i = existcount; i < DataList->Count; i++) { data = (TVecData *)DataList->Items[i]; if (!data->Equal(nInstNum)) continue; if (data->bSelected) continue; // ÀÌ¹Ì Çѹø ÁöÁ¤µÇ¾îÀÖ´Â °æ¿ì´Â º¸³½´Ù if (!(data->GroupIndex & (1<GroupIndex &= 0x000001ff; data->GroupIndex += 1<bSelected = true; existindex |= 1<Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(nInstNum)) continue; if (data->bSelected) continue; if (data->GroupIndex / 10000 != k) continue; if (sw) { MainImageForm->GroupIndexState += 10000; sw = false; } data->GroupIndex = ((data->GroupIndex % 10000) & 0x000001ff) + MainImageForm->GroupIndexState; data->bSelected = true; } } // ================== for (int i = existcount; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; data->bSelected = NVector->bMergeMode; // MergeÀΰæ¿ì´Â ¼±ÅÃÀÌ µÈ»óÅ·Π»ý¼º } pPoints = NULL; END_LOG; return true; fail: // new·Î data°¡ »ý¼ºµÇ°í fail·Î µé¾î¿À¸é data´Â Áö¿ö¾ß ÇÑ´Ù. if (data) delete data; data = NULL; if (pPoints) delete []pPoints; pPoints = NULL; MessageDlg(IDS_MESSAGE_FILE_OPEN_VECTOR, mtInformation, TMsgDlgButtons() << mbOK, 0); END_LOG; return false; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::LoadFromSTYMemory(BYTE **pMemory, DWORD *dwPos, TVecData *data, int nVersion) { BEGIN_LOG(""); TVecData *childdata = NULL; memcpy(&data->Kind, *pMemory + (*dwPos), sizeof(EVecKind)); *dwPos += sizeof(EVecKind); memcpy(&data->First, *pMemory + (*dwPos), sizeof(POINT)); *dwPos += sizeof(POINT); memcpy(&data->Second, *pMemory + (*dwPos), sizeof(POINT)); *dwPos += sizeof(POINT); memcpy(&data->TraitSet, *pMemory + (*dwPos), sizeof(ObjectTraitSet)); *dwPos += sizeof(ObjectTraitSet); if ((205 <= nVersion && nVersion < 500) || 505 <= nVersion) { memcpy(&data->bAntialiasing, *pMemory + (*dwPos), sizeof(bool)); *dwPos += sizeof(bool); } else { data->bAntialiasing = true; // AntialiasingÀÌ ¾ø´Ù¸é Antialias·Î Open - by monkman (2007.05.30) } // TEXTBOX ¼öÁ¤½Ã ÀÌ ºÎºÐÀ» ¼öÁ¤ - by monkman if (data->Kind != V_TEXTBOX) { memcpy(&data->PenStyle, *pMemory + (*dwPos), sizeof(EPenStyle)); *dwPos += sizeof(EPenStyle); if ((205 <= nVersion && nVersion < 500) || 505 <= nVersion) { memcpy(&data->PenThick, *pMemory + (*dwPos), sizeof(double)); // int->double shin *dwPos += sizeof(double); } else { int tempthick; memcpy(&tempthick, *pMemory + (*dwPos), sizeof(int)); // int->double shin //0305 data->PenThick = (double)tempthick; *dwPos += sizeof(int); } memcpy(&data->nCount, *pMemory + (*dwPos), sizeof(int)); *dwPos += sizeof(int); memcpy(&data->bRound, *pMemory + (*dwPos), sizeof(bool)); *dwPos += sizeof(bool); memcpy(&data->bFill, *pMemory + (*dwPos), sizeof(bool)); *dwPos += sizeof(bool); memcpy(&data->bWinding, *pMemory + (*dwPos), sizeof(bool)); *dwPos += sizeof(bool); memcpy(&data->Color, *pMemory + (*dwPos), sizeof(TColor)); *dwPos += sizeof(TColor); memcpy(&data->Brush, *pMemory + (*dwPos), sizeof(TColor)); *dwPos += sizeof(TColor); memcpy(&data->bClosed, *pMemory + (*dwPos), sizeof(bool)); *dwPos += sizeof(bool); memcpy(&data->GroupIndex, *pMemory + (*dwPos), sizeof(int)); *dwPos += sizeof(int); data->pList = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * (data->nCount * 3 + 1)); memcpy(data->pList, *pMemory + (*dwPos), 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); // ÃʱâÈ­ memset(data->pMask, 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); *dwPos += sizeof(DPOINT) * (data->nCount * 3 + 1); if ((205 <= nVersion && nVersion < 500) || 505 <= nVersion) { memcpy(data->DashValues, *pMemory + (*dwPos), sizeof(double) * 7); *dwPos += (sizeof(double) * 7); } // STY, STI´Â Outline¸¸ ÀúÀåÇϹǷΠGradientFillÀº ÀúÀåÇÏÁö ¾Ê´Â´Ù - by monkman (2009.04.07) /* // GroupIndex º¯°æ & gradient fill Ãß°¡ - by monkman (2009.04.03) if ((206 <= nVersion && nVersion < 500) || 506 <= nVersion) { memcpy(&data->bGradientFill, *pMemory+(*dwPos), sizeof(int)); *dwPos += sizeof(int); if (data->bGradientFill){ memcpy(&data->gradientItem, *pMemory+(*dwPos), sizeof(int)); *dwPos += sizeof(int); memcpy(&data->gAngle, *pMemory+(*dwPos), sizeof(int)); *dwPos += sizeof(int); memcpy(&data->gradientColorCount, *pMemory+(*dwPos), sizeof(int)); *dwPos += sizeof(int); data->gradientColors = new RGBQUAD[data->gradientColorCount]; memcpy(data->gradientColors, *pMemory+(*dwPos), sizeof(RGBQUAD)*data->gradientColorCount); *dwPos += (sizeof(RGBQUAD)*data->gradientColorCount); } } */ // MotiveObject Ãß°¡ - by monkman (2009.04.03) if ((207 <= nVersion && nVersion < 500) || 507 <= nVersion) { memcpy(&data->bMotive, *pMemory + (*dwPos), sizeof(int)); *dwPos += sizeof(int); if (data->bMotive) { memcpy(&data->mode, *pMemory + (*dwPos), sizeof(int)); *dwPos += sizeof(int); memcpy(&data->gap, *pMemory + (*dwPos), sizeof(double)); *dwPos += sizeof(double); memcpy(&data->motivecount, *pMemory + (*dwPos), sizeof(int)); *dwPos += sizeof(int); memcpy(&data->proportion, *pMemory + (*dwPos), sizeof(double)); *dwPos += sizeof(double); memcpy(&data->childwidth, *pMemory + (*dwPos), sizeof(double)); *dwPos += sizeof(double); memcpy(&data->childheight, *pMemory + (*dwPos), sizeof(double)); *dwPos += sizeof(double); memcpy(&data->centerX, *pMemory + (*dwPos), sizeof(double)); *dwPos += sizeof(double); memcpy(&data->centerY, *pMemory + (*dwPos), sizeof(double)); *dwPos += sizeof(double); memcpy(&data->ChildCount, *pMemory + (*dwPos), sizeof(int)); *dwPos += sizeof(int); for (int i = 0; i < data->ChildCount; i++) { childdata = new TVecData(data->GetInstNum()); LoadFromSTYMemory(pMemory, dwPos, childdata, nVersion); // Àç±ÍÇÔ¼ö È£Ãâ if (data->ChildList == NULL) { data->ChildList = new TList; } data->ChildList->Add(childdata); } } } if ((209 <= nVersion && nVersion < 500) || 509 <= nVersion) { int TempCapStyle[2] = {0, 0}; memcpy(&TempCapStyle, *pMemory + (*dwPos), sizeof(int)*2); *dwPos += (sizeof(int)*2); data->CapStyle[0] = TempCapStyle[0]; data->CapStyle[1] = TempCapStyle[1]; if (data->CapStyle[0] && data->ArrowCap){ memcpy(&data->ArrowCap->bFillLineCap, *pMemory + (*dwPos), sizeof(bool)); *dwPos += sizeof(bool); memcpy(&data->ArrowCap->bShowArrowBoth, *pMemory + (*dwPos), sizeof(bool)); *dwPos += sizeof(bool); memcpy(&data->ArrowCap->LineCapWidthScale, *pMemory + (*dwPos), sizeof(double)); *dwPos += sizeof(double); memcpy(&data->ArrowCap->LineCapWidth, *pMemory + (*dwPos), sizeof(double)); *dwPos += sizeof(double); memcpy(&data->ArrowCap->LineCapHeight, *pMemory + (*dwPos), sizeof(double)); *dwPos += sizeof(double); memcpy(&data->ArrowCap->LineCapLine, *pMemory + (*dwPos), sizeof(double)); *dwPos += sizeof(double); } } // by siuaa 080507 if (nVersion < 206 || (500 <= nVersion && nVersion < 506)) { int tempIndex = data->GroupIndex & 0x000001ff; for (int index = 10; index < 32; index++) { if (data->GroupIndex & (1 << index)) { tempIndex += ((index - 9) * 10000); break; } } data->GroupIndex = tempIndex; } } END_LOG; } // --------------------------------------------------------------------------- TPException __fastcall TVecDraw::LoadFromSTYFile(HANDLE hFile, TVecData *data, int nVersion) { BEGIN_LOG(""); TPException ec = EC_NONE; TVecData *childdata = NULL; DWORD dwRead; if (!ReadFile(hFile, &data->Kind, sizeof(EVecKind), &dwRead, NULL)) goto fail; if (!ReadFile(hFile, &data->First, sizeof(POINT), &dwRead, NULL)) goto fail; if (!ReadFile(hFile, &data->Second, sizeof(POINT), &dwRead, NULL)) goto fail; if (!ReadFile(hFile, &data->TraitSet, sizeof(ObjectTraitSet), &dwRead, NULL)) goto fail; if ((205 <= nVersion && nVersion < 500) || 505 <= nVersion) { if (!ReadFile(hFile, &data->bAntialiasing, sizeof(bool), &dwRead, NULL)) goto fail; } else { data->bAntialiasing = true; // AntialiasingÀÌ ¾ø´Ù¸é Antialias·Î Open - by monkman (2007.05.30) } // TEXTBOX ¼öÁ¤½Ã ÀÌ ºÎºÐÀ» ¼öÁ¤ - by monkman if (data->Kind != V_TEXTBOX) { if (!ReadFile(hFile, &data->PenStyle, sizeof(EPenStyle), &dwRead, NULL)) goto fail; if ((205 <= nVersion && nVersion < 500) || 505 <= nVersion) { if (!ReadFile(hFile, &data->PenThick, sizeof(double), &dwRead, NULL)) goto fail; } else { int tempthick; if (!ReadFile(hFile, &tempthick, sizeof(int), &dwRead, NULL)) goto fail; data->PenThick = (double)tempthick; // int->double shin //0305 } if (!ReadFile(hFile, &data->nCount, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(hFile, &data->bRound, sizeof(bool), &dwRead, NULL)) goto fail; if (!ReadFile(hFile, &data->bFill, sizeof(bool), &dwRead, NULL)) goto fail; if (!ReadFile(hFile, &data->bWinding, sizeof(bool), &dwRead, NULL)) goto fail; if (!ReadFile(hFile, &data->Color, sizeof(TColor), &dwRead, NULL)) goto fail; if (!ReadFile(hFile, &data->Brush, sizeof(TColor), &dwRead, NULL)) goto fail; if (!ReadFile(hFile, &data->bClosed, sizeof(bool), &dwRead, NULL)) goto fail; if (!ReadFile(hFile, &data->GroupIndex, sizeof(int), &dwRead, NULL)) goto fail; data->pList = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * (data->nCount * 3 + 1)); if (!ReadFile(hFile, data->pList, sizeof(DPOINT) * (data->nCount * 3 + 1), &dwRead, NULL)) goto fail; data->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); // ÃʱâÈ­ memset(data->pMask, 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); if ((205 <= nVersion && nVersion < 500) || 505 <= nVersion) { if (!ReadFile(hFile, data->DashValues, sizeof(double) * 7, &dwRead, NULL)) goto fail; } // STY, STI´Â Outline¸¸ ÀúÀåÇϹǷΠGradientFillÀº ÀúÀåÇÏÁö ¾Ê´Â´Ù - by monkman (2009.04.07) /* // GroupIndex º¯°æ & gradient fill Ãß°¡ - by monkman (2009.04.03) if ((206 <= nVersion && nVersion < 500) || 506 <= nVersion) { if (!ReadFile(hFile, &data->bGradientFill, sizeof(int), &dwRead, NULL)) goto fail; if (data->bGradientFill){ if (!ReadFile(hFile, &data->gradientItem, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(hFile, &data->gAngle, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(hFile, &data->gradientColorCount, sizeof(int), &dwRead, NULL)) goto fail; data->gradientColors = new RGBQUAD[data->gradientColorCount]; if (!ReadFile(hFile, data->gradientColors, sizeof(RGBQUAD)*data->gradientColorCount, &dwRead, NULL)) goto fail; } } */ // MotiveObject Ãß°¡ - by monkman (2009.04.03) if ((207 <= nVersion && nVersion < 500) || 507 <= nVersion) { if (!ReadFile(hFile, &data->bMotive, sizeof(int), &dwRead, NULL)) goto fail; if (data->bMotive) { if (!ReadFile(hFile, &data->mode, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(hFile, &data->gap, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(hFile, &data->motivecount, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(hFile, &data->proportion, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(hFile, &data->childwidth, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(hFile, &data->childheight, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(hFile, &data->centerX, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(hFile, &data->centerY, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(hFile, &data->ChildCount, sizeof(int), &dwRead, NULL)) goto fail; for (int i = 0; i < data->ChildCount; i++) { childdata = new TVecData(data->GetInstNum()); LoadFromSTYFile(hFile, childdata, nVersion); // Àç±ÍÇÔ¼ö È£Ãâ if (data->ChildList == NULL) { data->ChildList = new TList; } data->ChildList->Add(childdata); } } } // Arrow Ãß°¡ if ((209 <= nVersion && nVersion < 500) || 509 <= nVersion) { int TempCapStyle[2] = {0, 0}; if (!ReadFile(hFile, TempCapStyle, sizeof(int) * 2, &dwRead, NULL)) goto fail; data->CapStyle[0] = TempCapStyle[0]; data->CapStyle[1] = TempCapStyle[1]; if (data->CapStyle[0] && data->ArrowCap){ if (!data->ArrowCap->LoadFromFile(hFile)) goto fail; // if (!ReadFile(hFile, &data->ArrowCap->bFillLineCap, sizeof(bool), &dwRead, NULL)) // goto fail; // if (!ReadFile(hFile, &data->ArrowCap->bShowArrowBoth, sizeof(bool), &dwRead, NULL)) // goto fail; // if (!ReadFile(hFile, &data->ArrowCap->LineCapWidthScale, sizeof(double), &dwRead, NULL)) // goto fail; // if (!ReadFile(hFile, &data->ArrowCap->LineCapWidth, sizeof(double), &dwRead, NULL)) // goto fail; // if (!ReadFile(hFile, &data->ArrowCap->LineCapHeight, sizeof(double), &dwRead, NULL)) // goto fail; } } } // by siuaa 080507 if (nVersion < 206 || (500 <= nVersion && nVersion < 506)) { int tempIndex = data->GroupIndex & 0x000001ff; for (int index = 10; index < 32; index++) { if (data->GroupIndex & (1 << index)) { tempIndex += ((index - 9) * 10000); break; } } data->GroupIndex = tempIndex; } END_LOG; return ec; fail: ec = EC_FILE_NOT_READ; if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile); END_LOG; return ec; } // --------------------------------------------------------------------------- bool __fastcall TVecDraw::LoadVectorFile(HANDLE fh, TVecData *Parent, TVecData *data, int Version) { BEGIN_LOG(""); POINT *pPoints = NULL; // pPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) DWORD dwRead; int srcMaxGroupIndex = 0; // load¸¦ ÇØ¿À´Â objectÁß °¡Àå Å« index¸¦ ÀúÀå by siuaa 080506 if (!ReadFile(fh, &data->Kind, sizeof(EVecKind), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->First, sizeof(POINT), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->Second, sizeof(POINT), &dwRead, NULL)) goto fail; if (Version >= 150) { if (!ReadFile(fh, &data->bAntialiasing, sizeof(bool), &dwRead, NULL)) goto fail; } else { data->bAntialiasing = false; } int tempThick; switch(data->Kind) { case V_LINE: case V_CURVE: if (!ReadFile(fh, &data->PenStyle, sizeof(EPenStyle), &dwRead, NULL)) goto fail; // Version 150 Ãß°¡ if (Version >= 150) { if (!ReadFile(fh, &data->PenThick, sizeof(double), &dwRead, NULL)) goto fail; } else { if (!ReadFile(fh, &tempThick, sizeof(int), &dwRead, NULL)) goto fail; data->PenThick = (double)tempThick; } // if (!ReadFile(fh, &data->PenThick, sizeof(int), &dwRead, NULL)) goto fail; // if (!ReadFile(fh, &data->PenThick, sizeof(double), &dwRead, NULL)) goto fail; // 2005 Vector Upgrade 0223 shin if (!ReadFile(fh, &data->nCount, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->bRound, sizeof(bool), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->bFill, sizeof(bool), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->bWinding, sizeof(bool), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->Color, sizeof(TColor), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->Brush, sizeof(TColor), &dwRead, NULL)) goto fail; // ===7.41, Version 110 Ãß°¡ if (Version >= 110) { if (!ReadFile(fh, &data->bClosed, sizeof(bool), &dwRead, NULL)) goto fail; // if (!ReadFile(fh, &data->GroupIndex, sizeof(int), &dwRead, NULL)) goto fail; if (Version < 160) // 2.4 ÀÌÇÏ ¹öÀüÀÇ groupÀ» ÀÐ¾î ¿À±â À§ÇØ { int temp; if (!ReadFile(fh, &temp, sizeof(int), &dwRead, NULL)) goto fail; int tempIndex = 0; for (int i = 0; i < 10; i++) // ¹øÈ£°¡ ÀÖ´Â group index¸¦ ÀÐÀ½ { if ((temp & (1 << i))) tempIndex += (1 << i); } for (int i = 10; i < 32; i++) // ¹øÈ£°¡ ¾ø´Â group index¸¦ ÀÐÀ½ { if ((temp & (1 << i))) { tempIndex += ((i - 9) * 10000); break; } } data->GroupIndex = tempIndex; if (srcMaxGroupIndex < tempIndex / 10000) srcMaxGroupIndex = tempIndex / 10000; } else { if (!ReadFile(fh, &data->GroupIndex, sizeof(int), &dwRead, NULL)) goto fail; if (srcMaxGroupIndex < data->GroupIndex / 10000) srcMaxGroupIndex = data->GroupIndex / 10000; } } // ========================= 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); if (Version <= 110) { // 7.41ÀÌÇÏ¿¡¼­´Â DPOINT¸¦ »ç¿ëÇÏÁö ¾Ê¾Ò´Ù if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new POINT[(data->nCount + 1) * 3 + 1]; } else { pPoints = new POINT[data->nCount * 3 + 1]; } if (!ReadFile(fh, pPoints, sizeof(POINT) * (data->nCount * 3 + 1), &dwRead, NULL)) goto fail; for (int j = 0; j < data->nCount * 3 + 1; j++) data->pList[j].DPoint(pPoints[j]); if (pPoints) delete[]pPoints; pPoints = NULL; } else { if (!ReadFile(fh, data->pList, sizeof(DPOINT) * (data->nCount * 3 + 1), &dwRead, NULL)) goto fail; } // ÃʱâÈ­ memset(data->pMask, 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); if (!ReadFile(fh, &data->bPatternFill, sizeof(bool), &dwRead, NULL)) goto fail; if (data->bPatternFill) { int w, h; if (!ReadFile(fh, &data->PatternAngle, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->PatternAdjustX, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->PatternAdjustY, sizeof(int), &dwRead, NULL)) goto fail; // ====7.43, Version 130 Ãß°¡ Added by maxleo21c (2004/05/11) if (Version >= 130) { if (!ReadFile(fh, &data->RatioX, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->RatioY, sizeof(int), &dwRead, NULL)) goto fail; } // ========================== if (!ReadFile(fh, &w, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &h, sizeof(int), &dwRead, NULL)) goto fail; data->TBitmapSource = new TTexpiaBitmap; if (!data->TBitmapSource->Create(w, h, 24)) goto fail; data->TBitmapSource->LoadFromTexpiaFile(fh, cmZLib); MakePatternBitmap(data); } // Version 150 Ãß°¡ if (Version >= 150) { if (!ReadFile(fh, data->DashValues, sizeof(double) * 7, &dwRead, NULL)) goto fail; int TempCapStyle[2] = {0, 0}; if (!ReadFile(fh, TempCapStyle, sizeof(int) * 2, &dwRead, NULL)) goto fail; data->CapStyle[0] = TempCapStyle[0]; data->CapStyle[1] = TempCapStyle[1]; if (Version >= 181){ if (data->CapStyle[0] && data->ArrowCap){ if (!data->ArrowCap->LoadFromFile(fh)) goto fail; // if (!ReadFile(fh, &data->ArrowCap->bFillLineCap, sizeof(bool), &dwRead, NULL)) // goto fail; // if (!ReadFile(fh, &data->ArrowCap->bShowArrowBoth, sizeof(bool), &dwRead, NULL)) // goto fail; // if (!ReadFile(fh, &data->ArrowCap->LineCapWidthScale, sizeof(double), &dwRead, NULL)) // goto fail; // if (!ReadFile(fh, &data->ArrowCap->LineCapWidth, sizeof(double), &dwRead, NULL)) // goto fail; // if (!ReadFile(fh, &data->ArrowCap->LineCapHeight, sizeof(double), &dwRead, NULL)) // goto fail; } } else if (data->CapStyle[0] && data->ArrowCap){ data->ArrowCap->SetDefault(); } } // Version 160 Ãß°¡ 080514 if (Version >= 160) { if (!ReadFile(fh, &data->bGradientFill, sizeof(int), &dwRead, NULL)) goto fail; if (data->bGradientFill) { if (!ReadFile(fh, &data->gradientItem, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->gAngle, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->gradientColorCount, sizeof(int), &dwRead, NULL)) goto fail; int count = data->gradientColorCount; data->gradientColors = new RGBQUAD[count]; if (!ReadFile(fh, data->gradientColors, sizeof(RGBQUAD) * count, &dwRead, NULL)) goto fail; } } // Version 170 Ãß°¡ 090304 if (Version >= 170) { if (!ReadFile(fh, &data->bMotive, sizeof(int), &dwRead, NULL)) goto fail; if (data->bMotive) { if (!ReadFile(fh, &data->mode, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->gap, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->motivecount, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->proportion, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->childwidth, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->childheight, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->centerX, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->centerY, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->ChildCount, sizeof(int), &dwRead, NULL)) goto fail; } } break; case V_RECT: case V_ELLIPSE: if (!ReadFile(fh, &data->PenStyle, sizeof(EPenStyle), &dwRead, NULL)) goto fail; // Version 150 Ãß°¡ if (Version >= 150) { if (!ReadFile(fh, &data->PenThick, sizeof(double), &dwRead, NULL)) goto fail; } else { if (!ReadFile(fh, &tempThick, sizeof(int), &dwRead, NULL)) goto fail; data->PenThick = (double)tempThick; } if (!ReadFile(fh, &data->bRound, sizeof(bool), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->bFill, sizeof(bool), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->bWinding, sizeof(bool), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->Color, sizeof(TColor), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->Brush, sizeof(TColor), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->bPatternFill, sizeof(bool), &dwRead, NULL)) goto fail; if (data->bPatternFill) LoadObjectBitmap(fh, data); // Version 150 Ãß°¡ if (Version >= 150) { if (!ReadFile(fh, data->DashValues, sizeof(double) * 7, &dwRead, NULL)) goto fail; int TempCapStyle[2] = {0, 0}; if (!ReadFile(fh, TempCapStyle, sizeof(int) * 2, &dwRead, NULL)) goto fail; data->CapStyle[0] = TempCapStyle[0]; data->CapStyle[1] = TempCapStyle[1]; } // Version 160 Ãß°¡ 080514 if (Version >= 160) { if (!ReadFile(fh, &data->bGradientFill, sizeof(int), &dwRead, NULL)) goto fail; if (data->bGradientFill) { if (!ReadFile(fh, &data->gradientItem, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->gAngle, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->gradientColorCount, sizeof(int), &dwRead, NULL)) goto fail; int count = data->gradientColorCount; data->gradientColors = new RGBQUAD[count]; if (!ReadFile(fh, data->gradientColors, sizeof(RGBQUAD) * count, &dwRead, NULL)) goto fail; } } // Version 170 Ãß°¡ 090304 if (Version >= 170) { if (!ReadFile(fh, &data->bMotive, sizeof(int), &dwRead, NULL)) goto fail; if (data->bMotive) { if (!ReadFile(fh, &data->mode, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->gap, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->motivecount, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->proportion, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->childwidth, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->childheight, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->centerX, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->centerY, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->ChildCount, sizeof(int), &dwRead, NULL)) goto fail; } } break; case V_TEXT: if (!ReadFile(fh, &data->Color, sizeof(TColor), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->Font, sizeof(LOGFONT), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->nCount, sizeof(int), &dwRead, NULL)) goto fail; if (Version >= 180) { // Unicode Char w_tempchar; for (int k = 0; k < data->nCount; k++) { if (!ReadFile(fh, &w_tempchar, sizeof(Char), &dwRead, NULL)) goto fail; data->TextString += w_tempchar; } } else { char tempchar; AnsiString tempString; for (int k = 0; k < data->nCount; k++) { if (!ReadFile(fh, &tempchar, sizeof(char), &dwRead, NULL)) goto fail; tempString += tempchar; } data->TextString = (String)tempString; } break; } if (data->nCount > 0) { if (!Parent->ChildList) { Parent->ChildList = new TList; Parent->ChildList->Add(data); } else { Parent->ChildList->Add(data); } } else { delete data; } if (pPoints) delete[]pPoints; pPoints = NULL; END_LOG; return true; fail: if (pPoints) delete[]pPoints; pPoints = NULL; END_LOG; return false; } // --------------------------------------------------------------------------- /** SVG file·Î vector save. * modified by maleo21c(06.06.20) * SVG¸¦ ó¸®Çϱâ À§Çؼ­ TXMLDocument Component¸¦ ÀÌ¿ëÇØ¼­ ó¸®Çß´Ù. * ÇѱÛÀ» ÆÄ½ÌÇÒ¶§ ¿¡·¯°¡ ¹ß»ýÇÏ´Â ¹®Á¦°¡ Àִµ¥ À̰ÍÀº encoding¹æ½ÄÀ» euc-kr·Î * ¹Ù²Ù¸é µÇÁö¸¸ SVGÆÄÀÏ¿¡¼­´Â euc-kr ÀÎÄÚµù ¹æ½ÄÀ¸·Î Çϸé svg viewer¿¡¼­ º¸ÀÌÁö * ¾Ê´Â 2Â÷ ¹®Á¦°¡ ¹ß»ýÇÑ´Ù. À̰ÍÀ» ÇØ°áÇߴµ¥ ÀúÀåÀ» ÇÒ ¶§ utf-8(À¯´ÏÄÚµå)Çü½ÄÀ¸·Î * ÀúÀåÇÏ¸é ¿¡·¯°¡ ¹ß»ýÇÏÁö ¾Ê´Â °ÍÀ» È®ÀÎÇß´Ù. */ // bool __fastcall TVecDraw::SaveVectorToSVGFile(HANDLE fh, int Index, int method, String dn, // String fn) bool __fastcall TVecDraw::SaveVectorToSVGFile(HANDLE fh, int Index, int method, String dn, String fn) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) int Version = 100, count = 0; // Version 1.5 : 100 DWORD dwWrite; String buffer; //POINT *pPoints = NULL; // pPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) DPOINT *pPoints = NULL; int Width, Height; long minx = MaxInt, miny = MaxInt, maxx = 0, maxy = 0; int FirstX, FirstY, SecondX, SecondY, StartX, StartY; int cx, cy; // font°¢µµÃ³¸®À§Çؼ­ double tx, ty, angle, pw; // font°¢µµÃ³¸®À§Çؼ­ RECT rect; bool isVector, bRange = false; TRect Src; UTF8String resualtUTF8; String resualt; // ÀÛ¾÷±¸¿ªÀÌ ÀÖ´Â °æ¿ì¿¡´Â ¿µ¿ªÀÇ »çÀÌÁî¿¡ ¸ÂÃß¾î shift~ -------------------- if (MainImageForm->WorkArea->Mask) { bRange = true; Src = MainImageForm->WorkArea->Range; Width = Src.Width(); Height = Src.Height(); } else { Width = MainImageForm->iMainImage->uBitmap->Width; Height = MainImageForm->iMainImage->uBitmap->Height; } for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (data->nCount <= 0) continue; if (!data->Equal(MainImageForm->Number)) continue; // if (method == 4 && !data->bSelected) continue; if ((method & 8) && !data->bSelected) continue; // INRECTMETHOD; if (!InRectMethod(Src, data, method, bRange)) continue; count++; } if (count > 0) isVector = true; else isVector = false; TVector2SVG *tvector2svg = NULL; tvector2svg = new TVector2SVG(bRange, Src); tvector2svg->InitSVGFile(buffer, TexStylistVersion, Width, Height); resualt += buffer; buffer = ""; int motiveCount = 0; int patternFill_ID = 0; bool byPass = false; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (data->nCount <= 0) continue; if (!data->Equal(MainImageForm->Number)) continue; if (!InRectMethod(Src, data, method, bRange)) continue; if (bRange) { FirstX = data->First.x - Src.Left; FirstY = data->First.y - Src.Top; SecondX = data->Second.x - Src.Left; SecondY = data->Second.y - Src.Top; } else { FirstX = data->First.x; FirstY = data->First.y; SecondX = data->Second.x; SecondY = data->Second.y; } pw = data->PenThick; if (data->Kind == V_TEXTBOX) { //pPoints = new POINT[5]; pPoints = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * 5); } else { if (data->bClosed && data->PenStyle == P_SOLID) { //pPoints = new POINT[(data->nCount + 1) * 3 + 1]; pPoints = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * ((data->nCount + 1) * 3 + 1)); } else { //pPoints = new POINT[data->nCount * 3 + 1]; pPoints = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * (data->nCount * 3 + 1)); } } if (data->Kind == V_CURVE || data->Kind == V_LINE) { byPass = false; for (int i = 0; i < data->nCount * 3 + 1; i++) { if (bRange) { pPoints[i].x = data->pList[i].x - Src.Left; pPoints[i].y = data->pList[i].y - Src.Top; } else { pPoints[i].x = data->pList[i].x; pPoints[i].y = data->pList[i].y; } //SVG·Î ÀúÀåÀ» ÇÒ ¶§ ÀÌ»óÇÑ ³»¿ëÀÌ ÀúÀåµÈ °æ¿ì°¡ À־ ¾Æ·¡ ³»¿ë Ãß°¡ //pList °ªÀÌ Á¤»óÀûÀÌÁö ¾ÊÀ» °æ¿ì ÀúÀåÀ» ÇÏÁö ¾Ê´Â´Ù. by david 14.08.28 if (CheckFloatingPoint(pPoints[i].x) || CheckFloatingPoint(pPoints[i].y)) { //¹«Á¶°Ç Áö¿ìÁö ¾Ê°í ÆÄÀÏÀ» ÀúÀåÇÏÁö ¾Êµµ·Ï continue ÇÑ´Ù. DataList->Remove(data); delete data; data = NULL; byPass = true; break; //for } } if (byPass) continue; if (data->bClosed && data->PenStyle == P_SOLID) { // by maxleo21c 070626 Ãß°¡ pPoints[data->nCount * 3] = pPoints[0]; } } if (data->bPatternFill) { // PatternFill À϶§ patternFill_ID++; } switch(data->Kind) { case V_LINE: if (data->bMotive) { buffer = buffer + "\t\n"; motiveCount++; buffer = buffer + "\t"; tvector2svg->SVGDrawLine(buffer, pPoints, data->nCount + 1, data->Color, data->Brush, data->bFill, data->bWinding, pw); buffer = buffer + "\t\t\n\t\t"; SaveMotiveToSVGFile(data, (void*)tvector2svg, buffer, method, dn, fn, patternFill_ID); } else { tvector2svg->SVGDrawLine(buffer, pPoints, data->nCount + 1, data->Color, data->Brush, data->bFill, data->bWinding, pw); if (buffer.Length() == 0) break; resualt += buffer; buffer = ""; } break; case V_CURVE: if (data->ParentTextBox) break; // by maxleo21c(06.06.09) if (data->bPatternFill) patternFill_ID++; if (data->bMotive) { buffer = buffer + "\t\n"; motiveCount++; buffer = buffer + "\t"; tvector2svg->SVGDrawCurve(buffer, pPoints, data, dn, fn, i, patternFill_ID); buffer = buffer + "\t\t\n\t\t"; SaveMotiveToSVGFile(data, (void*)tvector2svg, buffer, method, dn, fn, patternFill_ID); } else { tvector2svg->SVGDrawCurve(buffer, pPoints, data, dn, fn, i, patternFill_ID); if (buffer.Length() == 0) break; resualt += buffer; buffer = ""; } break; case V_RECT: tvector2svg->SVGDrawRect(buffer, FirstX, FirstY, SecondX, SecondY, data->Color, data->Brush); if (buffer.Length() == 0) break; // if (!WriteFile(fh, buffer.c_str(), buffer.Length(), &dwWrite, NULL)) goto fail; resualt += buffer; buffer = ""; break; case V_ELLIPSE: tvector2svg->SVGDrawEllipse(buffer, FirstX, FirstY, SecondX, SecondY, data->Color, data->Brush); if (buffer.Length() == 0) break; // if (!WriteFile(fh, buffer.c_str(), buffer.Length(), &dwWrite, NULL)) goto fail; resualt += buffer; buffer = ""; break; case V_TEXT: tvector2svg->SVGDrawText(buffer, FirstX, FirstY, data->TextString, data->nCount, data->Font, data->Color); if (buffer.Length() == 0) break; // if (!WriteFile(fh, buffer.c_str(), buffer.Length(), &dwWrite, NULL)) goto fail; resualt += buffer; buffer = ""; break; case V_TEXTBOX: if (bRange) { StartX = data->StartPoint.x - Src.Left; StartY = data->StartPoint.y - Src.Top; } else { StartX = data->StartPoint.x; StartY = data->StartPoint.y; } if (data->TextAngle) { if (bRange) { cx = data->CenterPoint.x - Src.Left; cy = data->CenterPoint.y - Src.Top; } else { cx = data->CenterPoint.x; cy = data->CenterPoint.y; } tx = StartX - cx; ty = cy - StartY; angle = (double)data->TextAngle / 180 * M_PI; StartX = tx * cos(-angle) + ty * sin(-angle) + cx; StartY = cy - (-tx * sin(-angle) + ty * cos(-angle)); } if (data->ListOfAllLine->CurveData) { tvector2svg->SVGDrawTextPath(buffer, data, StartX, StartY, i, patternFill_ID); if (buffer.Length() == 0) break; // if (!WriteFile(fh, buffer.c_str(), buffer.Length(), &dwWrite, NULL)) goto fail; resualt += buffer; buffer = ""; } else { // tvector2svg->SVGDrawTextBox(buffer, data, StartX, StartY); if (!tvector2svg->SVGDrawTextBox(buffer, data, StartX, StartY)) { // 070807 #ifdef SK_SMART // "Text data¿¡ ¿À·ù°¡ ÀÖ½À´Ï´Ù. ´Ù½Ã ÀÛ¼ºÇØ Áֽñ⠹ٶø´Ï´Ù." Application->MessageBox(IDS_MESSAGE011.c_str(), L"Warning", MB_OK); #endif goto fail; } if (buffer.Length() == 0) break; // if (!WriteFile(fh, buffer.c_str(), buffer.Length(), &dwWrite, NULL)) goto fail; resualt += buffer; buffer = ""; } break; } //if (pPoints) delete[]pPoints; if (pPoints) HeapFree(GetProcessHeap(), 0, pPoints); pPoints = NULL; } buffer = buffer + ""; // if (!WriteFile(fh, buffer.c_str(), buffer.Length(), &dwWrite, NULL)) goto fail; resualt += buffer; resualtUTF8 = AnsiToUtf8(resualt); if (!WriteFile(fh, resualtUTF8.c_str(), resualtUTF8.Length(), &dwWrite, NULL)) goto fail; delete tvector2svg; tvector2svg = NULL; if (pPoints) HeapFree(GetProcessHeap(), 0, pPoints); pPoints = NULL; END_LOG; return true; fail: if (tvector2svg) delete tvector2svg; tvector2svg = NULL; //if (pPoints) delete[]pPoints; if (pPoints) HeapFree(GetProcessHeap(), 0, pPoints); pPoints = NULL; END_LOG; return false; } // --------------------------------------------------------------------------- // ¸ðƼºê by embakum 09.03.26 // bool __fastcall TVecDraw::SaveMotiveToSVGFile(TVecData *ParentData, void *TVector2Svg, String &buffer, // int method, String dn, String fn, int &patternFill_ID) bool __fastcall TVecDraw::SaveMotiveToSVGFile(TVecData *ParentData, void *TVector2Svg, String &buffer, int method, String dn, String fn, int &patternFill_ID) { BEGIN_LOG(""); TList *tDataList = ParentData->ChildList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) TList *DataList = new TList; TVector2SVG *tvector2svg = (TVector2SVG*)TVector2Svg; // ------------------------------------------ TList * ResultBezierPointList; TPointList *tempPointList; DPOINT firstPoint, onPoint, normalPoint, tempCurpt, tempOldpt; DPOINT *pTempList = NULL; double dInterval; TBezierPointList * BezierPointList = new TBezierPointList(); // »ý¼º BezierPointList->Init(ParentData); double CurveLength = BezierPointList->GetCurveLength(); int nSegment; // int quotient = int(CurveLength/((ParentData->proportion)*(ParentData->childwidth))); // if (quotient==0) quotient = 1; switch(ParentData->mode) { case 0: // ²Ë ä¿ì±â if (ParentData->proportion == 0) { ParentData->proportion = 1; if (VectorForm) VectorForm->eMotiveProportion->Value = 1; } if (ParentData->childwidth == 0) { ParentData->childwidth = 1; } nSegment = int(CurveLength / ((ParentData->proportion) * (ParentData->childwidth))); if (nSegment == 0) nSegment = 1; ParentData->gap = double(CurveLength / nSegment); ParentData->motivecount = nSegment; break; case 1: // °³¼ö ¼³Á¤ nSegment = ParentData->motivecount; if (nSegment == 0) { nSegment = 1; if (VectorForm) VectorForm->eMotiveCount->Value = 1; } ParentData->gap = double(CurveLength / nSegment); break; case 2: // °£°Ý ¼³Á¤ if (ParentData->gap == 0) { ParentData->gap = 1; if (VectorForm) VectorForm->eMotiveGap->Value = 1; } nSegment = int(CurveLength / ParentData->gap); if (nSegment == 0) nSegment = 1; ParentData->motivecount = nSegment; break; } int count = 1; ResultBezierPointList = BezierPointList->Calculate(ParentData, nSegment); pTempList = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * (nSegment * 3 + 1)); double *tangentlist = new double[nSegment + 1]; // ±â¿ï±â¸¦ °¡Áö°í ÀÖ´Â ¹è¿­ firstPoint = FindingNormalOnBezier(&ParentData->pList[0], 0, 0, 0); pTempList[0].x = firstPoint.x; pTempList[0].y = firstPoint.y; pTempList[1].x = firstPoint.x; pTempList[1].y = firstPoint.y; tangentlist[0] = FindCurveTangent(&ParentData->pList[0], 0); for (int i = 0; i < ResultBezierPointList->Count; i++) { tempPointList = (TPointList*)ResultBezierPointList->Items[i]; for (tempPointList->First(); !tempPointList->IsDone(); tempPointList->Next()) { dInterval = tempPointList->CurrentDouble(); // BezierCurve À§ÀÇ Á¡À§Ä¡ // onPoint = FindingPointOnBezier(&tData->pList[i*3], dInterval); // ãÀº Á¡ÀÇ NormalÀÇ À§Ä¡ (ãÀº Á¡Àº ResultBezierPointList¾È¿¡ ÀÖÀ½) normalPoint = FindingNormalOnBezier(&ParentData->pList[i * 3], dInterval, 0, count % 2); tangentlist[count] = FindCurveTangent(&ParentData->pList[i * 3], dInterval); pTempList[count * 3 - 2] = pTempList[count * 3 - 3]; pTempList[count * 3 - 1].x = normalPoint.x; pTempList[count * 3 - 1].y = normalPoint.y; pTempList[count * 3].x = normalPoint.x; pTempList[count * 3].y = normalPoint.y; count++; tempOldpt = tempCurpt; } } if (ParentData->bClosed) { // ´ÝÈù ¿ÀºêÁ§Æ®ÀÇ °æ¿ì ³¡Á¡°ú ùÁ¡À» °°°Ô. pTempList[nSegment * 3] = pTempList[0]; pTempList[nSegment * 3 - 1] = pTempList[0]; } delete BezierPointList; BezierPointList = NULL; // ------------------------------------------ count = 0; int Version = 100; // Version 1.5 : 100 int px = 0, py = 0; //POINT *pPoints = NULL; // pPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) DPOINT *pPoints = NULL; int Width, Height; long minx = MaxInt, miny = MaxInt, maxx = 0, maxy = 0; int FirstX, FirstY, SecondX, SecondY, StartX, StartY; int cx, cy; // font°¢µµÃ³¸®À§Çؼ­ double tx, ty, angle, pw; // font°¢µµÃ³¸®À§Çؼ­ RECT rect; bool bRange = false; TRect Src; double centerX, centerY; ///< childÀÇ centerÀÇ x,yÁÂÇ¥ // ------------------------------------------ UTF8String resualtUTF8; String result; // ÀÛ¾÷±¸¿ªÀÌ ÀÖ´Â °æ¿ì¿¡´Â ¿µ¿ªÀÇ »çÀÌÁî¿¡ ¸ÂÃß¾î shift~ -------------------- if (MainImageForm->WorkArea->Mask) { bRange = true; Src = MainImageForm->WorkArea->Range; Width = Src.Width(); Height = Src.Height(); } else { Width = MainImageForm->iMainImage->uBitmap->Width; Height = MainImageForm->iMainImage->uBitmap->Height; } // buffer = buffer + "\t\n"; // buffer = buffer + "\t\t\n"; // ------------------------------------------ TVecData *tdata; // motive childÀÇ È®´ë Ãà¼Ò for (int i = 0; i < tDataList->Count; i++) { data = (TVecData*)tDataList->Items[i]; tdata = new TVecData(data->GetInstNum()); tdata->Copy(data); // ------------------------------------------ if (data->Kind == V_TEXTBOX) { //pPoints = new POINT[5]; pPoints = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * 5); } else { if (data->bClosed && data->PenStyle == P_SOLID) { //pPoints = new POINT[(data->nCount + 1) * 3 + 1]; pPoints = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * ((data->nCount + 1) * 3 + 1)); } else { //pPoints = new POINT[data->nCount * 3 + 1]; pPoints = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * (data->nCount * 3 + 1)); } } if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int j = 0; j < data->nCount * 3 + 1; j++) { if (bRange) { pPoints[j].x = data->pList[j].x - Src.Left; pPoints[j].y = data->pList[j].y - Src.Top; } else { pPoints[j].x = data->pList[j].x; pPoints[j].y = data->pList[j].y; } } if (data->bClosed && data->PenStyle == P_SOLID) { // by maxleo21c 070626 Ãß°¡ pPoints[data->nCount * 3] = pPoints[0]; } } pw = data->PenThick; if (data->bPatternFill) { // PatternFill À϶§ SET_RECT; // gradientfill MakePatternBitmap(tdata); patternFill_ID++; } tvector2svg->SVGDrawCurve(result, pPoints, tdata, dn, fn, i, patternFill_ID); //if (pPoints) delete[]pPoints; if (pPoints) HeapFree(GetProcessHeap(), 0, pPoints); pPoints = NULL; if (result.Length() == 0) goto fail; buffer += result; result = "\t\t"; // ------------------------------------------ centerX = ParentData->centerX; // - Src.Left; centerY = ParentData->centerY; // - Src.Top; for (int l = 0; l < data->nCount * 3 + 1; l++) { tdata->pList[l].x = (data->pList[l].x - centerX) * ParentData->proportion + centerX; tdata->pList[l].y = (data->pList[l].y - centerY) * ParentData->proportion + centerY; } DataList->Add(tdata); } buffer = buffer + "\t\t\n"; // ------------------------------------------ result = "\t"; for (int k = 0; k < nSegment; k++) { for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; centerX = ParentData->centerX; // - Src.Left; centerY = ParentData->centerY; // - Src.Top; for (int l = 0; l < data->nCount * 3 + 1; l++) { data->pList[l].x = data->pList[l].x - centerX + pTempList[3 * k].x; data->pList[l].y = data->pList[l].y - centerY + pTempList[3 * k].y; } for (int l = 0; l < data->nCount * 3 + 1; l++) { double dx = data->pList[l].x - pTempList[3 * k].x; double dy = data->pList[l].y - pTempList[3 * k].y; data->pList[l].x = dx * cos(tangentlist[k]) - dy * sin(tangentlist[k]) + pTempList[3 * k].x; data->pList[l].y = dx * sin(tangentlist[k]) + dy * cos(tangentlist[k]) + pTempList[3 * k].y; } SET_RECT; // gradientfill if (!data->Equal(MainImageForm->Number)) continue; if (!InRectMethod(Src, data, method, bRange)) continue; if (bRange) { FirstX = data->First.x - Src.Left; FirstY = data->First.y - Src.Top; SecondX = data->Second.x - Src.Left; SecondY = data->Second.y - Src.Top; } else { FirstX = data->First.x; FirstY = data->First.y; SecondX = data->Second.x; SecondY = data->Second.y; } pw = data->PenThick; if (data->Kind == V_TEXTBOX) { //pPoints = new POINT[5]; pPoints = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * 5); } else { if (data->bClosed && data->PenStyle == P_SOLID) { //pPoints = new POINT[(data->nCount + 1) * 3 + 1]; pPoints = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * ((data->nCount + 1) * 3 + 1)); } else { //pPoints = new POINT[data->nCount * 3 + 1]; pPoints = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * (data->nCount * 3 + 1)); } } if (data->Kind == V_CURVE || data->Kind == V_LINE) { for (int i = 0; i < data->nCount * 3 + 1; i++) { if (bRange) { pPoints[i].x = data->pList[i].x - Src.Left; pPoints[i].y = data->pList[i].y - Src.Top; } else { pPoints[i].x = data->pList[i].x; pPoints[i].y = data->pList[i].y; } } if (data->bClosed && data->PenStyle == P_SOLID) { // by maxleo21c 070626 Ãß°¡ pPoints[data->nCount * 3] = pPoints[0]; } } if (data->bPatternFill) { // PatternFill À϶§ MakePatternBitmap(data); patternFill_ID++; } switch(data->Kind) { case V_LINE: tvector2svg->SVGDrawLine(result, pPoints, data->nCount + 1, data->Color, data->Brush, data->bFill, data->bWinding, pw); if (result.Length() == 0) break; buffer += result; result = "\t"; break; case V_CURVE: if (data->ParentTextBox) break; // by maxleo21c(06.06.09) tvector2svg->SVGDrawCurve(result, pPoints, data, dn, fn, i, patternFill_ID); if (result.Length() == 0) break; buffer += result; result = "\t"; break; case V_RECT: tvector2svg->SVGDrawRect(result, FirstX, FirstY, SecondX, SecondY, data->Color, data->Brush); if (result.Length() == 0) break; buffer += result; result = "\t"; break; case V_ELLIPSE: tvector2svg->SVGDrawEllipse(result, FirstX, FirstY, SecondX, SecondY, data->Color, data->Brush); if (result.Length() == 0) break; buffer += result; result = "\t"; break; case V_TEXT: tvector2svg->SVGDrawText(result, FirstX, FirstY, data->TextString, data->nCount, data->Font, data->Color); if (result.Length() == 0) break; buffer += result; result = "\t"; break; case V_TEXTBOX: if (bRange) { StartX = data->StartPoint.x - Src.Left; StartY = data->StartPoint.y - Src.Top; } else { StartX = data->StartPoint.x; StartY = data->StartPoint.y; } if (data->TextAngle) { if (bRange) { cx = data->CenterPoint.x - Src.Left; cy = data->CenterPoint.y - Src.Top; } else { cx = data->CenterPoint.x; cy = data->CenterPoint.y; } tx = StartX - cx; ty = cy - StartY; angle = (double)data->TextAngle / 180 * M_PI; StartX = tx * cos(-angle) + ty * sin(-angle) + cx; StartY = cy - (-tx * sin(-angle) + ty * cos(-angle)); } if (data->ListOfAllLine->CurveData) { tvector2svg->SVGDrawTextPath(result, data, StartX, StartY, i, patternFill_ID); if (result.Length() == 0) break; buffer += result; result = "\t"; } else { if (!tvector2svg->SVGDrawTextBox(result, data, StartX, StartY)) { // 070807 #ifdef SK_SMART // "Text data¿¡ ¿À·ù°¡ ÀÖ½À´Ï´Ù. ´Ù½Ã ÀÛ¼ºÇØ Áֽñ⠹ٶø´Ï´Ù." Application->MessageBox(IDS_MESSAGE011.c_str(), L"Warning", MB_OK); #endif goto fail; } if (result.Length() == 0) break; buffer += result; result = "\t"; } break; } //if (pPoints) delete[]pPoints; if (pPoints) HeapFree(GetProcessHeap(), 0, pPoints); pPoints = NULL; // 20090220 °¢µµº¯È¯ reverseÇÊ¿ä for (int l = 0; l < data->nCount * 3 + 1; l++) { double dx = data->pList[l].x - pTempList[3 * k].x; double dy = data->pList[l].y - pTempList[3 * k].y; data->pList[l].x = dx * cos(-tangentlist[k]) - dy * sin (-tangentlist[k]) + pTempList[3 * k].x; data->pList[l].y = dx * sin(-tangentlist[k]) + dy * cos (-tangentlist[k]) + pTempList[3 * k].y; } for (int l = 0; l < data->nCount * 3 + 1; l++) { data->pList[l].x = data->pList[l].x + centerX - pTempList[3 * k].x; data->pList[l].y = data->pList[l].y + centerY - pTempList[3 * k].y; } } // DataList } // segment buffer = buffer + "\n\t"; buffer = buffer + tvector2svg->MakeMotiveCDATA(ParentData); buffer = buffer + "\n\t\n"; if (DataList) { for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (data) delete data; } DataList->Clear(); delete DataList; DataList = NULL; } if (tangentlist) delete[]tangentlist; tangentlist = NULL; // ¸Þ¸ð¸® ÇØÁ¦ - by monkman (2009.04.16) if (pTempList) { HeapFree(GetProcessHeap(), 0, pTempList); } pTempList = NULL; if (pPoints) HeapFree(GetProcessHeap(), 0, pPoints); pPoints = NULL; END_LOG; return true; fail: buffer = ""; if (DataList) { for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (data) delete data; } DataList->Clear(); delete DataList; } if (tangentlist) delete[]tangentlist; tangentlist = NULL; // ¸Þ¸ð¸® ÇØÁ¦ - by monkman (2009.04.16) if (pTempList) { HeapFree(GetProcessHeap(), 0, pTempList); } pTempList = NULL; //if (pPoints) delete[]pPoints; if (pPoints) HeapFree(GetProcessHeap(), 0, pPoints); pPoints = NULL; END_LOG; return false; } // --------------------------------------------------------------------------- /** SVG file load * added for SVG by maxleo21c(06.06.17) */ // bool __fastcall TVecDraw::LoadFromSVGFile(String dn, String fn, TEXPIAFILEHEADER &tpfh, // TUnit mainUnit) bool __fastcall TVecDraw::LoadFromSVGFile(String dn, String fn, TEXPIAFILEHEADER &tpfh, TUnit mainUnit, TList *_DataList) { BEGIN_LOG(""); bool isOK = true; TList *dataList = NULL; if (_DataList) dataList = _DataList; else dataList = NVector->DataList; String fname = dn + String("\\") + fn; // 06.09.20 by maxleo21c String tname = String(DirectoryBin + "\\") + fn; String t_name; if (!CopyFile(fname.c_str(), tname.c_str(), false)) { // delete tSVG2Vector; END_LOG; return false; } t_name = tname.SubString(0, tname.Length() - 3); t_name += String("xml"); RenameFile(tname, t_name); ::TSVG2Vector *tSVG2Vector = NULL; tSVG2Vector = new ::TSVG2Vector(VectorForm->XMLDocument1, dataList, MainImageForm->Number); isOK = tSVG2Vector->LoadFromFile(dn, t_name, mainUnit); TTinyXML::TSVG2Vector *tinySVG2Vector = NULL; if (isOK) { if (tSVG2Vector->Width > 0 && tSVG2Vector->Height > 0) { tpfh.CanvasInfor.SetSize(cstFree, tSVG2Vector->Width, tSVG2Vector->Height); FontCheckAndChange(); } else { isOK = false; } delete tSVG2Vector; tSVG2Vector = NULL; } else { tinySVG2Vector = new TTinyXML::TSVG2Vector(dataList, MainImageForm->Number); isOK = tinySVG2Vector->LoadFromFile(dn, t_name, mainUnit); if (isOK == false) goto fail; if (tinySVG2Vector->Width > 0 && tinySVG2Vector->Height > 0) { tpfh.CanvasInfor.SetSize(cstFree, tinySVG2Vector->Width, tinySVG2Vector->Height); FontCheckAndChange(); } else { isOK = false; } delete tinySVG2Vector; tinySVG2Vector = NULL; } DeleteFile(t_name); END_LOG; return true; fail: DeleteFile(t_name); if (tSVG2Vector) delete tSVG2Vector; if (tinySVG2Vector) delete tinySVG2Vector; END_LOG; return false; } // --------------------------------------------------------------------------- /// Vector file¿¡¼­ palette(TPalette), tpfh(TEXPIAFILEHEADER)¸¦ load TPException __fastcall TVecDraw::LoadVector(HANDLE fh, TPalette *pPalette, TEXPIAFILEHEADER &tpfh, bool bTrialVersion) { BEGIN_LOG(""); WORD BitCount; TPException ec = EC_NONE; DWORD dwRead; int Version; // plata0 : C++ Builder 6 ´À·ÁÁö´Â ¹®Á¦ ÃßÀûÁß // ¿©±â±îÁö´Â ´À·ÁÁöÁö ¾ÊÀ½ ///////////////////////////////// Start of Standard Tag Format #ifdef TRIAL // TrialVersion ó¸® if (bTrialVersion == true) { TEXPIAFILEHEADER_TRIAL temp; if (!ReadFile(fh, &temp, sizeof(TEXPIAFILEHEADER), &dwRead, NULL)) goto fail; tpfh.Version = temp.Version; tpfh.CanvasInfor = temp.CanvasInfor; tpfh.BitsPerPixel = temp.BitsPerPixel; tpfh.Compress = temp.Compress; } else { if (!ReadFile(fh, &tpfh, sizeof(TEXPIAFILEHEADER), &dwRead, NULL)) goto fail; } #else if (!ReadFile(fh, &tpfh, sizeof(TEXPIAFILEHEADER), &dwRead, NULL)) goto fail; #endif WORD useColor; if (!ReadFile(fh, &useColor, sizeof(Word), &dwRead, NULL)) goto fail; pPalette->UseColor = useColor; if (tpfh.Version.Number <= 301) { pPalette->LoadFromFileHandle(fh, 1); } else { pPalette->LoadFromFileHandle(fh, 2); } if (!ReadFile(fh, &BitCount, sizeof(WORD), &dwRead, NULL)) goto fail; if (SetFilePointer(fh, BitCount == 8 ? 8000 : 24000, NULL, FILE_CURRENT) == 0xFFFFFFFF) goto fail; ///////////////////////////////// End of Standard Tag Format //////////////free and realloc // Create(tpfh.CanvasInfor.Width,tpfh.CanvasInfor.Height); ////////////// if (!ReadFile(fh, &Version, sizeof(int), &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } if (Version < 100) { // ec = EC_FILE_OLD_VERSION; goto fail; ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } else { // if ((ec = LoadDataFromFile(fh))!=EC_NONE) goto fail; } END_LOG; return EC_NONE; fail: if (fh != INVALID_HANDLE_VALUE) CloseHandle(fh); END_LOG; return ec; } // --------------------------------------------------------------------------- /** File¿¡¼­ Vector load * Version : 140 - TextBox¸¦ ³ÖÀºÈÄ º¯°æ * Version : 150 - Gdiplus Àû¿ë ÈÄ º¯°æ 2005 Vector Upgrade Shin 0317 * Version : 160 - GradientFill Ãß°¡ & group index ±¸Á¶ ¼öÁ¤ ÈÄ º¯°æ * Version : 170 - Motive Object Ãß°¡ * Version : 180 - Unicode Ãß°¡ * Version : 181 - Arrow ¼öÁ¤ * Version : 182 - Line Arrow ¼öÁ¤ */ bool __fastcall TVecDraw::LoadVectorFromFile(HANDLE fh, bool bTrialVersion) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL, *childdata = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) int Version, count; int existindex = 0, index = 0, existcount; // ±âÁ¸¿¡ Á¸ÀçÇÏ´Â indexÆÇº°, »ðÀÔÇÒ index number, ±âÁ¸ÀÇ objectÀÇ °¹¼ö int srcMaxGroupIndex = 0; // load¸¦ ÇØ¿À´Â objectÁß °¡Àå Å« index¸¦ ÀúÀå by siuaa 080501 POINT *pPoints = NULL; // pPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) DWORD dwRead; bool sw = true; EDataCode Code; int linecount, wordcount, lineheight; RECT rect; MaxThick = 0; if (!ReadFile(fh, &Code, sizeof(EDataCode), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &Version, sizeof(int), &dwRead, NULL)) goto fail; // Version : 140 - TextBox¸¦ ³ÖÀºÈÄ º¯°æ // Version : 150 - Gdiplus Àû¿ë ÈÄ º¯°æ 2005 Vector Upgrade Shin 0317 // Version : 160 - GradientFill Ãß°¡ & group index ±¸Á¶ ¼öÁ¤ ÈÄ º¯°æ // Version : 170 - Motive Object Ãß°¡ // Version : 180 - Unicode Ãß°¡ // Version : 181 - Arrow ¼öÁ¤ // Version : 182 - Line Arrow ¼öÁ¤ if (Version != 100 && Version != 110 && Version != 120 && Version != 130 && Version != 140 && Version != 150 && Version != 160 && Version != 170 && Version != 180 && Version != 181 && Version != 182) goto fail; if (!ReadFile(fh, &count, sizeof(int), &dwRead, NULL)) goto fail; existcount = DataList->Count; if (count) { deSelect(); NVector->bSelected = true; PasteRange = Rect(50000, 50000, 0, 0); } #ifdef TRIAL if (bTrialVersion == true) { char garbage[6]; for (int i = 0; i < 10; i++) if (!ReadFile(fh, garbage, sizeof(char) * 6, &dwRead, NULL)) { END_LOG; return false; } } #endif for (int i = 0; i < count; i++) { if ((data = new TVecData(MainImageForm->Number)) == NULL) goto fail; if (!ReadFile(fh, &data->Kind, sizeof(EVecKind), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->First, sizeof(POINT), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->Second, sizeof(POINT), &dwRead, NULL)) goto fail; // Version 150 Ãß°¡ if (Version >= 150) { if (!ReadFile(fh, &data->bAntialiasing, sizeof(bool), &dwRead, NULL)) goto fail; } else { data->bAntialiasing = false; } int tempThick; switch(data->Kind) { case V_LINE: case V_CURVE: if (!ReadFile(fh, &data->PenStyle, sizeof(EPenStyle), &dwRead, NULL)) goto fail; if (Version >= 150) { if (!ReadFile(fh, &data->PenThick, sizeof(double), &dwRead, NULL)) goto fail; } else { if (!ReadFile(fh, &tempThick, sizeof(int), &dwRead, NULL)) goto fail; data->PenThick = (double)tempThick; } // if (!ReadFile(fh, &data->PenThick, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->nCount, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->bRound, sizeof(bool), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->bFill, sizeof(bool), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->bWinding, sizeof(bool), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->Color, sizeof(TColor), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->Brush, sizeof(TColor), &dwRead, NULL)) goto fail; // ===7.41, Version 110 Ãß°¡ if (Version >= 110) { if (!ReadFile(fh, &data->bClosed, sizeof(bool), &dwRead, NULL)) goto fail; // if (!ReadFile(fh, &data->GroupIndex, sizeof(int), &dwRead, NULL)) goto fail; if (Version < 160) // 9.2 ÀÌÇÏ ¹öÀüÀÇ groupÀ» ÀÐ¾î ¿À±â À§ÇØ { int temp; if (!ReadFile(fh, &temp, sizeof(int), &dwRead, NULL)) goto fail; int tempIndex = 0; for (int i = 0; i < 10; i++) // ¹øÈ£°¡ ÀÖ´Â group index¸¦ ÀÐÀ½ { if ((temp & (1 << i))) tempIndex += (1 << i); } for (int i = 10; i < 32; i++) // ¹øÈ£°¡ ¾ø´Â group index¸¦ ÀÐÀ½ { if ((temp & (1 << i))) { tempIndex += ((i - 9) * 10000); break; } } data->GroupIndex = tempIndex; if (srcMaxGroupIndex < tempIndex / 10000) srcMaxGroupIndex = tempIndex / 10000; } else { if (!ReadFile(fh, &data->GroupIndex, sizeof(int), &dwRead, NULL)) goto fail; if (srcMaxGroupIndex < data->GroupIndex / 10000) srcMaxGroupIndex = data->GroupIndex / 10000; } } // ========================= 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); if (Version <= 110) { // 7.41ÀÌÇÏ¿¡¼­´Â DPOINT¸¦ »ç¿ëÇÏÁö ¾Ê¾Ò´Ù if (data->Kind == V_TEXTBOX) { pPoints = new POINT[5]; } else { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new POINT[(data->nCount + 1) * 3 + 1]; } else { pPoints = new POINT[data->nCount * 3 + 1]; } } if (!ReadFile(fh, pPoints, sizeof(POINT) * (data->nCount * 3 + 1), &dwRead, NULL)) goto fail; for (int j = 0; j < data->nCount * 3 + 1; j++) data->pList[j].DPoint(pPoints[j]); if (pPoints) delete[]pPoints; pPoints = NULL; } else { if (!ReadFile(fh, data->pList, sizeof(DPOINT) * (data->nCount * 3 + 1), &dwRead, NULL)) goto fail; } // ÃʱâÈ­ memset(data->pMask, 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); if (!ReadFile(fh, &data->bPatternFill, sizeof(bool), &dwRead, NULL)) goto fail; if (data->bPatternFill) { int w, h; if (!ReadFile(fh, &data->PatternAngle, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->PatternAdjustX, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->PatternAdjustY, sizeof(int), &dwRead, NULL)) goto fail; // ====7.43, Version 130 Ãß°¡ Added by maxleo21c (2004/05/11) if (Version >= 130) { if (!ReadFile(fh, &data->RatioX, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->RatioY, sizeof(int), &dwRead, NULL)) goto fail; } // ========================== if (!ReadFile(fh, &w, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &h, sizeof(int), &dwRead, NULL)) goto fail; data->TBitmapSource = new TTexpiaBitmap; if (!data->TBitmapSource->Create(w, h, 24)) goto fail; data->TBitmapSource->LoadFromTexpiaFile(fh, cmZLib); MakePatternBitmap(data); } // Version 150 Ãß°¡ if (Version >= 150) { if (!ReadFile(fh, data->DashValues, sizeof(double) * 7, &dwRead, NULL)) goto fail; int TempCapStyle[2] = {0, 0}; if (!ReadFile(fh, TempCapStyle, sizeof(int) * 2, &dwRead, NULL)) goto fail; data->CapStyle[0] = TempCapStyle[0]; data->CapStyle[1] = TempCapStyle[1]; if (Version >= 181){ if(Version == 181 && data->CapStyle[0] == 2 && data->ArrowCap){ data->ArrowCap->bShowArrowBoth = true; data->ArrowCap->LineCapWidthScale = 1; data->ArrowCap->LineCapWidth = 5; data->ArrowCap->LineCapHeight = 5; data->ArrowCap->LineCapLine = 1; } else if (data->CapStyle[0] && data->ArrowCap){ if (!data->ArrowCap->LoadFromFile(fh)) goto fail; // if (!ReadFile(fh, &data->ArrowCap->bFillLineCap, sizeof(bool), &dwRead, NULL)) // goto fail; // if (!ReadFile(fh, &data->ArrowCap->bShowArrowBoth, sizeof(bool), &dwRead, NULL)) // goto fail; // if (!ReadFile(fh, &data->ArrowCap->LineCapWidthScale, sizeof(double), &dwRead, NULL)) // goto fail; // if (!ReadFile(fh, &data->ArrowCap->LineCapWidth, sizeof(double), &dwRead, NULL)) // goto fail; // if (!ReadFile(fh, &data->ArrowCap->LineCapHeight, sizeof(double), &dwRead, NULL)) // goto fail; } } } // Version 160 Ãß°¡ if (Version >= 160) { if (!ReadFile(fh, &data->bGradientFill, sizeof(int), &dwRead, NULL)) goto fail; if (data->bGradientFill) { if (!ReadFile(fh, &data->gradientItem, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->gAngle, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->gradientColorCount, sizeof(int), &dwRead, NULL)) goto fail; int count = data->gradientColorCount; data->gradientColors = new RGBQUAD[count]; if (!ReadFile(fh, data->gradientColors, sizeof(RGBQUAD) * count, &dwRead, NULL)) goto fail; } } // Version 170 Ãß°¡ 090304 if (Version >= 170) { if (!ReadFile(fh, &data->bMotive, sizeof(int), &dwRead, NULL)) goto fail; if (data->bMotive) { if (!ReadFile(fh, &data->mode, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->gap, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->motivecount, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->proportion, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->childwidth, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->childheight, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->centerX, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->centerY, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->ChildCount, sizeof(int), &dwRead, NULL)) goto fail; for (int i = 0; i < data->ChildCount; i++) { TVecData *childdata = new TVecData(MainImageForm->Number); LoadVectorFile(fh, data, childdata, Version); } } } // ========================= N3D ¿¡¼­ Ãß°¡ - LayerIndex, GridIIndex // if (!ReadFile(fh, &data->LayerIndex, sizeof(int), &dwRead, NULL)) goto fail; // if (bLoadVectorMergeMode) // if (!ReadFile(fh, data->GridIndex, sizeof(int)*8, &dwRead, NULL)) goto fail; // if (!ReadFile(fh, &data->GridCount, sizeof(int), &dwRead, NULL)) goto fail; // if (!ReadFile(fh, &data->top, sizeof(int), &dwRead, NULL)) goto fail; // if (!ReadFile(fh, &data->bottom, sizeof(int), &dwRead, NULL)) goto fail; // data->GridCount = 0; // data->bSelected = true; if (data->bClosed && DataCode == T_TEX3D) data->bFill = true; PasteRange.left = min(PasteRange.left, min(data->First.x, data->Second.x) - data->PenThick * 2); PasteRange.right = max(PasteRange.right, max(data->First.x, data->Second.x) + data->PenThick * 2); PasteRange.top = min(PasteRange.top, min(data->First.y, data->Second.y) - data->PenThick * 2); PasteRange.bottom = max(PasteRange.bottom, max(data->First.y, data->Second.y) + data->PenThick * 2); break; case V_RECT: case V_ELLIPSE: if (!ReadFile(fh, &data->PenStyle, sizeof(EPenStyle), &dwRead, NULL)) goto fail; if (Version >= 150) { if (!ReadFile(fh, &data->PenThick, sizeof(double), &dwRead, NULL)) goto fail; } else { if (!ReadFile(fh, &tempThick, sizeof(int), &dwRead, NULL)) goto fail; data->PenThick = (double)tempThick; } // if (!ReadFile(fh, &data->PenThick, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->bRound, sizeof(bool), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->bFill, sizeof(bool), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->bWinding, sizeof(bool), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->Color, sizeof(TColor), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->Brush, sizeof(TColor), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->bPatternFill, sizeof(bool), &dwRead, NULL)) goto fail; if (data->bPatternFill) LoadObjectBitmap(fh, data); // Version 150 Ãß°¡ if (Version >= 150) { if (!ReadFile(fh, data->DashValues, sizeof(double) * 7, &dwRead, NULL)) goto fail; int TempCapStyle[2] = {0, 0}; if (!ReadFile(fh, TempCapStyle, sizeof(int) * 2, &dwRead, NULL)) goto fail; data->CapStyle[0] = TempCapStyle[0]; data->CapStyle[1] = TempCapStyle[1]; } // Version 160 Ãß°¡ if (Version >= 160) { if (!ReadFile(fh, &data->bGradientFill, sizeof(int), &dwRead, NULL)) goto fail; if (data->bGradientFill) { if (!ReadFile(fh, &data->gradientItem, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->gAngle, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->gradientColorCount, sizeof(int), &dwRead, NULL)) goto fail; int count = data->gradientColorCount; data->gradientColors = new RGBQUAD[count]; if (!ReadFile(fh, data->gradientColors, sizeof(RGBQUAD) * count, &dwRead, NULL)) goto fail; } } // Version 170 Ãß°¡ 090304 if (Version >= 170) { if (!ReadFile(fh, &data->bMotive, sizeof(int), &dwRead, NULL)) goto fail; if (data->bMotive) { if (!ReadFile(fh, &data->mode, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->gap, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->motivecount, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->proportion, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->childwidth, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->childheight, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->centerX, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->centerY, sizeof(double), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->ChildCount, sizeof(int), &dwRead, NULL)) goto fail; for (int i = 0; i < data->ChildCount; i++) { TVecData *childdata = new TVecData(MainImageForm->Number); LoadVectorFile(fh, data, childdata, Version); } } } break; case V_TEXT: if (!ReadFile(fh, &data->Color, sizeof(TColor), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->Font, sizeof(LOGFONT), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->nCount, sizeof(int), &dwRead, NULL)) goto fail; if (Version >= 180) { // Unicode Char w_tempchar; for (int k = 0; k < data->nCount; k++) { if (!ReadFile(fh, &w_tempchar, sizeof(Char), &dwRead, NULL)) goto fail; data->TextString += w_tempchar; } } else { char tempchar; AnsiString tempString; for (int k = 0; k < data->nCount; k++) { if (!ReadFile(fh, &tempchar, sizeof(char), &dwRead, NULL)) goto fail; tempString += tempchar; } data->TextString = (String)tempString; } PasteRange.left = min(PasteRange.left, min(data->First.x, data->Second.x) - data->PenThick * 2); PasteRange.right = max(PasteRange.right, max(data->First.x, data->Second.x) + data->PenThick * 2); PasteRange.top = min(PasteRange.top, min(data->First.y, data->Second.y) - data->PenThick * 2); PasteRange.bottom = max(PasteRange.bottom, max(data->First.y, data->Second.y) + data->PenThick * 2); /* if (data->nCount == 0 || data->TextString.Length() == 0) { delete data; continue; } data->Kind = V_TEXTBOX; ChangeTextToTextBox(data); GetRectForMouseMove(data, rect); PasteRange.left = min(PasteRange.left, rect.left); PasteRange.right = max(PasteRange.right, rect.right); PasteRange.top = min(PasteRange.top, rect.top); PasteRange.bottom = max(PasteRange.bottom, rect.bottom); */ break; case V_TEXTBOX: if (!ReadFile(fh, &data->CharH, sizeof(int), &dwRead, NULL)) goto fail; // ±ÛÀÚÀÇ Å©±â if (!ReadFile(fh, &data->CharW, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->TextAngle, sizeof(double), &dwRead, NULL)) goto fail; // TextBoxÀÇ Angle·Î »ç¿ëµÊ if (!ReadFile(fh, &data->StartPoint, sizeof(POINT), &dwRead, NULL)) goto fail; // ù±ÛÀÚ°¡ ÀÖ´Â À§Ä¡ if (!ReadFile(fh, &data->CenterPoint, sizeof(POINT), &dwRead, NULL)) goto fail; // BoxÀÇ ¹«°ÔÁß½ÉÁ¡ TSWordData *srcWordData; // °¢°¢ÀÇ ¶óÀÎÀ» ÀúÀåÇϰí ÀÖ´Â ºÎºÐÀ» Copy TLineTextBox *tempTLineTextBox; data->ListOfAllLine = new TWordList; // -->by linuxjun for CurvedVectorText if (Version >= 150) { int nTemp; if (!ReadFile(fh, &nTemp, sizeof(int), &dwRead, NULL)) goto fail; if (nTemp >= 0) { // if (NVector->bMergeMode) { nTemp += existcount; // MergeÀÎ °æ¿ì¿¡ ±Û¾¾µû¶óº¤ÅÍ ÆùÆ® ¿¡·¯³ª´ÂºÎºÐ¼öÁ¤ //by linuxjun for CurvedVectorText // } data->ListOfAllLine->CurveData = (TVecData*)DataList->Items[nTemp]; data->ListOfAllLine->CurveData->ParentTextBox = data; } else { data->ListOfAllLine->CurveData = NULL; } } else { data->ListOfAllLine->CurveData = NULL; } // <--by linuxjun for CurvedVectorText if (!ReadFile(fh, &linecount, sizeof(int), &dwRead, NULL)) goto fail; for (int i = 0; i < linecount; i++) { tempTLineTextBox = new TLineTextBox; if (!ReadFile(fh, &wordcount, sizeof(int), &dwRead, NULL)) goto fail; for (int j = 0; j < wordcount; j++) { srcWordData = new TSWordData; if (!ReadFile(fh, &srcWordData->Selected, sizeof(bool), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &srcWordData->PPoint, sizeof(POINT), &dwRead, NULL)) goto fail; if (Version >= 180) { // Unicode if (!ReadFile(fh, &srcWordData->LFont, sizeof(LOGFONT), &dwRead, NULL)) goto fail; if (!ReadFile(fh, srcWordData->Word, sizeof(Char) * 2, &dwRead, NULL)) goto fail; if (!ReadFile(fh, &srcWordData->UsedByte, sizeof(int), &dwRead, NULL)) goto fail; } else { char tword[2]; String wString; LOGFONTA LFont; if (!ReadFile(fh, &LFont, sizeof(LOGFONTA), &dwRead, NULL)) goto fail; if (!ReadFile(fh, tword, sizeof(char) * 2, &dwRead, NULL)) goto fail; wString = String(tword); // _tcscpy(srcWordData->Word, wString.c_str()); srcWordData->Word[0] = wString.c_str()[0]; srcWordData->Word[1] = 0; Copy_From_LOGFONTA_To_LOGFONTW(LFont, srcWordData->LFont); if (!ReadFile(fh, &srcWordData->UsedByte, sizeof(int), &dwRead, NULL)) goto fail; srcWordData->UsedByte = 1; } if (!ReadFile(fh, &srcWordData->Color, sizeof(TColor), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &srcWordData->Interval, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &srcWordData->HeightGap, sizeof(float), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &srcWordData->WidthGap, sizeof(float), &dwRead, NULL)) goto fail; // Version 150 Ãß°¡ if (Version >= 150) { if (!ReadFile(fh, &srcWordData->bNameChanged, sizeof(bool), &dwRead, NULL)) goto fail; // -->by linuxjun for CurvedVectorText if (!ReadFile(fh, &srcWordData->px, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &srcWordData->py, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &srcWordData->tx, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &srcWordData->ty, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &srcWordData->nx, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &srcWordData->ny, sizeof(int), &dwRead, NULL)) goto fail; // <--by linuxjun for CurvedVectorText } else { srcWordData->bNameChanged = false; } tempTLineTextBox->LineDataList->Add(srcWordData); } if (!ReadFile(fh, &lineheight, sizeof(int), &dwRead, NULL)) goto fail; tempTLineTextBox->lineHeight = lineheight; // lineHeight ÀúÀå data->ListOfAllLine->Add(tempTLineTextBox); } data->pList = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * 5); data->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, 1); if (!ReadFile(fh, data->pList, sizeof(DPOINT) * 5, &dwRead, NULL)) goto fail; if (!ReadFile(fh, &data->nCount, sizeof(int), &dwRead, NULL)) goto fail; if (!(data->ListOfAllLine && data->ListOfAllLine->CurveData)) { // by linuxjun for CurvedVectorText(Load) GetRectForMouseMove(data, rect); // asdfasdf PasteRange.left = min(PasteRange.left, rect.left); PasteRange.right = max(PasteRange.right, rect.right); PasteRange.top = min(PasteRange.top, rect.top); PasteRange.bottom = max(PasteRange.bottom, rect.bottom); } // ÃʱâÈ­ memset(data->pMask, 0, 1); break; } DataList->Add(data); UndoSave(VU_CREATE, DataList->Count - 1, sw); sw = false; } // 2005 Vector Upgrade Shin 0317 // font check, open ¿©ºÎ ¹Ýȯ : falseÀÌ¸é ¿­Áö ¾ÊÀ½. FontCheckAndChange(); // if (!FontCheckAndChange()) goto fail; // =========== Group Index¸¦ ÀçÁöÁ¤ÇØÁÖ´Â ºÎºÐ /* //===========±âÁ¸ objectµéÀÇ indexÃ߸®±â for (int i = 0; i < existcount; i++) { data = (TVecData *)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->GroupIndex) continue; existindex |= data->GroupIndex; } //========= Group Index ÁöÁ¤ (»õ·Î¿î index·Î »ðÀÔ) for (int k = 10; k < 32; k++) { // µé¾î°¥ GroupindexÁöÁ¤ for (int i = 10; i < 32; i++) { if (existindex & (1 << i)) continue; index = i; break; } for (int i = existcount; i < DataList->Count; i++) { data = (TVecData *)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (data->bSelected) continue; // ÀÌ¹Ì Çѹø ÁöÁ¤µÇ¾îÀÖ´Â °æ¿ì´Â º¸³½´Ù if (!(data->GroupIndex & (1<GroupIndex &= 0x000001ff; data->GroupIndex += 1<bSelected = true; existindex |= 1<Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (data->bSelected) continue; if (data->GroupIndex / 10000 != k) continue; if (sw) { MainImageForm->GroupIndexState += 10000; sw = false; } data->GroupIndex = ((data->GroupIndex % 10000) & 0x000001ff) + MainImageForm->GroupIndexState; data->bSelected = true; } } for (int i = existcount; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (data->ListOfAllLine && data->ListOfAllLine->CurveData) continue; data->bSelected = true; } // ================== for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; data->First.x -= PasteRange.left; data->Second.x -= PasteRange.left; data->First.y -= PasteRange.top; data->Second.y -= PasteRange.top; if (data->Kind == V_LINE || data->Kind == V_CURVE) { for (int j = 0; j < data->nCount * 3 + 1; j++) { data->pList[j].x -= PasteRange.left; data->pList[j].y -= PasteRange.top; } } if (data->Kind == V_TEXTBOX) { // -->by linuxjun for CurvedVectorText if (!data->ListOfAllLine->CurveData) { // <--by linuxjun for CurvedVectorText data->StartPoint.x -= PasteRange.left; data->StartPoint.y -= PasteRange.top; for (int k = 0; k < 5; k++) { data->pList[k].x -= PasteRange.left; data->pList[k].y -= PasteRange.top; } data->CenterPoint.x = (data->First.x + data->Second.x) / 2; data->CenterPoint.y = (data->First.y + data->Second.y) / 2; // todo: ij·ÔÀ» ó¸®Çϱâ À§Çؼ­ (¹Ú»óÈÆ) CenterPoint.x = data->CenterPoint.x; CenterPoint.y = data->CenterPoint.y; } } } PasteRange = Rect(50000, 50000, 0, 0); for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->Kind == V_TEXTBOX) { if (data->ListOfAllLine->CurveData) continue; GetRectForMouseMove(data, rect); PasteRange.left = min(PasteRange.left, rect.left); PasteRange.right = max(PasteRange.right, rect.right); PasteRange.top = min(PasteRange.top, rect.top); PasteRange.bottom = max(PasteRange.bottom, rect.bottom); } else { PasteRange.left = min(PasteRange.left, min(data->First.x, data->Second.x) - data->PenThick * 2); PasteRange.right = max(PasteRange.right, max(data->First.x, data->Second.x) + data->PenThick * 2); PasteRange.top = min(PasteRange.top, min(data->First.y, data->Second.y) - data->PenThick * 2); PasteRange.bottom = max(PasteRange.bottom, max(data->First.y, data->Second.y) + data->PenThick * 2); } } if (count) NVector->bMergeMode = true; pPoints = NULL; END_LOG; return true; fail: if (pPoints) delete[]pPoints; pPoints = NULL; END_LOG; return false; } // --------------------------------------------------------------------------- /** DXF Format Load * Creation Date : 2003.11.26 * Programming by monkman */ TPException __fastcall TVecDraw::LoadExternalVector(String FileName, TPalette *pPalette, TEXPIAFILEHEADER &tpfh, TList *_DataList) { BEGIN_LOG(""); // DXF File Àбâ TPException ec = EC_NONE; TList *DataList = NULL; if (_DataList) DataList = _DataList; else DataList = NVector->DataList; // --------------------------------------------------------------------------- // ======== DXF Format Load ºÎºÐ //=========================================== // --------------------------------------------------------------------------- // Creation Date : 2003.11.26 // Programming by monkman // --------------------------------------------------------------------------- CDXF dxf; TVecData *data; String buf; // ¹è¿­ÀÇ Ä«¿îÆ®¸¦ 0À¸·Î ¼ÂÆÃ dxf.SetCount(0); TStringList *sf = new TStringList; TStringList *tempStringList = new TStringList; // ÆÄÀÏÀ» ÇÑ ¶óÀξ¿ Àо TStringList¿¡ ´ã´Â´Ù // sf->LoadFromFile(FileName); tempStringList->LoadFromFile(FileName); for (int idx = 0; idx < tempStringList->Count; idx++) { sf->Add(String(tempStringList->Strings[idx])); } delete tempStringList; int g_code; bool continue_flag; dxf.DeleteContents(); if (dxf.Find_Header(sf, dxf.min_x, dxf.min_y, dxf.max_x, dxf.max_y) == FALSE) { END_LOG; return FALSE; } dxf.AllocTable(); if (dxf.Find_Table(sf) == FALSE) { dxf.DeleteTable(); END_LOG; return FALSE; } if (dxf.Find_Block(sf) == FALSE) { dxf.DeleteTable(); END_LOG; return FALSE; } // Blocks or Entities SECTION if (dxf.Find_Entry(sf, 0, L"SECTION") == FALSE) { dxf.DeleteTable(); END_LOG; return FALSE; } if (dxf.Find_Entry(sf, 2, L"ENTITIES") == FALSE) { dxf.DeleteTable(); END_LOG; return FALSE; } // DXF ·Îµù½Ã ÇØ»óµµ Á¶Àý dxf.tw = dxf.max_x - dxf.min_x; dxf.th = dxf.max_y - dxf.min_y; // A4 ±âÁØ Å×½ºÆ®.. // dxf.f = 1248.0/dxf.tw; // dxf.TW = 1760.0; // ÀåÃà°ú ´ÜÃàÀ» ºñ±³Çؼ­ ªÀº ÂÊÀ» ³Ö¾îÁØ´Ù if (dxf.tw < dxf.th) // DXFÀÇ ¼¼·ÎÃàÀÌ ±ä °æ¿ì { dxf.f = (tpfh.CanvasInfor.Width) / dxf.th; dxf.TW = dxf.tw * dxf.f; dxf.TH = tpfh.CanvasInfor.Width; } else // DXFÀÇ °¡·ÎÃàÀÌ ±ä °æ¿ì { dxf.f = (tpfh.CanvasInfor.Width) / dxf.tw; dxf.TW = tpfh.CanvasInfor.Width; dxf.TH = dxf.th * dxf.f; } dxf.SetSizeXY(dxf.tw, dxf.th); // ±×¸®±â continue_flag = TRUE; while (continue_flag) { g_code = dxf.GetLine(sf, buf); switch(g_code) { case DXF_ERR: { continue_flag = FALSE; break; } case 0: // file section mark if (buf == "EOF") { continue_flag = FALSE; break; } else if (buf == "ENDSEC") { continue_flag = FALSE; break; } else if (buf == "POINT") { data = new TVecData(MainImageForm->Number); if (dxf.DrawPoint(sf, data)) { DataList->Add(data); } else if (data) { delete data; } } else if (buf == "LINE") { data = new TVecData(MainImageForm->Number); if (dxf.DrawLine(sf, data)) { DataList->Add(data); } else if (data) { delete data; } } else if (buf == "CIRCLE") { data = new TVecData(MainImageForm->Number); if (dxf.DrawCircle(sf, data)) { DataList->Add(data); } else if (data) { delete data; } } else if (buf == "ARC") { // todo : ARC ±¸ÇöÀº ´ÙÀ½ ¹öÀü¾÷¶§.. - by monkman // data = new TVecData(MainImageForm->Number); // if (dxf.DrawArc(sf, data)) DataList->Add(data); // else delete data; } else if (buf == "POLYLINE") { data = new TVecData(MainImageForm->Number); if (dxf.DrawPolyline(sf, data)) { DataList->Add(data); } else if (data) { delete data; } } else if (buf == "ELLIPSE") { data = new TVecData(MainImageForm->Number); if (dxf.DrawEllipse(sf, data)) { DataList->Add(data); } else if (data) { delete data; } } else if (buf == "TEXT") { data = new TVecData(MainImageForm->Number); if (dxf.DrawText(sf, data)) { DataList->Add(data); } else if (data) { delete data; } } else if (buf == "SOLID") { data = new TVecData(MainImageForm->Number); if (dxf.DrawSolid(sf, data)) { DataList->Add(data); } else if (data) { delete data; } } else if (buf == "INSERT") { data = new TVecData(MainImageForm->Number); if (dxf.DrawInsert(sf, data)) { DataList->Add(data); } else if (data) { delete data; } } else if (buf == "SPLINE") { data = new TVecData(MainImageForm->Number); if (dxf.DrawSpline(sf, data)) { DataList->Add(data); } else if (data) { delete data; } } else if (buf == "LWPOLYLINE") { data = new TVecData(MainImageForm->Number); if (dxf.DrawLWPolyline(sf, data)) { DataList->Add(data); } else if (data) { delete data; } } else if (buf == "MTEXT") { // todo : MTEXT ±¸ÇöÀº ´ÙÀ½ ¹öÀü¾÷¶§.. - by monkman // data = new TVecData(MainImageForm->Number); // if (dxf.DrawMText(sf, data)) DataList->Add(data); // else delete data; } break; } } dxf.DeleteTable(); delete sf; END_LOG; return EC_NONE; fail: END_LOG; return ec; } // --------------------------------------------------------------------------- /** file ÀúÀå. * - Method * -# Method 2 : ÇÑ Á¡ÀÌ¶óµµ Area¾È¿¡ Àִ°æ¿ì ÀúÀå * -# Method 3 : ÇÑ Á¡ÀÌ¶óµµ Area¹Û¿¡ ÀÖÀ¸¸é ÀúÀåÇÏÁö ¾ÊÀ½ * -# Method 4 : ¼±ÅÃµÈ Object¸¸ ÀúÀåµÊ * -# Method 5 : Motive Object ÀúÀåÀ¸·Î ÀÛ¾÷±¸¿ª°ú »ó°ü¾øÀÌ ÀúÀåÇÑ´Ù. // 090811 Áߺ¹ ÁöÁ¤À» À§ÇØ ¼öÁ¤ by david // 00000000 00000000 00000000 00000001 Bit·Î ó¸® * -# Method 00000001(1) : Default * -# Method 00000010(2) : ÇÑ Á¡ÀÌ¶óµµ Area¾È¿¡ Àִ°æ¿ì ÀúÀå * -# Method 00000100(4) : ÇÑ Á¡ÀÌ¶óµµ Area¹Û¿¡ ÀÖÀ¸¸é ÀúÀåÇÏÁö ¾ÊÀ½ * -# Method 00001000(8) : ¼±ÅÃµÈ Object¸¸ ÀúÀåµÊ * -# Method 00010000(16) : Motive Object ÀúÀåÀ¸·Î ÀÛ¾÷±¸¿ª°ú »ó°ü¾øÀÌ ÀúÀåÇÑ´Ù. * -# Method 00100000(32) : Style Data(Color´Â ºí·¢, ColorFill, Pattern, Gradient Á¦¿Ü Çϰí ÀúÀå) * - Version * -# Version 7.4 : 100, 7.41 : 110, 7.42 : 120, 7.43 : 130 * -# Version : 140 - TextBox¸¦ ³ÖÀºÈÄ º¯°æ (04.10.26) * -# Version : 150 - Gdiplus Àû¿ë ÈÄ º¯°æ 2005 Vector Upgrade Shin 0317 * -# Version : 160 - GradientFill ³Ö°í º¯°æ (08.04.03 - version 9.2) * -# Version : 170 - MotiveObject ³Ö°í º¯°æ (09.03.20) * -# Version : 180 - Unicode ³Ö°í º¯°æ (10.07.29) * -# Version : 181 - Arrow ¼öÁ¤(µ¥ÀÌÅÍÃß°¡) (11.07.19) * -# Version : 182 - Line Arrow ¼öÁ¤(µ¥ÀÌÅÍÃß°¡) (18.12.18) */ // bool __fastcall TVecDraw::SaveToFile(HANDLE fh, TList *DataList, int method, bool IsOldVersion) bool __fastcall TVecDraw::SaveToFile(HANDLE fh, TList *DataList, int method, int textileVersion, int nInstNum) { BEGIN_LOG(""); DPOINT *pPoints = NULL; // pPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) // TList *DataList = NVector->DataList; // MainImageForm¿¡ ÀÖ´Â DataList ¸»°í ´Ù¸¥ ¸®½ºÆ®µµ ¹ÞÀ» ¼ö ÀÖµµ·Ï ó¸® if (DataList == NULL) DataList = NVector->DataList; int Version = 182, count = 0; // if(IsOldVersion == true) // Version = 120; if (textileVersion == TextileFileVersionOld) Version = 120; else if (textileVersion == TextileFileVersion10) Version = 160; else Version = 182; bool isVector, bRange = false; bool bColorfill = false, bPatternfill = false, bGradientfill = false; TColor tColor = clBlack, tBrush = clBlack; bool bMessageBoxForStyleData = false; DWORD dwWrite; TRect Src; int linecount, wordcount, lineheight; TSWordData *srcWordData; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) if (nInstNum == -1) nInstNum = MainImageForm->Number; // if (MainImageForm->WorkArea->Mask && method != 5) { // ÀÛ¾÷±¸¿ªÀÌ ÀÖ´Â °æ¿ì¿¡´Â ¿µ¿ªÀÇ »çÀÌÁî¿¡ ¸ÂÃß¾î shift~ if (MainImageForm->WorkArea->Mask && !(method & 8) && !(method & 16)) { // ÀÛ¾÷±¸¿ªÀÌ ÀÖ´Â °æ¿ì¿¡´Â ¿µ¿ªÀÇ »çÀÌÁî¿¡ ¸ÂÃß¾î shift~ bRange = true; Src = MainImageForm->WorkArea->Range; } for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (data->nCount <= 0) continue; // if (method != 5 && !data->Equal(MainImageForm->Number)) continue; if (!(method & 16) && (!data->Equal(nInstNum))) continue; // if (method == 4 && !data->bSelected) continue; if ((method & 8) && !data->bSelected) continue; // INRECTMETHOD; if (!InRectMethod(Src, data, method, bRange)) continue; count++; } if (count > 0) isVector = true; else isVector = false; if (!WriteFile(fh, &isVector, sizeof(bool), &dwWrite, NULL)) goto fail; if (!isVector) { END_LOG; return true; } if (!WriteFile(fh, &Version, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &count, sizeof(int), &dwWrite, NULL)) goto fail; // 2005 Vector Upgrade Shin 0317 if (NVector->bFontChange) FontCheckAndChange(true); for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (data->nCount <= 0) continue; if (Version < 170 && data->bMotive == true) continue; // if (method != 5 && !data->Equal(MainImageForm->Number)) continue; if (!(method & 16) && (!data->Equal(nInstNum))) continue; // if (method == 4 && !data->bSelected) continue; if (method & 8 && !data->bSelected) continue; // INRECTMETHOD; if (!InRectMethod(Src, data, method, bRange)) continue; if (!WriteFile(fh, &data->Kind, sizeof(EVecKind), &dwWrite, NULL)) goto fail; if (bRange) { POINT TempFirst, TempSecond; TempFirst.x = data->First.x - Src.Left; TempFirst.y = data->First.y - Src.Top; TempSecond.x = data->Second.x - Src.Left; TempSecond.y = data->Second.y - Src.Top; if (!WriteFile(fh, &TempFirst, sizeof(POINT), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &TempSecond, sizeof(POINT), &dwWrite, NULL)) goto fail; } else { if (!WriteFile(fh, &data->First, sizeof(POINT), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->Second, sizeof(POINT), &dwWrite, NULL)) goto fail; } // Version 150 Ãß°¡ if (Version >= 150) { if (!WriteFile(fh, &data->bAntialiasing, sizeof(bool), &dwWrite, NULL)) goto fail; } // 090811 by david // StyleÀº VST, TEX¿¡¼­ bGradientfillÀ» Æ÷ÇÔÇÏÁö ¾Ê´Â´Ù. if (method & 32) { tColor = clBlack, tBrush = clBlack; bColorfill = false; bPatternfill = false; bGradientfill = false; if (data->bFill || data->bPatternFill || data->bGradientFill || data->Color != clBlack || data->Brush != clBlack) { bMessageBoxForStyleData = true; } } else { tColor = data->Color, tBrush = data->Brush; bColorfill = data->bFill; bPatternfill = data->bPatternFill; bGradientfill = data->bGradientFill; } switch(data->Kind) { case V_LINE: case V_CURVE: if (!WriteFile(fh, &data->PenStyle, sizeof(EPenStyle), &dwWrite, NULL)) goto fail; if (Version >= 150) { if (!WriteFile(fh, &data->PenThick, sizeof(double), &dwWrite, NULL)) goto fail; // 2005 Vector upgrade shin } else { int tempthick; tempthick = (int)data->PenThick; if (tempthick == 0) tempthick = 1; if (!WriteFile(fh, &tempthick, sizeof(int), &dwWrite, NULL)) goto fail; } // if (!WriteFile(fh, &data->PenThick, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->nCount, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->bRound, sizeof(bool), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &bColorfill, sizeof(bool), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->bWinding, sizeof(bool), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &tColor, sizeof(TColor), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &tBrush, sizeof(TColor), &dwWrite, NULL)) goto fail; // ===7.41, Version 110 Ãß°¡ if (!WriteFile(fh, &data->bClosed, sizeof(bool), &dwWrite, NULL)) goto fail; // if (!WriteFile(fh, &data->GroupIndex, sizeof(int), &dwWrite, NULL)) goto fail; if (Version < 160) // 9.2ÀÌÇÏ ¹öÀü¿¡¼­ ÀÐÀ» ¼ö ÀÖµµ·Ï Çϱâ À§ÇØ { int temp = data->GroupIndex; data->GroupIndex = (data->GroupIndex % 10000) & 0x000001ff; temp /= 10000; if (temp > 0 && temp < 24) data->GroupIndex += (1 << (temp + 9)); if (!WriteFile(fh, &data->GroupIndex, sizeof(int), &dwWrite, NULL)) goto fail; } else { if (!WriteFile(fh, &data->GroupIndex, sizeof(int), &dwWrite, NULL)) goto fail; } // ========================= if (bRange) { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new DPOINT[(data->nCount + 1) * 3 + 1]; } else { pPoints = new DPOINT[data->nCount * 3 + 1]; } for (int i = 0; i < data->nCount * 3 + 1; i++) { pPoints[i].x = data->pList[i].x - Src.Left; pPoints[i].y = data->pList[i].y - Src.Top; } if (!WriteFile(fh, pPoints, sizeof(DPOINT) * (data->nCount * 3 + 1), &dwWrite, NULL)) goto fail; if (pPoints) delete[]pPoints; pPoints = NULL; } else { if (!WriteFile(fh, data->pList, sizeof(DPOINT) * (data->nCount * 3 + 1), &dwWrite, NULL)) goto fail; } if (!WriteFile(fh, &bPatternfill, sizeof(bool), &dwWrite, NULL)) goto fail; if (bPatternfill) { int w = data->TBitmapSource->Width, h = data->TBitmapSource->Height; if (!WriteFile(fh, &data->PatternAngle, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->PatternAdjustX, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->PatternAdjustY, sizeof(int), &dwWrite, NULL)) goto fail; // ===7.43, Version 130 Ãß°¡ if (!WriteFile(fh, &data->RatioX, sizeof(int), &dwWrite, NULL)) goto fail; // Added by maxleo21c(2004/05/11) if (!WriteFile(fh, &data->RatioY, sizeof(int), &dwWrite, NULL)) goto fail; // ========================= if (!WriteFile(fh, &w, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &h, sizeof(int), &dwWrite, NULL)) goto fail; data->TBitmapSource->SaveToTexpiaFile(fh, cmZLib); } // Version 150 Ãß°¡ if (Version >= 150) { if (!WriteFile(fh, data->DashValues, sizeof(double) * 7, &dwWrite, NULL)) goto fail; int TempCapStyle[2] = {0, 0}; TempCapStyle[0] = data->CapStyle[0]; TempCapStyle[1] = data->CapStyle[1]; if (!WriteFile(fh, TempCapStyle, sizeof(int) * 2, &dwWrite, NULL)) goto fail; if (Version >= 181){ if (data->CapStyle[0] && data->ArrowCap){ if (!data->ArrowCap->SaveToFile(fh)) goto fail; // if (!WriteFile(fh, &data->ArrowCap->bFillLineCap, sizeof(bool), &dwWrite, NULL)) // goto fail; // if (!WriteFile(fh, &data->ArrowCap->bShowArrowBoth, sizeof(bool), &dwWrite, NULL)) // goto fail; // if (!WriteFile(fh, &data->ArrowCap->LineCapWidthScale, sizeof(double), &dwWrite, NULL)) // goto fail; // if (!WriteFile(fh, &data->ArrowCap->LineCapWidth, sizeof(double), &dwWrite, NULL)) // goto fail; // if (!WriteFile(fh, &data->ArrowCap->LineCapHeight, sizeof(double), &dwWrite, NULL)) // goto fail; } } } if (Version >= 160) { if (!WriteFile(fh, &bGradientfill, sizeof(int), &dwWrite, NULL)) goto fail; if (bGradientfill) { if (!WriteFile(fh, &data->gradientItem, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->gAngle, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->gradientColorCount, sizeof(int), &dwWrite, NULL)) goto fail; int count = data->gradientColorCount; if (!WriteFile(fh, data->gradientColors, sizeof(RGBQUAD) * count, &dwWrite, NULL)) goto fail; } } // Version 170 Ãß°¡ 090304 if (Version >= 170) { if (!WriteFile(fh, &data->bMotive, sizeof(int), &dwWrite, NULL)) goto fail; if (data->bMotive) { if (!WriteFile(fh, &data->mode, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->gap, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->motivecount, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->proportion, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->childwidth, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->childheight, sizeof(double), &dwWrite, NULL)) goto fail; if (bRange) { // ÀÛ¾÷±¸¿ªÀÌ ÀÖÀ» °æ¿ì centerX,centerYÁ¡ º¯°æ double adjustedcenterX = data->centerX - Src.Left; double adjustedcenterY = data->centerY - Src.Top; if (!WriteFile(fh, &adjustedcenterX, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &adjustedcenterY, sizeof(double), &dwWrite, NULL)) goto fail; } else { if (!WriteFile(fh, &data->centerX, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->centerY, sizeof(double), &dwWrite, NULL)) goto fail; } if (!WriteFile(fh, &data->ChildCount, sizeof(int), &dwWrite, NULL)) goto fail; for (int i = 0; i < data->ChildCount; i++) { TVecData *childdata = (TVecData*)data->ChildList->Items[i]; SaveVectorToFile(fh, childdata, method, Version); } } } break; case V_RECT: case V_ELLIPSE: if (!WriteFile(fh, &data->PenStyle, sizeof(EPenStyle), &dwWrite, NULL)) goto fail; if (Version >= 150) { if (!WriteFile(fh, &data->PenThick, sizeof(double), &dwWrite, NULL)) goto fail; // 2005 Vector upgrade 0223 shin } else { int tempthick; tempthick = (int)data->PenThick; if (tempthick == 0) tempthick = 1; if (!WriteFile(fh, &tempthick, sizeof(int), &dwWrite, NULL)) goto fail; } // if (!WriteFile(fh, &data->PenThick, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->bRound, sizeof(bool), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &bColorfill, sizeof(bool), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->bWinding, sizeof(bool), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &tColor, sizeof(TColor), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &tBrush, sizeof(TColor), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &bPatternfill, sizeof(bool), &dwWrite, NULL)) goto fail; if (data->bPatternFill) SaveObjectBitmap(fh, data); // Version 150 Ãß°¡ if (Version >= 150) { if (!WriteFile(fh, data->DashValues, sizeof(double) * 7, &dwWrite, NULL)) goto fail; int TempCapStyle[2] = {0, 0}; TempCapStyle[0] = data->CapStyle[0]; TempCapStyle[1] = data->CapStyle[1]; if (!WriteFile(fh, TempCapStyle, sizeof(int) * 2, &dwWrite, NULL)) goto fail; } if (Version >= 160) { if (!WriteFile(fh, &bGradientfill, sizeof(int), &dwWrite, NULL)) goto fail; if (bGradientfill) { if (!WriteFile(fh, &data->gradientItem, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->gAngle, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->gradientColorCount, sizeof(int), &dwWrite, NULL)) goto fail; int count = data->gradientColorCount; if (!WriteFile(fh, data->gradientColors, sizeof(RGBQUAD) * count, &dwWrite, NULL)) goto fail; } } // Version 170 Ãß°¡ 090304 if (Version >= 170) { if (!WriteFile(fh, &data->bMotive, sizeof(int), &dwWrite, NULL)) goto fail; if (data->bMotive) { if (!WriteFile(fh, &data->mode, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->gap, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->motivecount, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->proportion, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->childwidth, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->childheight, sizeof(double), &dwWrite, NULL)) goto fail; if (bRange) { // ÀÛ¾÷±¸¿ªÀÌ ÀÖÀ» °æ¿ì centerX,centerYÁ¡ º¯°æ double adjustedcenterX = data->centerX - Src.Left; double adjustedcenterY = data->centerY - Src.Top; if (!WriteFile(fh, &adjustedcenterX, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &adjustedcenterY, sizeof(double), &dwWrite, NULL)) goto fail; } else { if (!WriteFile(fh, &data->centerX, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->centerY, sizeof(double), &dwWrite, NULL)) goto fail; } if (!WriteFile(fh, &data->ChildCount, sizeof(int), &dwWrite, NULL)) goto fail; for (int i = 0; i < data->ChildCount; i++) { TVecData *childdata = (TVecData*)data->ChildList->Items[i]; SaveVectorToFile(fh, childdata, method, Version); } } } break; case V_TEXT: if (!WriteFile(fh, &tColor, sizeof(TColor), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->Font, sizeof(LOGFONT), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->nCount, sizeof(int), &dwWrite, NULL)) goto fail; if (Version < 180) { AnsiString ansiTxt = data->TextString; if (!WriteFile(fh, ansiTxt.c_str(), sizeof(char) * data->nCount, &dwWrite, NULL)) goto fail; } else { if (!WriteFile(fh, data->TextString.c_str(), sizeof(Char) * data->nCount, &dwWrite, NULL)) goto fail; } break; case V_TEXTBOX: if (!WriteFile(fh, &data->CharH, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->CharW, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->TextAngle, sizeof(double), &dwWrite, NULL)) goto fail; if (bRange) { POINT TempStart, TempCenter; TempStart.x = data->StartPoint.x - Src.Left; // ù±ÛÀÚ°¡ ÀÖ´Â À§Ä¡ TempStart.y = data->StartPoint.y - Src.Top; TempCenter.x = data->CenterPoint.x - Src.Left; // BoxÀÇ ¹«°ÔÁß½ÉÁ¡ TempCenter.y = data->CenterPoint.y - Src.Top; if (!WriteFile(fh, &TempStart, sizeof(POINT), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &TempCenter, sizeof(POINT), &dwWrite, NULL)) goto fail; } else { if (!WriteFile(fh, &data->StartPoint, sizeof(POINT), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->CenterPoint, sizeof(POINT), &dwWrite, NULL)) goto fail; } linecount = data->ListOfAllLine->LineCount; // -->by linuxjun for CurvedVectorText int nTemp; if (data->ListOfAllLine->CurveData) { nTemp = DataList->IndexOf(data->ListOfAllLine->CurveData); } else { nTemp = -1; } if (!WriteFile(fh, &nTemp, sizeof(int), &dwWrite, NULL)) goto fail; // <--by linuxjun for CurvedVectorText if (!WriteFile(fh, &linecount, sizeof(int), &dwWrite, NULL)) goto fail; for (int i = 0; i < linecount; i++) { wordcount = data->ListOfAllLine->GetLineTextBox(i)->LineDataList->Count; if (!WriteFile(fh, &wordcount, sizeof(int), &dwWrite, NULL)) goto fail; for (int j = 0; j < wordcount; j++) { srcWordData = (TSWordData*)data->ListOfAllLine->GetLineTextBox(i) ->LineDataList->Items[j]; if (!WriteFile(fh, &srcWordData->Selected, sizeof(bool), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &srcWordData->PPoint, sizeof(POINT), &dwWrite, NULL)) goto fail; if (Version < 180) { LOGFONTA tempLFont; tempLFont.lfHeight = srcWordData->LFont.lfHeight; tempLFont.lfWidth = srcWordData->LFont.lfWidth; tempLFont.lfEscapement = srcWordData->LFont.lfEscapement; tempLFont.lfOrientation = srcWordData->LFont.lfOrientation; tempLFont.lfWeight = srcWordData->LFont.lfWeight; tempLFont.lfItalic = srcWordData->LFont.lfItalic; tempLFont.lfUnderline = srcWordData->LFont.lfUnderline; tempLFont.lfStrikeOut = srcWordData->LFont.lfStrikeOut; tempLFont.lfCharSet = srcWordData->LFont.lfCharSet; tempLFont.lfPitchAndFamily = srcWordData->LFont.lfPitchAndFamily; AnsiString faceName = srcWordData->LFont.lfFaceName; strcpy(tempLFont.lfFaceName, faceName.c_str()); if (!WriteFile(fh, &tempLFont, sizeof(LOGFONTA), &dwWrite, NULL)) goto fail; AnsiString ansiWord = srcWordData->Word; char aWord[2]; memcpy(aWord, ansiWord.c_str(), 2); if (!WriteFile(fh, aWord, sizeof(char) * 2, &dwWrite, NULL)) goto fail; int usedByte = srcWordData->UsedByte; if (aWord[1] != 0) usedByte = 2; if (!WriteFile(fh, &usedByte, sizeof(int), &dwWrite, NULL)) goto fail; } else { if (!WriteFile(fh, &srcWordData->LFont, sizeof(LOGFONT), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, srcWordData->Word, sizeof(Char) * 2, &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &srcWordData->UsedByte, sizeof(int), &dwWrite, NULL)) goto fail; } if (!WriteFile(fh, &srcWordData->Color, sizeof(TColor), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &srcWordData->Interval, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &srcWordData->HeightGap, sizeof(float), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &srcWordData->WidthGap, sizeof(float), &dwWrite, NULL)) goto fail; // Version 150 Ãß°¡ if (Version >= 150) { if (!WriteFile(fh, &srcWordData->bNameChanged, sizeof(bool), &dwWrite, NULL)) goto fail; // -->by linuxjun for CurvedVectorText if (!WriteFile(fh, &srcWordData->px, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &srcWordData->py, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &srcWordData->tx, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &srcWordData->ty, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &srcWordData->nx, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &srcWordData->ny, sizeof(int), &dwWrite, NULL)) goto fail; // <--by linuxjun for CurvedVectorText } } lineheight = data->ListOfAllLine->GetLineTextBox(i)->lineHeight; // lineHeight ÀúÀå if (!WriteFile(fh, &lineheight, sizeof(int), &dwWrite, NULL)) goto fail; } if (bRange) { pPoints = new DPOINT[5]; for (int i = 0; i < 5; i++) { pPoints[i].x = data->pList[i].x - Src.Left; pPoints[i].y = data->pList[i].y - Src.Top; } if (!WriteFile(fh, pPoints, sizeof(DPOINT) * 5, &dwWrite, NULL)) goto fail; if (pPoints) delete[]pPoints; pPoints = NULL; } else if (!WriteFile(fh, data->pList, sizeof(DPOINT) * 5, &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->nCount, sizeof(int), &dwWrite, NULL)) goto fail; break; } } if (bMessageBoxForStyleData) { Application->MessageBox(IDS_MESSAGE013.c_str(), L"Information", MB_OK); } pPoints = NULL; END_LOG; return true; fail: if (pPoints) delete[]pPoints; pPoints = NULL; END_LOG; return false; } // --------------------------------------------------------------------------- BYTE * __fastcall TVecDraw::SaveToSTYMemory(BYTE **pMemory, DWORD *dwPos, DWORD *dwDataSize, TVecData *data, int nVersion) { TVecData *childdata = NULL; // ÀÔ·ÂµÉ °ª°ú ±× µ¥ÀÌÅÍŸÀÔÀÌ Á¤È®ÇÏ°Ô ÀÏÄ¡ÇÏ¿©¾ß ÇÑ´Ù - by monkman (2009.04.03) // Çѹø¿¡ °è»êÇÏ°í ¸Þ¸ð¸® È®º¸ ÈÄ ÀúÀåÇÏ´Â °ÍÀÌ È¿À²ÀûÀ̾ º¯°æÇÏ°í ½ÍÀ¸³ª, // ÀúÀå ÀÛ¾÷ÀÌ ºó¹øÇÏ°Ô ÀϾÁö ¾Ê´Â °ü°è·Î ¼öÁ¤ÇÏÁö ¾Ê´Â´Ù. *dwPos = *dwDataSize; *dwDataSize += sizeof(EVecKind); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); if (memcpy(*pMemory + (*dwPos), &data->Kind, sizeof(EVecKind))); *dwPos = *dwDataSize; *dwDataSize += sizeof(POINT); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); if (memcpy(*pMemory + (*dwPos), &data->First, sizeof(POINT))); *dwPos = *dwDataSize; *dwDataSize += sizeof(POINT); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); if (memcpy(*pMemory + (*dwPos), &data->Second, sizeof(POINT))); *dwPos = *dwDataSize; *dwDataSize += sizeof(ObjectTraitSet); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); if (memcpy(*pMemory + (*dwPos), &data->TraitSet, sizeof(ObjectTraitSet))); *dwPos = *dwDataSize; *dwDataSize += sizeof(bool); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); if (memcpy(*pMemory + (*dwPos), &data->bAntialiasing, sizeof(bool))); // TEXTBOX ¼öÁ¤½Ã ÀÌ ºÎºÐÀ» ¼öÁ¤ - by monkman if (data->Kind != V_TEXTBOX) { // V_TEXTBOX °¡ ¾Æ´Ò¶§.. *dwPos = *dwDataSize; *dwDataSize += sizeof(EPenStyle); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory + (*dwPos), &data->PenStyle, sizeof(EPenStyle)); *dwPos = *dwDataSize; *dwDataSize += sizeof(double); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory + (*dwPos), &data->PenThick, sizeof(double)); // int->double shin *dwPos = *dwDataSize; *dwDataSize += sizeof(int); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory + (*dwPos), &data->nCount, sizeof(int)); *dwPos = *dwDataSize; *dwDataSize += sizeof(bool); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory + (*dwPos), &data->bRound, sizeof(bool)); *dwPos = *dwDataSize; *dwDataSize += sizeof(bool); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory + (*dwPos), &data->bFill, sizeof(bool)); *dwPos = *dwDataSize; *dwDataSize += sizeof(bool); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory + (*dwPos), &data->bWinding, sizeof(bool)); *dwPos = *dwDataSize; *dwDataSize += sizeof(TColor); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory + (*dwPos), &data->Color, sizeof(TColor)); *dwPos = *dwDataSize; *dwDataSize += sizeof(TColor); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory + (*dwPos), &data->Brush, sizeof(TColor)); *dwPos = *dwDataSize; *dwDataSize += sizeof(bool); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory + (*dwPos), &data->bClosed, sizeof(bool)); *dwPos = *dwDataSize; *dwDataSize += sizeof(int); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory + (*dwPos), &data->GroupIndex, sizeof(int)); *dwPos = *dwDataSize; *dwDataSize += sizeof(DPOINT) * (data->nCount * 3 + 1); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory + (*dwPos), data->pList, sizeof(DPOINT) * (data->nCount * 3 + 1)); *dwPos = *dwDataSize; *dwDataSize += (sizeof(double) * 7); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory + (*dwPos), data->DashValues, sizeof(double) * 7); } // STY, STI´Â Outline¸¸ ÀúÀåÇϹǷΠGradientFillÀº ÀúÀåÇÏÁö ¾Ê´Â´Ù - by monkman (2009.04.07) /* // GroupIndex º¯°æ & gradient fill Ãß°¡ - by monkman (2009.04.03) if ((206 <= nVersion && nVersion < 500) || 506 <= nVersion){ *dwPos = *dwDataSize; *dwDataSize += (sizeof(int)); *pMemory = (BYTE *)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory+(*dwPos), &data->bGradientFill, sizeof(int)); if (data->bGradientFill) { *dwPos = *dwDataSize; *dwDataSize += (sizeof(int)); *pMemory = (BYTE *)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory+(*dwPos), &data->gradientItem, sizeof(int)); *dwPos = *dwDataSize; *dwDataSize += (sizeof(int)); *pMemory = (BYTE *)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory+(*dwPos), &data->gAngle, sizeof(int)); *dwPos = *dwDataSize; *dwDataSize += (sizeof(int)); *pMemory = (BYTE *)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory+(*dwPos), &data->gradientColorCount, sizeof(int)); *dwPos = *dwDataSize; *dwDataSize += (sizeof(RGBQUAD)*data->gradientColorCount); *pMemory = (BYTE *)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory+(*dwPos), data->gradientColors, sizeof(RGBQUAD)*data->gradientColorCount); } } */ // MotiveObject Ãß°¡ - by monkman (2009.04.03) if ((207 <= nVersion && nVersion < 500) || 507 <= nVersion) { *dwPos = *dwDataSize; *dwDataSize += (sizeof(int)); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory + (*dwPos), &data->bMotive, sizeof(int)); if (data->bMotive) { *dwPos = *dwDataSize; *dwDataSize += (sizeof(int)); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory + (*dwPos), &data->mode, sizeof(int)); *dwPos = *dwDataSize; *dwDataSize += (sizeof(double)); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory + (*dwPos), &data->gap, sizeof(double)); *dwPos = *dwDataSize; *dwDataSize += (sizeof(int)); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory + (*dwPos), &data->motivecount, sizeof(int)); *dwPos = *dwDataSize; *dwDataSize += (sizeof(double)); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory + (*dwPos), &data->proportion, sizeof(double)); *dwPos = *dwDataSize; *dwDataSize += (sizeof(double)); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory + (*dwPos), &data->childwidth, sizeof(double)); *dwPos = *dwDataSize; *dwDataSize += (sizeof(double)); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory + (*dwPos), &data->childheight, sizeof(double)); *dwPos = *dwDataSize; *dwDataSize += (sizeof(double)); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory + (*dwPos), &data->centerX, sizeof(double)); *dwPos = *dwDataSize; *dwDataSize += (sizeof(double)); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory + (*dwPos), &data->centerY, sizeof(double)); *dwPos = *dwDataSize; *dwDataSize += (sizeof(int)); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory + (*dwPos), &data->ChildCount, sizeof(int)); for (int i = 0; i < data->ChildCount; i++) { childdata = (TVecData*)data->ChildList->Items[i]; SaveToSTYMemory(pMemory, dwPos, dwDataSize, childdata, nVersion); // Àç±ÍÇÔ¼ö È£Ãâ } } } // Arrow Ãß°¡ if ((209 <= nVersion && nVersion < 500) || 509 <= nVersion) { *dwPos = *dwDataSize; *dwDataSize += (sizeof(int)*2); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); int TempCapStyle[2] = {0, 0}; TempCapStyle[0] = data->CapStyle[0]; TempCapStyle[1] = data->CapStyle[1]; memcpy(*pMemory + (*dwPos), &TempCapStyle, sizeof(int)*2); if (data->CapStyle[0] && data->ArrowCap){ *dwPos = *dwDataSize; *dwDataSize += (sizeof(bool)); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory + (*dwPos), &data->ArrowCap->bFillLineCap, sizeof(bool)); *dwPos = *dwDataSize; *dwDataSize += (sizeof(bool)); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory + (*dwPos), &data->ArrowCap->bShowArrowBoth, sizeof(bool)); *dwPos = *dwDataSize; *dwDataSize += (sizeof(double)); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory + (*dwPos), &data->ArrowCap->LineCapWidthScale, sizeof(double)); *dwPos = *dwDataSize; *dwDataSize += (sizeof(double)); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory + (*dwPos), &data->ArrowCap->LineCapWidth, sizeof(double)); *dwPos = *dwDataSize; *dwDataSize += (sizeof(double)); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory + (*dwPos), &data->ArrowCap->LineCapHeight, sizeof(double)); *dwPos = *dwDataSize; *dwDataSize += (sizeof(double)); *pMemory = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, *pMemory, *dwDataSize); memcpy(*pMemory + (*dwPos), &data->ArrowCap->LineCapLine, sizeof(double)); } } } // --------------------------------------------------------------------------- TPException __fastcall TVecDraw::SaveToSTYFile(HANDLE hFile, TVecData *data, int nVersion) { TPException ec = EC_NONE; TVecData *childdata = NULL; DWORD dwWrite; // ÀÔ·ÂµÉ °ª°ú ±× µ¥ÀÌÅÍŸÀÔÀÌ Á¤È®ÇÏ°Ô ÀÏÄ¡ÇÏ¿©¾ß ÇÑ´Ù - by monkman (2009.04.03) // Çѹø¿¡ °è»êÇÏ°í ¸Þ¸ð¸® È®º¸ ÈÄ ÀúÀåÇÏ´Â °ÍÀÌ È¿À²ÀûÀ̾ º¯°æÇÏ°í ½ÍÀ¸³ª, // ÀúÀå ÀÛ¾÷ÀÌ ºó¹øÇÏ°Ô ÀϾÁö ¾Ê´Â °ü°è·Î ¼öÁ¤ÇÏÁö ¾Ê´Â´Ù. if (!WriteFile(hFile, &data->Kind, sizeof(EVecKind), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &data->First, sizeof(POINT), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &data->Second, sizeof(POINT), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &data->TraitSet, sizeof(ObjectTraitSet), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &data->bAntialiasing, sizeof(bool), &dwWrite, NULL)) goto fail; // TEXTBOX ¼öÁ¤½Ã ÀÌ ºÎºÐÀ» ¼öÁ¤ - by monkman if (data->Kind != V_TEXTBOX) { // V_TEXTBOX °¡ ¾Æ´Ò¶§.. if (!WriteFile(hFile, &data->PenStyle, sizeof(EPenStyle), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &data->PenThick, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &data->nCount, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &data->bRound, sizeof(bool), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &data->bFill, sizeof(bool), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &data->bWinding, sizeof(bool), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &data->Color, sizeof(TColor), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &data->Brush, sizeof(TColor), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &data->bClosed, sizeof(bool), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &data->GroupIndex, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, data->pList, sizeof(DPOINT) * (data->nCount * 3 + 1), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, data->DashValues, sizeof(double) * 7, &dwWrite, NULL)) goto fail; } // STY, STI´Â Outline¸¸ ÀúÀåÇϹǷΠGradientFillÀº ÀúÀåÇÏÁö ¾Ê´Â´Ù - by monkman (2009.04.07) /* // GroupIndex º¯°æ & gradient fill Ãß°¡ - by monkman (2009.04.03) if ((206 <= nVersion && nVersion < 500) || 506 <= nVersion){ if (!WriteFile(hFile, &data->bGradientFill, sizeof(int), &dwWrite, NULL)) goto fail; if (data->bGradientFill) { if (!WriteFile(hFile, &data->gradientItem, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &data->gAngle, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &data->gradientColorCount, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, data->gradientColors, sizeof(RGBQUAD)*data->gradientColorCount, &dwWrite, NULL)) goto fail; } } */ // MotiveObject Ãß°¡ - by monkman (2009.04.03) if ((207 <= nVersion && nVersion < 500) || 507 <= nVersion) { if (!WriteFile(hFile, &data->bMotive, sizeof(int), &dwWrite, NULL)) goto fail; if (data->bMotive) { if (!WriteFile(hFile, &data->mode, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &data->gap, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &data->motivecount, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &data->proportion, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &data->childwidth, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &data->childheight, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &data->centerX, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &data->centerY, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &data->ChildCount, sizeof(int), &dwWrite, NULL)) goto fail; for (int i = 0; i < data->ChildCount; i++) { childdata = (TVecData*)data->ChildList->Items[i]; SaveToSTYFile(hFile, childdata, nVersion); // Àç±ÍÇÔ¼ö È£Ãâ } } } if ((209 <= nVersion && nVersion < 500) || 509 <= nVersion) { int TempCapStyle[2] = {0, 0}; TempCapStyle[0] = data->CapStyle[0]; TempCapStyle[1] = data->CapStyle[1]; if (!WriteFile(hFile, TempCapStyle, sizeof(int) * 2, &dwWrite, NULL)) goto fail; if (data->CapStyle[0] && data->ArrowCap){ if (!data->ArrowCap->SaveToFile(hFile)) goto fail; // if (!WriteFile(hFile, &data->ArrowCap->bFillLineCap, sizeof(bool), &dwWrite, NULL)) // goto fail; // if (!WriteFile(hFile, &data->ArrowCap->bShowArrowBoth, sizeof(bool), &dwWrite, NULL)) // goto fail; // if (!WriteFile(hFile, &data->ArrowCap->LineCapWidthScale, sizeof(double), &dwWrite, NULL)) // goto fail; // if (!WriteFile(hFile, &data->ArrowCap->LineCapWidth, sizeof(double), &dwWrite, NULL)) // goto fail; // if (!WriteFile(hFile, &data->ArrowCap->LineCapHeight, sizeof(double), &dwWrite, NULL)) // goto fail; } } return ec; fail: ec = EC_FILE_NOT_WRITE; if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile); return ec; } // --------------------------------------------------------------------------- /** // 090811 Áߺ¹ ÁöÁ¤À» À§ÇØ ¼öÁ¤ by david // 00000000 00000000 00000000 00000001 Bit·Î ó¸® * -# Method 00000001(1) : Default * -# Method 00000010(2) : ÇÑ Á¡ÀÌ¶óµµ Area¾È¿¡ Àִ°æ¿ì ÀúÀå * -# Method 00000100(4) : ÇÑ Á¡ÀÌ¶óµµ Area¹Û¿¡ ÀÖÀ¸¸é ÀúÀåÇÏÁö ¾ÊÀ½ * -# Method 00001000(8) : ¼±ÅÃµÈ Object¸¸ ÀúÀåµÊ * -# Method 00010000(16) : Moptive Object ÀúÀåÀ¸·Î ÀÛ¾÷±¸¿ª°ú »ó°ü¾øÀÌ ÀúÀåÇÑ´Ù. * -# Method 00100000(32) : Style Data(Color´Â ºí·¢, ColorFill, Pattern, Gradient Á¦¿Ü Çϰí ÀúÀå) */ // bool __fastcall TVecDraw::SaveVectorToFile(HANDLE fh, TVecData *data, int method, bool IsOldVersion) bool __fastcall TVecDraw::SaveVectorToFile(HANDLE fh, TVecData *data, int method, int Version) { BEGIN_LOG(""); DPOINT *pPoints = NULL; // pPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) DWORD dwWrite; // int Version = 180; bool bRange = false; TRect Src; bool saveLowVersion = false; int linecount, wordcount, lineheight; TSWordData *srcWordData; bool bColorfill = false, bPatternfill = false, bGradientfill = false; TColor tColor = clBlack, tBrush = clBlack; // V1.3¿¡¼­ ÇöÀç ¸¸µé¾îÁø (V1.5)ÆÄÀÏÀÌ ¿­¸± ¼ö ÀÖµµ·Ï Save¹æ½Ä Ãß°¡ // if (IsOldVersion) // { // Version = 120; // saveLowVersion = true; // } if (Version == 120) saveLowVersion = true; if (MainImageForm->WorkArea->Mask) { // ÀÛ¾÷±¸¿ªÀÌ ÀÖ´Â °æ¿ì¿¡´Â ¿µ¿ªÀÇ »çÀÌÁî¿¡ ¸ÂÃß¾î shift~ bRange = true; Src = MainImageForm->WorkArea->Range; } if (!WriteFile(fh, &data->Kind, sizeof(EVecKind), &dwWrite, NULL)) goto fail; if (bRange) { POINT TempFirst, TempSecond; TempFirst.x = data->First.x - Src.Left; TempFirst.y = data->First.y - Src.Top; TempSecond.x = data->Second.x - Src.Left; TempSecond.y = data->Second.y - Src.Top; if (!WriteFile(fh, &TempFirst, sizeof(POINT), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &TempSecond, sizeof(POINT), &dwWrite, NULL)) goto fail; } else { if (!WriteFile(fh, &data->First, sizeof(POINT), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->Second, sizeof(POINT), &dwWrite, NULL)) goto fail; } // Version 150 Ãß°¡ if (Version >= 150) { if (!WriteFile(fh, &data->bAntialiasing, sizeof(bool), &dwWrite, NULL)) goto fail; } // 090811 by david // StyleÀº VST, TEX¿¡¼­ bGradientfillÀ» Æ÷ÇÔÇÏÁö ¾Ê´Â´Ù. if (method & 32) { tColor = clBlack, tBrush = clBlack; bColorfill = false; bPatternfill = false; bGradientfill = false; } else { tColor = data->Color, tBrush = data->Brush; bColorfill = data->bFill; bPatternfill = data->bPatternFill; bGradientfill = data->bGradientFill; } switch(data->Kind) { case V_LINE: case V_CURVE: if (!WriteFile(fh, &data->PenStyle, sizeof(EPenStyle), &dwWrite, NULL)) goto fail; if (Version >= 150) { if (!WriteFile(fh, &data->PenThick, sizeof(double), &dwWrite, NULL)) goto fail; // 2005 Vector upgrade 0223 shin } else { int tempthick; tempthick = (int)data->PenThick; if (tempthick == 0) tempthick = 1; if (!WriteFile(fh, &tempthick, sizeof(int), &dwWrite, NULL)) goto fail; } if (!WriteFile(fh, &data->nCount, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->bRound, sizeof(bool), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &bColorfill, sizeof(bool), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->bWinding, sizeof(bool), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &tColor, sizeof(TColor), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &tBrush, sizeof(TColor), &dwWrite, NULL)) goto fail; // ===7.43, Version 110 Ãß°¡ if (!WriteFile(fh, &data->bClosed, sizeof(bool), &dwWrite, NULL)) goto fail; // if (!WriteFile(fh, &data->GroupIndex, sizeof(int), &dwWrite, NULL)) goto fail; if (Version < 160) // 2.4ÀÌÇÏ ¹öÀü¿¡¼­ ÀÐÀ» ¼ö ÀÖµµ·Ï Çϱâ À§ÇØ { int temp = data->GroupIndex; data->GroupIndex = (data->GroupIndex % 10000) & 0x000001ff; temp /= 10000; if (temp > 0 && temp < 24) data->GroupIndex += (1 << (temp + 9)); if (!WriteFile(fh, &data->GroupIndex, sizeof(int), &dwWrite, NULL)) goto fail; } else if (!WriteFile(fh, &data->GroupIndex, sizeof(int), &dwWrite, NULL)) goto fail; // ========================= if (bRange) { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new DPOINT[(data->nCount + 1) * 3 + 1]; } else { pPoints = new DPOINT[data->nCount * 3 + 1]; } for (int i = 0; i < data->nCount * 3 + 1; i++) { pPoints[i].x = data->pList[i].x - Src.Left; pPoints[i].y = data->pList[i].y - Src.Top; } if (!WriteFile(fh, pPoints, sizeof(DPOINT) * (data->nCount * 3 + 1), &dwWrite, NULL)) goto fail; if (pPoints) delete[]pPoints; pPoints = NULL; } else { if (!WriteFile(fh, data->pList, sizeof(DPOINT) * (data->nCount * 3 + 1), &dwWrite, NULL)) goto fail; } if (!WriteFile(fh, &bPatternfill, sizeof(bool), &dwWrite, NULL)) goto fail; if (bPatternfill) { int w = data->TBitmapSource->Width, h = data->TBitmapSource->Height; if (!WriteFile(fh, &data->PatternAngle, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->PatternAdjustX, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->PatternAdjustY, sizeof(int), &dwWrite, NULL)) goto fail; // ===7.41, Version 130 Ãß°¡ if (!saveLowVersion) { // V1.3¿¡¼­µµ ¿­¸®°Ô Çϱâ À§Çؼ­ À̺κÐÀ» Ãß°¡Çß´Ù. if (!WriteFile(fh, &data->RatioX, sizeof(int), &dwWrite, NULL)) goto fail; // Added by maxleo21c(2004/05/11) if (!WriteFile(fh, &data->RatioY, sizeof(int), &dwWrite, NULL)) goto fail; } // ========================= if (!WriteFile(fh, &w, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &h, sizeof(int), &dwWrite, NULL)) goto fail; data->TBitmapSource->SaveToTexpiaFile(fh, cmZLib); } // Version 150 Ãß°¡ if (Version >= 150) { if (!WriteFile(fh, data->DashValues, sizeof(double) * 7, &dwWrite, NULL)) goto fail; int TempCapStyle[2] = {0, 0}; TempCapStyle[0] = data->CapStyle[0]; TempCapStyle[1] = data->CapStyle[1]; if (!WriteFile(fh, TempCapStyle, sizeof(int) * 2, &dwWrite, NULL)) goto fail; if (Version >= 181){ if (data->CapStyle[0] && data->ArrowCap){ if (!data->ArrowCap->SaveToFile(fh)) goto fail; // if (!WriteFile(fh, &data->ArrowCap->bFillLineCap, sizeof(bool), &dwWrite, NULL)) // goto fail; // if (!WriteFile(fh, &data->ArrowCap->bShowArrowBoth, sizeof(bool), &dwWrite, NULL)) // goto fail; // if (!WriteFile(fh, &data->ArrowCap->LineCapWidthScale, sizeof(double), &dwWrite, NULL)) // goto fail; // if (!WriteFile(fh, &data->ArrowCap->LineCapWidth, sizeof(double), &dwWrite, NULL)) // goto fail; // if (!WriteFile(fh, &data->ArrowCap->LineCapHeight, sizeof(double), &dwWrite, NULL)) // goto fail; } } } // Version 160 Ãß°¡ 080514 if (Version >= 160) { if (!WriteFile(fh, &bGradientfill, sizeof(int), &dwWrite, NULL)) goto fail; if (bGradientfill) { if (!WriteFile(fh, &data->gradientItem, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->gAngle, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->gradientColorCount, sizeof(int), &dwWrite, NULL)) goto fail; int count = data->gradientColorCount; if (!WriteFile(fh, data->gradientColors, sizeof(RGBQUAD) * count, &dwWrite, NULL)) goto fail; } } // Version 170 Ãß°¡ 090304 if (Version >= 170) { if (!WriteFile(fh, &data->bMotive, sizeof(int), &dwWrite, NULL)) goto fail; if (data->bMotive) { if (!WriteFile(fh, &data->mode, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->gap, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->motivecount, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->proportion, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->childwidth, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->childheight, sizeof(double), &dwWrite, NULL)) goto fail; if (bRange) { // ÀÛ¾÷±¸¿ªÀÌ ÀÖÀ» °æ¿ì centerX,centerYÁ¡ º¯°æ double adjustedcenterX = data->centerX - Src.Left; double adjustedcenterY = data->centerY - Src.Top; if (!WriteFile(fh, &adjustedcenterX, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &adjustedcenterY, sizeof(double), &dwWrite, NULL)) goto fail; } else { if (!WriteFile(fh, &data->centerX, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->centerY, sizeof(double), &dwWrite, NULL)) goto fail; } if (!WriteFile(fh, &data->ChildCount, sizeof(int), &dwWrite, NULL)) goto fail; for (int i = 0; i < data->ChildCount; i++) { TVecData *childdata = (TVecData*)data->ChildList->Items[i]; // SaveVectorToFile(fh, childdata, Index, method); SaveVectorToFile(fh, childdata, method, Version); } } } break; case V_RECT: case V_ELLIPSE: if (!WriteFile(fh, &data->PenStyle, sizeof(EPenStyle), &dwWrite, NULL)) goto fail; if (Version >= 150) { if (!WriteFile(fh, &data->PenThick, sizeof(double), &dwWrite, NULL)) goto fail; // 2005 Vector upgrade 0223 shin } else { int tempthick; tempthick = (int)data->PenThick; if (tempthick == 0) tempthick = 1; if (!WriteFile(fh, &tempthick, sizeof(int), &dwWrite, NULL)) goto fail; } if (!WriteFile(fh, &data->bRound, sizeof(bool), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &bColorfill, sizeof(bool), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->bWinding, sizeof(bool), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &tColor, sizeof(TColor), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &tBrush, sizeof(TColor), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &bPatternfill, sizeof(bool), &dwWrite, NULL)) goto fail; if (data->bPatternFill) SaveObjectBitmap(fh, data); // Version 150 Ãß°¡ if (Version >= 150) { if (!WriteFile(fh, data->DashValues, sizeof(double) * 7, &dwWrite, NULL)) goto fail; int TempCapStyle[2] = {0, 0}; TempCapStyle[0] = data->CapStyle[0]; TempCapStyle[1] = data->CapStyle[1]; if (!WriteFile(fh, TempCapStyle, sizeof(int) * 2, &dwWrite, NULL)) goto fail; } // Version 160 Ãß°¡ 080514 if (Version >= 160) { if (!WriteFile(fh, &bGradientfill, sizeof(int), &dwWrite, NULL)) goto fail; if (bGradientfill) { if (!WriteFile(fh, &data->gradientItem, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->gAngle, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->gradientColorCount, sizeof(int), &dwWrite, NULL)) goto fail; int count = data->gradientColorCount; if (!WriteFile(fh, data->gradientColors, sizeof(RGBQUAD) * count, &dwWrite, NULL)) goto fail; } } // Version 170 Ãß°¡ 090304 if (Version >= 170) { if (!WriteFile(fh, &data->bMotive, sizeof(int), &dwWrite, NULL)) goto fail; if (data->bMotive) { if (!WriteFile(fh, &data->mode, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->gap, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->motivecount, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->proportion, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->childwidth, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->childheight, sizeof(double), &dwWrite, NULL)) goto fail; if (bRange) { // ÀÛ¾÷±¸¿ªÀÌ ÀÖÀ» °æ¿ì centerX,centerYÁ¡ º¯°æ double adjustedcenterX = data->centerX - Src.Left; double adjustedcenterY = data->centerY - Src.Top; if (!WriteFile(fh, &adjustedcenterX, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &adjustedcenterY, sizeof(double), &dwWrite, NULL)) goto fail; } else { if (!WriteFile(fh, &data->centerX, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->centerY, sizeof(double), &dwWrite, NULL)) goto fail; } if (!WriteFile(fh, &data->ChildCount, sizeof(int), &dwWrite, NULL)) goto fail; for (int i = 0; i < data->ChildCount; i++) { TVecData *childdata = (TVecData*)data->ChildList->Items[i]; // SaveVectorToFile(fh, childdata, Index, method); SaveVectorToFile(fh, childdata, method, Version); } } } break; case V_TEXT: if (!WriteFile(fh, &tColor, sizeof(TColor), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->Font, sizeof(LOGFONT), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->nCount, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, data->TextString.c_str(), sizeof(Char) * data->nCount, &dwWrite, NULL)) goto fail; break; } pPoints = NULL; END_LOG; return true; fail: if (pPoints) delete[]pPoints; pPoints = NULL; END_LOG; return false; } // --------------------------------------------------------------------------- /** Vector file ÀúÀå. * Method 2 : ÇÑ Á¡ÀÌ¶óµµ Area¾È¿¡ Àִ°æ¿ì ÀúÀå * Method 3 : ÇÑ Á¡ÀÌ¶óµµ Area¹Û¿¡ ÀÖÀ¸¸é ÀúÀåÇÏÁö ¾ÊÀ½ * Method 4 : ¼±ÅÃµÈ Object¸¸ ÀúÀåµÊ // 090811 Áߺ¹ ÁöÁ¤À» À§ÇØ ¼öÁ¤ by david // 00000000 00000000 00000000 00000001 Bit·Î ó¸® * -# Method 00000001(1) : Default * -# Method 00000010(2) : ÇÑ Á¡ÀÌ¶óµµ Area¾È¿¡ Àִ°æ¿ì ÀúÀå * -# Method 00000100(4) : ÇÑ Á¡ÀÌ¶óµµ Area¹Û¿¡ ÀÖÀ¸¸é ÀúÀåÇÏÁö ¾ÊÀ½ * -# Method 00001000(8) : ¼±ÅÃµÈ Object¸¸ ÀúÀåµÊ * -# Method 00010000(16) : Moptive Object ÀúÀåÀ¸·Î ÀÛ¾÷±¸¿ª°ú »ó°ü¾øÀÌ ÀúÀåÇÑ´Ù. * -# Method 00100000(32) : Style Data(Color´Â ºí·¢, ColorFill, Pattern, Gradient Á¦¿Ü Çϰí ÀúÀå) */ bool __fastcall TVecDraw::SaveVectorToFile(HANDLE fh, int method, int textileVersion) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) // Version : 150 - Gdiplus Àû¿ë ÈÄ º¯°æ 2005 Vector Upgrade Shin 0317 // Version : 160 - GradientFill Ãß°¡ & group index ±¸Á¶ ¼öÁ¤ ÈÄ º¯°æ // Version : 170 - MotiveObject Ãß°¡ // Version : 180 - Unicode Ãß°¡ // Version : 181 - Arrow ¼öÁ¤ // Version : 182 - Line Arrow ¼öÁ¤ int Version = 182, count = 0; if (textileVersion == TextileFileVersionOld) Version = 120; else if (textileVersion == TextileFileVersion10) Version = 160; else Version = 182; bool isVector, bRange = false; DWORD dwWrite; TRect Src; int linecount, wordcount, lineheight; TSWordData *srcWordData; DPOINT *pPoints = NULL; // pPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) bool bColorfill = false, bPatternfill = false, bGradientfill = false; TColor tColor = clBlack, tBrush = clBlack; bool bMessageBoxForStyleData = false; // ÀÛ¾÷±¸¿ªÀÌ ÀÖÀ» °æ¿ì ¿µ¿ª¸¸Å­¸¸ ÀúÀåÇÑ´Ù - by monkman (2005.08.02) if (MainImageForm->WorkArea->Mask) { // ÀÛ¾÷±¸¿ªÀÌ ÀÖ´Â °æ¿ì¿¡´Â ¿µ¿ªÀÇ »çÀÌÁî¿¡ ¸ÂÃß¾î shift~ bRange = true; Src = MainImageForm->WorkArea->Range; } else { Src = Rect(0, 0, MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height); } for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; // if (method == 4 && !data->bSelected) continue; // INRECTMETHOD; if (!InRectMethod(Src, data, method, bRange)) continue; count++; } // if (count > 0) isVector = true; else isVector = false; // if (!WriteFile(fh, &isVector, sizeof(bool), &dwWrite, NULL)) goto fail; // if (!isVector) return true; if (!WriteFile(fh, &DataCode, sizeof(EDataCode), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &Version, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &count, sizeof(int), &dwWrite, NULL)) goto fail; #ifdef TRIAL { char garbage[6] = "TRIAL"; for (int i = 0; i < 10; i++) { if (!WriteFile(fh, garbage, sizeof(char) * 6, &dwWrite, NULL)) { END_LOG; return false; } } } #endif for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; // if (method == 4 && !data->bSelected) continue; // INRECTMETHOD; if (!InRectMethod(Src, data, method, bRange)) continue; if (!WriteFile(fh, &data->Kind, sizeof(EVecKind), &dwWrite, NULL)) goto fail; if (bRange) { POINT TempFirst, TempSecond; TempFirst.x = data->First.x - Src.Left; TempFirst.y = data->First.y - Src.Top; TempSecond.x = data->Second.x - Src.Left; TempSecond.y = data->Second.y - Src.Top; if (!WriteFile(fh, &TempFirst, sizeof(POINT), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &TempSecond, sizeof(POINT), &dwWrite, NULL)) goto fail; } else { if (!WriteFile(fh, &data->First, sizeof(POINT), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->Second, sizeof(POINT), &dwWrite, NULL)) goto fail; } // Version 150 Ãß°¡ if (Version >= 150) { if (!WriteFile(fh, &data->bAntialiasing, sizeof(bool), &dwWrite, NULL)) goto fail; } // 090811 by david // Style Data(Color´Â ºí·¢, ColorFill, Pattern, Gradient Á¦¿Ü Çϰí ÀúÀå) if (method & 32) { tColor = clBlack, tBrush = clBlack; bColorfill = false; bPatternfill = false; bGradientfill = false; if (data->bFill || data->bPatternFill || data->bGradientFill || data->Color != clBlack || data->Brush != clBlack) { bMessageBoxForStyleData = true; } } else { tColor = data->Color, tBrush = data->Brush; bColorfill = data->bFill; bPatternfill = data->bPatternFill; bGradientfill = data->bGradientFill; } switch(data->Kind) { case V_LINE: case V_CURVE: if (!WriteFile(fh, &data->PenStyle, sizeof(EPenStyle), &dwWrite, NULL)) goto fail; // Version 150 º¯°æ penthick : int->double if (!WriteFile(fh, &data->PenThick, sizeof(double), &dwWrite, NULL)) goto fail; // if (!WriteFile(fh, &data->PenThick, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->nCount, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->bRound, sizeof(bool), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &bColorfill, sizeof(bool), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->bWinding, sizeof(bool), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &tColor, sizeof(TColor), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &tBrush, sizeof(TColor), &dwWrite, NULL)) goto fail; // ===7.41, Version 110 Ãß°¡ if (!WriteFile(fh, &data->bClosed, sizeof(bool), &dwWrite, NULL)) goto fail; // if (!WriteFile(fh, &data->GroupIndex, sizeof(int), &dwWrite, NULL)) goto fail; if (Version < 160) // 9.2 ÀÌÇÏ ¹öÀü¿¡¼­ ÀÐÀ» ¼ö ÀÖµµ·Ï Çϱâ À§ÇØ { int temp = data->GroupIndex; data->GroupIndex = (data->GroupIndex % 10000) & 0x000001ff; temp /= 10000; if (temp > 0 && temp < 24) data->GroupIndex += (1 << (temp + 9)); if (!WriteFile(fh, &data->GroupIndex, sizeof(int), &dwWrite, NULL)) goto fail; } else { if (!WriteFile(fh, &data->GroupIndex, sizeof(int), &dwWrite, NULL)) goto fail; } // ========================= if (bRange) { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new DPOINT[(data->nCount + 1) * 3 + 1]; } else { pPoints = new DPOINT[data->nCount * 3 + 1]; } for (int i = 0; i < data->nCount * 3 + 1; i++) { pPoints[i].x = data->pList[i].x - Src.Left; pPoints[i].y = data->pList[i].y - Src.Top; } if (!WriteFile(fh, pPoints, sizeof(DPOINT) * (data->nCount * 3 + 1), &dwWrite, NULL)) goto fail; if (pPoints) delete[]pPoints; pPoints = NULL; } else { if (!WriteFile(fh, data->pList, sizeof(DPOINT) * (data->nCount * 3 + 1), &dwWrite, NULL)) goto fail; } if (!WriteFile(fh, &bPatternfill, sizeof(bool), &dwWrite, NULL)) goto fail; if (bPatternfill) { int w = data->TBitmapSource->Width, h = data->TBitmapSource->Height; if (!WriteFile(fh, &data->PatternAngle, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->PatternAdjustX, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->PatternAdjustY, sizeof(int), &dwWrite, NULL)) goto fail; // ===7.43, Version 130 Ãß°¡ if (!WriteFile(fh, &data->RatioX, sizeof(int), &dwWrite, NULL)) goto fail; // Added by maxleo21c(2004/05/11) if (!WriteFile(fh, &data->RatioY, sizeof(int), &dwWrite, NULL)) goto fail; // ========================= if (!WriteFile(fh, &w, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &h, sizeof(int), &dwWrite, NULL)) goto fail; data->TBitmapSource->SaveToTexpiaFile(fh, cmZLib); } // Version 150 Ãß°¡ if (Version >= 150) { if (!WriteFile(fh, data->DashValues, sizeof(double) * 7, &dwWrite, NULL)) goto fail; int TempCapStyle[2] = {0, 0}; TempCapStyle[0] = data->CapStyle[0]; TempCapStyle[1] = data->CapStyle[1]; if (!WriteFile(fh, TempCapStyle, sizeof(int) * 2, &dwWrite, NULL)) goto fail; if (Version >= 181){ if (data->CapStyle[0] && data->ArrowCap){ if (!data->ArrowCap->SaveToFile(fh)) goto fail; // if (!WriteFile(fh, &data->ArrowCap->bFillLineCap, sizeof(bool), &dwWrite, NULL)) // goto fail; // if (!WriteFile(fh, &data->ArrowCap->bShowArrowBoth, sizeof(bool), &dwWrite, NULL)) // goto fail; // if (!WriteFile(fh, &data->ArrowCap->LineCapWidthScale, sizeof(double), &dwWrite, NULL)) // goto fail; // if (!WriteFile(fh, &data->ArrowCap->LineCapWidth, sizeof(double), &dwWrite, NULL)) // goto fail; // if (!WriteFile(fh, &data->ArrowCap->LineCapHeight, sizeof(double), &dwWrite, NULL)) // goto fail; } } } // Version 160 Ãß°¡ if (Version >= 160) { if (!WriteFile(fh, &bGradientfill, sizeof(int), &dwWrite, NULL)) goto fail; if (bGradientfill) { if (!WriteFile(fh, &data->gradientItem, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->gAngle, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->gradientColorCount, sizeof(int), &dwWrite, NULL)) goto fail; int count = data->gradientColorCount; if (!WriteFile(fh, data->gradientColors, sizeof(RGBQUAD) * count, &dwWrite, NULL)) goto fail; } } // Version 170 Ãß°¡ 090304 if (Version >= 170) { if (!WriteFile(fh, &data->bMotive, sizeof(int), &dwWrite, NULL)) goto fail; if (data->bMotive) { if (!WriteFile(fh, &data->mode, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->gap, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->motivecount, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->proportion, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->childwidth, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->childheight, sizeof(double), &dwWrite, NULL)) goto fail; if (bRange) { // ÀÛ¾÷±¸¿ªÀÌ ÀÖÀ» °æ¿ì centerX,centerYÁ¡ º¯°æ double adjustedcenterX = data->centerX - Src.Left; double adjustedcenterY = data->centerY - Src.Top; if (!WriteFile(fh, &adjustedcenterX, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &adjustedcenterY, sizeof(double), &dwWrite, NULL)) goto fail; } else { if (!WriteFile(fh, &data->centerX, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->centerY, sizeof(double), &dwWrite, NULL)) goto fail; } if (!WriteFile(fh, &data->ChildCount, sizeof(int), &dwWrite, NULL)) goto fail; for (int i = 0; i < data->ChildCount; i++) { TVecData *childdata = (TVecData*)data->ChildList->Items[i]; SaveVectorToFile(fh, childdata, method, Version); } } } // ========================= N3D ¿¡¼­ Ãß°¡ - LayerIndex, GridIIndex // if (!WriteFile(fh, &data->LayerIndex, sizeof(int), &dwWrite, NULL)) goto fail; // if (!WriteFile(fh, data->GridIndex, sizeof(int)*8, &dwWrite, NULL)) goto fail; // if (!WriteFile(fh, &data->GridCount, sizeof(int), &dwWrite, NULL)) goto fail; // if (!WriteFile(fh, &data->top, sizeof(int), &dwWrite, NULL)) goto fail; // if (!WriteFile(fh, &data->bottom, sizeof(int), &dwWrite, NULL)) goto fail; break; case V_RECT: case V_ELLIPSE: if (!WriteFile(fh, &data->PenStyle, sizeof(EPenStyle), &dwWrite, NULL)) goto fail; // Version 150 º¯°æ penthick : int->double if (!WriteFile(fh, &data->PenThick, sizeof(double), &dwWrite, NULL)) goto fail; // if (!WriteFile(fh, &data->PenThick, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->bRound, sizeof(bool), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &bColorfill, sizeof(bool), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->bWinding, sizeof(bool), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &tColor, sizeof(TColor), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &tBrush, sizeof(TColor), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &bPatternfill, sizeof(bool), &dwWrite, NULL)) goto fail; if (data->bPatternFill) SaveObjectBitmap(fh, data); // Version 150 Ãß°¡ if (Version >= 150) { if (!WriteFile(fh, data->DashValues, sizeof(double) * 7, &dwWrite, NULL)) goto fail; int TempCapStyle[2] = {0, 0}; TempCapStyle[0] = data->CapStyle[0]; TempCapStyle[1] = data->CapStyle[1]; if (!WriteFile(fh, TempCapStyle, sizeof(int) * 2, &dwWrite, NULL)) goto fail; } // Version 160 Ãß°¡ if (Version >= 160) { if (!WriteFile(fh, &bGradientfill, sizeof(int), &dwWrite, NULL)) goto fail; if (bGradientfill) { if (!WriteFile(fh, &data->gradientItem, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->gAngle, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->gradientColorCount, sizeof(int), &dwWrite, NULL)) goto fail; int count = data->gradientColorCount; if (!WriteFile(fh, data->gradientColors, sizeof(RGBQUAD) * count, &dwWrite, NULL)) goto fail; } } // Version 170 Ãß°¡ 090304 if (Version >= 170) { if (!WriteFile(fh, &data->bMotive, sizeof(int), &dwWrite, NULL)) goto fail; if (data->bMotive) { if (!WriteFile(fh, &data->mode, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->gap, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->motivecount, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->proportion, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->childwidth, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->childheight, sizeof(double), &dwWrite, NULL)) goto fail; if (bRange) { // ÀÛ¾÷±¸¿ªÀÌ ÀÖÀ» °æ¿ì centerX,centerYÁ¡ º¯°æ double adjustedcenterX = data->centerX - Src.Left; double adjustedcenterY = data->centerY - Src.Top; if (!WriteFile(fh, &adjustedcenterX, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &adjustedcenterY, sizeof(double), &dwWrite, NULL)) goto fail; } else { if (!WriteFile(fh, &data->centerX, sizeof(double), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->centerY, sizeof(double), &dwWrite, NULL)) goto fail; } if (!WriteFile(fh, &data->ChildCount, sizeof(int), &dwWrite, NULL)) goto fail; for (int i = 0; i < data->ChildCount; i++) { TVecData *childdata = (TVecData*)data->ChildList->Items[i]; SaveVectorToFile(fh, childdata, method, Version); } } } break; case V_TEXT: if (!WriteFile(fh, &tColor, sizeof(TColor), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->Font, sizeof(LOGFONT), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->nCount, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, data->TextString.c_str(), sizeof(Char) * data->nCount, &dwWrite, NULL)) goto fail; break; case V_TEXTBOX: if (!WriteFile(fh, &data->CharH, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->CharW, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->TextAngle, sizeof(double), &dwWrite, NULL)) goto fail; if (bRange) { POINT TempStart, TempCenter; TempStart.x = data->StartPoint.x - Src.Left; // ù±ÛÀÚ°¡ ÀÖ´Â À§Ä¡ TempStart.y = data->StartPoint.y - Src.Top; TempCenter.x = data->CenterPoint.x - Src.Left; // BoxÀÇ ¹«°ÔÁß½ÉÁ¡ TempCenter.y = data->CenterPoint.y - Src.Top; if (!WriteFile(fh, &TempStart, sizeof(POINT), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &TempCenter, sizeof(POINT), &dwWrite, NULL)) goto fail; } else { if (!WriteFile(fh, &data->StartPoint, sizeof(POINT), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->CenterPoint, sizeof(POINT), &dwWrite, NULL)) goto fail; } linecount = data->ListOfAllLine->LineCount; // -->by linuxjun for CurvedVectorText int nTemp; if (data->ListOfAllLine->CurveData) { nTemp = DataList->IndexOf(data->ListOfAllLine->CurveData); } else { nTemp = -1; } if (!WriteFile(fh, &nTemp, sizeof(int), &dwWrite, NULL)) goto fail; // <--by linuxjun for CurvedVectorText if (!WriteFile(fh, &linecount, sizeof(int), &dwWrite, NULL)) goto fail; for (int i = 0; i < linecount; i++) { wordcount = data->ListOfAllLine->GetLineTextBox(i)->LineDataList->Count; if (!WriteFile(fh, &wordcount, sizeof(int), &dwWrite, NULL)) goto fail; for (int j = 0; j < wordcount; j++) { srcWordData = (TSWordData*)data->ListOfAllLine->GetLineTextBox(i) ->LineDataList->Items[j]; if (!WriteFile(fh, &srcWordData->Selected, sizeof(bool), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &srcWordData->PPoint, sizeof(POINT), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &srcWordData->LFont, sizeof(LOGFONT), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, srcWordData->Word, sizeof(Char) * 2, &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &srcWordData->UsedByte, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &srcWordData->Color, sizeof(TColor), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &srcWordData->Interval, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &srcWordData->HeightGap, sizeof(float), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &srcWordData->WidthGap, sizeof(float), &dwWrite, NULL)) goto fail; // Version 150 Ãß°¡ if (Version >= 150) { if (!WriteFile(fh, &srcWordData->bNameChanged, sizeof(bool), &dwWrite, NULL)) goto fail; // -->by linuxjun for CurvedVectorText if (!WriteFile(fh, &srcWordData->px, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &srcWordData->py, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &srcWordData->tx, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &srcWordData->ty, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &srcWordData->nx, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &srcWordData->ny, sizeof(int), &dwWrite, NULL)) goto fail; // <--by linuxjun for CurvedVectorText } } lineheight = data->ListOfAllLine->GetLineTextBox(i)->lineHeight; // lineHeight ÀúÀå if (!WriteFile(fh, &lineheight, sizeof(int), &dwWrite, NULL)) goto fail; } if (bRange) { pPoints = new DPOINT[5]; for (int i = 0; i < 5; i++) { pPoints[i].x = data->pList[i].x - Src.Left; pPoints[i].y = data->pList[i].y - Src.Top; } if (!WriteFile(fh, pPoints, sizeof(DPOINT) * 5, &dwWrite, NULL)) goto fail; if (pPoints) delete []pPoints; pPoints = NULL; } else if (!WriteFile(fh, data->pList, sizeof(DPOINT) * 5, &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &data->nCount, sizeof(int), &dwWrite, NULL)) goto fail; break; } } if (bMessageBoxForStyleData) { Application->MessageBox(IDS_MESSAGE013.c_str(), L"Information", MB_OK); } if (pPoints) delete []pPoints; pPoints = NULL; END_LOG; return true; fail: if (pPoints) delete []pPoints; pPoints = NULL; END_LOG; return false; } // --------------------------------------------------------------------------- /// data°¡ Pattern FillÀÎ °æ¿ì Pattern BitmapÀ» save. bool __fastcall TVecDraw::SaveObjectBitmap(HANDLE fh, TVecData *data) { BEGIN_LOG(""); BYTE *pMem = NULL; BYTE *ptr = NULL; DWORD dwWrite; int w = data->Bitmap->Width, h = data->Bitmap->Height; if (!WriteFile(fh, &w, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, &h, sizeof(int), &dwWrite, NULL)) goto fail; if ((pMem = (BYTE*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, w * h * 3)) == NULL) goto fail; for (int y = 0; y < h; y++) { ptr = (Byte*)data->Bitmap->ScanLine[y]; memcpy(pMem + w * 3 * y, ptr, w * 3); } if (!WriteFile(fh, pMem, w * h * 3, &dwWrite, NULL)) goto fail; HeapFree(GetProcessHeap(), 0, pMem); END_LOG; return true; fail: END_LOG; return false; } // --------------------------------------------------------------------------- /// data°¡ Pattern FillÀÎ °æ¿ì Pattern BitmapÀ» load. bool __fastcall TVecDraw::LoadObjectBitmap(HANDLE fh, TVecData *data) { BEGIN_LOG(""); BYTE *pMem = NULL; BYTE *ptr = NULL; DWORD dwRead; int w, h; if (!ReadFile(fh, &w, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &h, sizeof(int), &dwRead, NULL)) goto fail; if ((pMem = (BYTE*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, w * h * 3)) == NULL) goto fail; data->Bitmap = new Graphics::TBitmap; data->Bitmap->PixelFormat = pf24bit; data->Bitmap->Width = w; data->Bitmap->Height = h; if (!ReadFile(fh, pMem, w * h * 3, &dwRead, NULL)) goto fail; for (int y = 0; y < h; y++) { ptr = (Byte*)data->Bitmap->ScanLine[y]; memcpy(ptr, pMem + y * w * 3, w * 3); } HeapFree(GetProcessHeap(), 0, pMem); END_LOG; return true; fail: END_LOG; return false; } // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // -------- Undo Handling --------------------------------------------- // --------------------------------------------------------------------------- // for new font void __fastcall TVecDraw::TextModUndoSave() { BEGIN_LOG(""); if (!BeModified) { // if(BeTextBoxCreated){ //for new font // UndoSave(VU_TEXTMODIFY,CurrentTextBox,false); // BeTextBoxCreated=false; //for new font // }else{ UndoSave(VU_TEXTMODIFY, CurrentTextBox, true); // } } BeModified = true; // for new font END_LOG; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::UndoSave(int kind, int index, bool sw, int nDest) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TPAbstractUndo * Undo = MainImageForm->VecUndo; Undo->UndoSave(kind, index, sw, nDest, DataList); MainImageForm->Modify = true; END_LOG; return; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::UndoRead() { BEGIN_LOG(""); TPAbstractUndo * Undo = MainImageForm->VecUndo; Undo->UndoRead(); // RECT rc = Rect(0, 0, MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height); MainImageForm->iMainImage->Cursor = crDefault; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - ¹ÝÀü °Å¿ïÀÇ º¤ÅÍ ¿µ¿ªÀ» °°ÀÌ ±¸ÇÑ´Ù - by monkman(2005.03.16) // if (NVector->bVectorReflectionMode) { // GetRealAndReflectionRect(&rc); // } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // MainImageForm->iMainImage->RectPaint(rc); MainImageForm->iMainImage->Repaint(); END_LOG; return; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::RedoRead() { BEGIN_LOG(""); TPAbstractUndo * Undo = MainImageForm->VecUndo; Undo->RedoRead(); // RECT rc = Rect(0, 0, MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height); MainImageForm->iMainImage->Cursor = crDefault; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - ¹ÝÀü °Å¿ïÀÇ º¤ÅÍ ¿µ¿ªÀ» °°ÀÌ ±¸ÇÑ´Ù - by monkman(2005.03.16) // if (NVector->bVectorReflectionMode) { // GetRealAndReflectionRect(&rc); // } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // MainImageForm->iMainImage->RectPaint(rc); MainImageForm->iMainImage->Repaint(); END_LOG; return; } // --------------------------------------------------------------------------- __fastcall TPVectorUndo::TPVectorUndo() { BEGIN_LOG(""); DataOfUndo = new TList; IndexOfStartReflection = -1; // by linuxjun for Undo IndexOfUndo = -1; // FileName = GetUndoFileName(); pos = 0; IsFirstRedo = true; CurrentBundle = NULL; END_LOG; } // --------------------------------------------------------------------------- String __fastcall TPVectorUndo::GetUndoFileName() { BEGIN_LOG(""); Char tp[MAX_PATH + 1], fn[MAX_PATH + 1]; GetTempPath(MAX_PATH, tp); if (tp[_tcslen(tp) - 1] == '\\') tp[_tcslen(tp) - 1] = 0; /* while (1) { _stprintf(fn, "%s\\TexWork%05X.do", tp, rand() & 0xFFFFF); if (!FileExists(fn)) break; } */ END_LOG; return(String)fn; } // --------------------------------------------------------------------------- __fastcall TPVectorUndo::~TPVectorUndo() { BEGIN_LOG(""); ExitUndo(); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPVectorUndo::ExitUndo() { BEGIN_LOG(""); while (DataOfUndo->Count) { RemoveLast(); } delete DataOfUndo; if (FileExists(FileName)) DeleteFile(FileName); END_LOG; } // --------------------------------------------------------------------------- bool __fastcall TPVectorUndo::canundo() { // return DataOfUndo->Count>0 && IndexOfUndo>-1; return DataOfUndo->Count > 0 && IndexOfUndo > IndexOfStartReflection; // by linuxjun for Undo } // -->by linuxjun for Undo void __fastcall TPVectorUndo::SetIndexOfStartReflection(int index) // by linuxjun for Undo { if (index == -2) { IndexOfStartReflection = IndexOfUndo; } else { IndexOfStartReflection = index; } } // --------------------------------------------------------------------------- void __fastcall TPVectorUndo::RemoveLastUntilNum(int num) { BEGIN_LOG(""); TPVectorUndoBundle * tempBundle; if (num == -2) { num = IndexOfStartReflection; } while (DataOfUndo->Count - 1 > num) { tempBundle = (TPVectorUndoBundle*)DataOfUndo->Last(); DataOfUndo->Remove(tempBundle); tempBundle->bCreateAtTail = true; delete tempBundle; if (DataOfUndo->Count == 0) break; } IndexOfUndo = IndexOfStartReflection; END_LOG; return; } // <--by linuxjun for Undo // --------------------------------------------------------------------------- bool __fastcall TPVectorUndo::canredo() { return IndexOfUndo < DataOfUndo->Count - 1; } // --------------------------------------------------------------------------- void __fastcall TPVectorUndo::AddUndoStep(TList *DataList) { BEGIN_LOG(""); /* º¹ÀâÇÑ ÀÌÀ¯·Î À̺κÐÀÌ ¸·¾ÆÁ®¾ß ÇÔ. Index°ü¸®¸¦ À§ÇØ ÇÊ¿äÇÔ. if(CurrentBundle!=NULL){ if(CurrentBundle->BundleOfUndoData->Count==0)return; } */ // CurrentBundle = new TPVectorUndoBundle(this); CurrentBundle = new TPVectorUndoBundle(DataList); IndexOfUndo++; int TempIndex = IndexOfUndo; while (DataOfUndo->Count > TempIndex) { RemoveLast(); } IndexOfUndo = TempIndex; DataOfUndo->Add(CurrentBundle); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPVectorUndo::AddToUndoBundle(TPVectorUndoData * tdu) { BEGIN_LOG(""); TPVectorUndoData * TempUndoData = NULL; /* if(CurrentBundle->BundleOfUndoData->Count>0){ for(int i = 0;iBundleOfUndoData->Count;i++){ TempUndoData = (TPVectorUndoData *)CurrentBundle->BundleOfUndoData->Items[i]; if(TempUndoData->SrcData==tdu->SrcData){ // CurrentBundle->RemoveLastUndo(); CurrentBundle->DeleteData(tdu); //Áߺ¹µÇ¼­ AddToUndoBundleµÈ°æ¿ì´Â óÀ½°ÍÀ» ³²°ÜµÐ´Ù. return; } } } */ CurrentBundle->AddUndoData(tdu); END_LOG; } // --------------------------------------------------------------------------- /* void __fastcall TPVectorUndo::AddToRedoBundle(TPDocObjectUndoData * tdu){ CurrentBundle->AddRedoData(tdu); } */ void __fastcall TPVectorUndo::GetSaveFileInfo(String &fileName, DWORD &posi, TTexpiaBitmap *Image) { /* fileName = FileName; posi = pos; SaveImageToFile(fileName, posi,Image); pos += ImageGetAllocateSize(Image); if(pos > 2*1024*1024*1024){ pos = 0; //2G°¡ ³Ñ´Â °æ¿ì ´Ù½Ã ¿øÁ¡¿¡¼­ ÀúÀå½ÃÀÛÇÏ°Ô ¹Ù²ãÁÜ. } */ } /* //--------------------------------------------------------------------------- int __fastcall TPVectorUndo::ImageGetAllocateSize(TTexpiaBitmap *Image) { int size = 0; if (Image) { size += sizeof(WORD) + sizeof(int) + sizeof(int); if (Image->BitsPerPixel == 8) size += (256 * sizeof(RGBQUAD)); size += Image->BytesPerLine * Image->Height; return size; } else { return sizeof(WORD); } } */ // --------------------------------------------------------------------------- void __fastcall TPVectorUndo::UndoSave(int kind, int index, int sw, int nDest, TList *DataList) // UndoSave´Â actionÀü¿¡ ½ÇÇàÇÑ´Ù { BEGIN_LOG(""); TVUndoData * udata; if (sw) { AddUndoStep(DataList); } if ((udata = new TVUndoData(MainImageForm->Number)) == NULL) goto fail; switch(kind) { case VU_ALL: { TPVectorUndoData * TDU = new TPVectorUndoData(); // udata = new TVUndoData(MainImageForm->Number); udata->Kind = VU_ALL; TDU->SrcData = udata; AddToUndoBundle(TDU); }break; case VU_CREATE: { TPCreateUndoData * TDU = new TPCreateUndoData(); udata->Kind = VU_CREATE; udata->IndexNumber = index; udata->VUndoData = NULL; udata->bFirst = sw; TDU->SrcData = udata; AddToUndoBundle(TDU); }break; case VU_DELETE: { TPDeleteUndoData * TDU = new TPDeleteUndoData(); udata->Kind = VU_DELETE; udata->IndexNumber = index; udata->VUndoData = new TVecData(MainImageForm->Number); udata->VUndoData->Copy((TVecData*)DataList->Items[index]); udata->bFirst = sw; TDU->SrcData = udata; AddToUndoBundle(TDU); }break; case VU_MODIFY: { TPModifyUndoData * TDU = new TPModifyUndoData(); udata->Kind = VU_MODIFY; udata->IndexNumber = index; udata->VUndoData = new TVecData(MainImageForm->Number); udata->VUndoData->Copy((TVecData*)DataList->Items[index]); udata->bFirst = sw; TDU->SrcData = udata; // for new font 11.08 aaaaaaaaaa if (udata->VUndoData->Kind == V_TEXTBOX) { TDU->IndexOfWord = VecDraw->IndexOfWord; } AddToUndoBundle(TDU); }break; case VU_ORDERF: { TPORDERFUndoData * TDU = new TPORDERFUndoData(); udata->Kind = VU_ORDERF; udata->IndexNumber = index; if (nDest) udata->DstNumber = nDest; else udata->DstNumber = DataList->Count - 1; udata->VUndoData = NULL; udata->bFirst = sw; TDU->SrcData = udata; AddToUndoBundle(TDU); }break; case VU_ORDERB: { TPORDERBUndoData * TDU = new TPORDERBUndoData(); udata->Kind = VU_ORDERB; udata->IndexNumber = index; udata->DstNumber = nDest; udata->VUndoData = NULL; udata->bFirst = sw; TDU->SrcData = udata; AddToUndoBundle(TDU); }break; // for new font case VU_TEXTCREATE: { TPTextCreateUndoData * TDU = new TPTextCreateUndoData(); udata->Kind = VU_TEXTCREATE; udata->IndexNumber = index; // -->by linuxjun for CurvedVectorText TVecData * TempVecData = (TVecData*)DataList->Items[index]; if (TempVecData->ListOfAllLine) { if (TempVecData->ListOfAllLine->CurveData) { udata->CurveDataIndexNumber = DataList->IndexOf (TempVecData->ListOfAllLine->CurveData); } else { udata->CurveDataIndexNumber = -1; } } // <--by linuxjun for CurvedVectorText udata->VUndoData = NULL; udata->bFirst = sw; TDU->SrcData = udata; AddToUndoBundle(TDU); VecDraw->BeTextBoxCreated = true; // for new font }break; case VU_TEXTDELETE: { TPTextDeleteUndoData * TDU = new TPTextDeleteUndoData(); udata->Kind = VU_TEXTDELETE; udata->IndexNumber = index; udata->VUndoData = new TVecData(MainImageForm->Number); udata->VUndoData->Copy((TVecData*)DataList->Items[index]); udata->bFirst = sw; // -->by linuxjun for CurvedVectorText TVecData * TempVecData = (TVecData*)DataList->Items[index]; if (TempVecData->ListOfAllLine) { if (TempVecData->ListOfAllLine->CurveData) { udata->CurveDataIndexNumber = DataList->IndexOf (TempVecData->ListOfAllLine->CurveData); } else { udata->CurveDataIndexNumber = -1; } } // <--by linuxjun for CurvedVectorText TDU->SrcData = udata; AddToUndoBundle(TDU); }break; case VU_TEXTMODIFY: { TPTextModifyUndoData * TDU = new TPTextModifyUndoData(); udata->Kind = VU_TEXTMODIFY; udata->IndexNumber = index; udata->VUndoData = new TVecData(MainImageForm->Number); udata->VUndoData->Copy((TVecData*)DataList->Items[index]); udata->bFirst = sw; // -->by linuxjun for CurvedVectorText TVecData * TempVecData = (TVecData*)DataList->Items[index]; if (TempVecData->ListOfAllLine) { if (TempVecData->ListOfAllLine->CurveData) { udata->CurveDataIndexNumber = DataList->IndexOf (TempVecData->ListOfAllLine->CurveData); } else { udata->CurveDataIndexNumber = -1; } } // <--by linuxjun for CurvedVectorText TDU->SrcData = udata; TDU->IndexOfWord = VecDraw->IndexOfWord; AddToUndoBundle(TDU); }break; case VU_MOTIVECREATE: { TPMotiveCreateUndoData * TDU = new TPMotiveCreateUndoData(); udata->Kind = VU_TEXTCREATE; udata->IndexNumber = index; // -->by embakum for motiveobject TVecData * TempVecData = (TVecData*)DataList->Items[index]; if (TempVecData->ChildList) { if (udata->ChildList) udata->DeleteChildList(); udata->ChildList = new TList; for (int i = 0; i < TempVecData->ChildList->Count; i++) { TVecData *child = new TVecData(MainImageForm->Number); TVecData *temp = (TVecData*)TempVecData->ChildList->Items[i]; child->Copy(temp); udata->ChildList->Add(child); } } // <--by embakum for motiveobject udata->VUndoData = NULL; udata->bFirst = sw; TDU->SrcData = udata; AddToUndoBundle(TDU); VecDraw->BeTextBoxCreated = true; // for new font }break; case VU_MOTIVEDELETE: { TPMotiveDeleteUndoData * TDU = new TPMotiveDeleteUndoData(); udata->Kind = VU_MOTIVEDELETE; udata->IndexNumber = index; udata->VUndoData = new TVecData(MainImageForm->Number); udata->VUndoData->Copy((TVecData*)DataList->Items[index]); udata->bFirst = sw; // -->by embakum for motiveobject TVecData * TempVecData = (TVecData*)DataList->Items[index]; if (TempVecData->ChildList) { udata->ChildList = new TList; for (int i = 0; i < TempVecData->ChildList->Count; i++) { TVecData *child = new TVecData(MainImageForm->Number); TVecData *temp = (TVecData*)TempVecData->ChildList->Items[i]; child->Copy(temp); udata->ChildList->Add(child); } } // <--by embakum for motiveobject TDU->SrcData = udata; AddToUndoBundle(TDU); }break; } fail: END_LOG; return; } // --------------------------------------------------------------------------- void __fastcall TPVectorUndo::UndoRead() { BEGIN_LOG(""); if (canundo()) { // RedoSave(); getUndoBundle(IndexOfUndo--); UndoBundle->UndoDatas(); VecDraw->BeTextBoxCreated = false; // for new font VecDraw->BeModified = false; // for new font } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPVectorUndo::RedoRead() { BEGIN_LOG(""); if (canredo()) { getUndoBundle(++IndexOfUndo); UndoBundle->RedoDatas(); VecDraw->BeTextBoxCreated = false; // for new font VecDraw->BeModified = false; // for new font } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPVectorUndo::getUndoBundle(int IndexOfUndo) { BEGIN_LOG(""); // TPVectorUndoBundle *tempBundle; if (IndexOfUndo < DataOfUndo->Count) { UndoBundle = (TPVectorUndoBundle*)DataOfUndo->Items[IndexOfUndo]; } else { UndoBundle = (TPVectorUndoBundle*)DataOfUndo->Last(); } // return *tempBundle; END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPVectorUndo::RemoveLastEltNum(int num) { BEGIN_LOG(""); TPVectorUndoBundle * tempBundle; while (num > 0) { tempBundle = (TPVectorUndoBundle*)DataOfUndo->Last(); num = tempBundle->RemoveLastEltNum(num); if (num >= 0) { DataOfUndo->Remove(tempBundle); tempBundle->bCreateAtTail = true; delete tempBundle; } } if (DataOfUndo->Count <= IndexOfUndo) IndexOfUndo = DataOfUndo->Count - 1; END_LOG; // return true; } // --------------------------------------------------------------------------- bool __fastcall TPVectorUndo::RemoveLast() { BEGIN_LOG(""); TPVectorUndoBundle * tempBundle; tempBundle = (TPVectorUndoBundle*)DataOfUndo->Last(); DataOfUndo->Remove(tempBundle); tempBundle->bCreateAtTail = true; delete tempBundle; if (DataOfUndo->Count <= IndexOfUndo) IndexOfUndo = DataOfUndo->Count - 1; END_LOG; return true; } // --------------------------------------------------------------------------- bool __fastcall TPVectorUndo::RemoveFirst() { BEGIN_LOG(""); TPVectorUndoBundle * tempBundle; tempBundle = (TPVectorUndoBundle*)DataOfUndo->First(); DataOfUndo->Remove(tempBundle); tempBundle->bDeleteAtHead = true; delete tempBundle; if (IndexOfUndo > -1) IndexOfUndo--; END_LOG; return true; } // --------------------------------------------------------------------------- __fastcall TPVectorUndoBundle::TPVectorUndoBundle(TList *dataList) // __fastcall TPVectorUndoBundle::TPVectorUndoBundle() { BundleOfUndoData = new TList(); BundleOfRedoData = new TList(); IsFirstRedoStep = true; bDeleteAtHead = false; bCreateAtTail = false; DataList = dataList; // ParentUndoManager = Parent; } // --------------------------------------------------------------------------- __fastcall TPVectorUndoBundle::~TPVectorUndoBundle() { BEGIN_LOG(""); // DeleteBundleData(); if (BundleOfUndoData) { // by linuxjun 2004.09.02 while (BundleOfUndoData->Count > 0) { RemoveLastUndo(); } delete BundleOfUndoData; } if (BundleOfRedoData) { // by linuxjun 2004.09.02 while (BundleOfRedoData->Count > 0) { RemoveLastRedo(); } delete BundleOfRedoData; } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPVectorUndoBundle::AddUndoData(TPVectorUndoData * TDUT) { TDUT->DataList = DataList; BundleOfUndoData->Add(TDUT); } // --------------------------------------------------------------------------- void __fastcall TPVectorUndoBundle::AddRedoData(TPVectorUndoData * UndoData) { TPVectorUndoData * TDUT; TDUT = MakeRedoData(UndoData); TDUT->DataList = DataList; BundleOfRedoData->Add(TDUT); } // --------------------------------------------------------------------------- TPVectorUndoData * __fastcall TPVectorUndoBundle::MakeRedoData (TPVectorUndoData * TDUT) { BEGIN_LOG(""); TVUndoData * rdata; TVecData * data; TVUndoData * udata = TDUT->SrcData; if ((rdata = new TVUndoData(MainImageForm->Number)) == NULL) { END_LOG; return NULL; } switch(udata->Kind) { case VU_CREATE: { TPDeleteUndoData * TDU = new TPDeleteUndoData(); data = (TVecData*)DataList->Items[udata->IndexNumber]; rdata->Kind = VU_DELETE; rdata->IndexNumber = udata->IndexNumber; rdata->VUndoData = new TVecData(MainImageForm->Number); rdata->VUndoData->Copy(data); rdata->bFirst = udata->bFirst; /* DataList->Delete(udata->IndexNumber); delete data; data = NULL; // if (udata->IndexNumber == Index) deSelect(); // Áö¿öÁö´Â°æ¿ì¿¡ Select°¡ µÇ¸é ¾ÈµÇ´Ï±î UndoList->Delete(i); i--; delete udata->VUndoData; udata->VUndoData = NULL; */ TDU->SrcData = rdata; END_LOG; return TDU; } case VU_DELETE: { TPCreateUndoData * TDU = new TPCreateUndoData(); rdata->Kind = VU_CREATE; rdata->IndexNumber = udata->IndexNumber; rdata->VUndoData = NULL; rdata->bFirst = udata->bFirst; /* if ((data = new TVecData(MainImageForm->Number))==NULL) goto fail; data->Copy(udata->VUndoData); DataList->Insert(udata->IndexNumber, data); UndoList->Delete(i); i--; delete udata->VUndoData; udata->VUndoData = NULL; */ TDU->SrcData = rdata; END_LOG; return TDU; } case VU_MODIFY: { TPModifyUndoData * TDU = new TPModifyUndoData(); data = (TVecData*)DataList->Items[udata->IndexNumber]; rdata->Kind = VU_MODIFY; rdata->IndexNumber = udata->IndexNumber; rdata->VUndoData = new TVecData(MainImageForm->Number); rdata->VUndoData->Copy(data); rdata->bFirst = udata->bFirst; // for new font 11.08 aaaaaaaaaa if (data->Kind == V_TEXTBOX) { TDU->IndexOfWord = ((TPTextModifyUndoData*)TDUT)->IndexOfWord; } /* data->Copy(udata->VUndoData); // data->bSelected = false; // NVector->bSelected = false; UndoList->Delete(i); i--; delete udata->VUndoData; udata->VUndoData = NULL; */ TDU->SrcData = rdata; END_LOG; return TDU; } case VU_ORDERF: { TPORDERFUndoData * TDU = new TPORDERFUndoData(); /* DataList->Move(udata->DstNumber, udata->IndexNumber); */ rdata->Kind = VU_ORDERB; rdata->IndexNumber = udata->DstNumber; rdata->DstNumber = udata->IndexNumber; rdata->VUndoData = NULL; rdata->bFirst = udata->bFirst; /* UndoList->Delete(i); i--; delete udata->VUndoData; udata->VUndoData = NULL; deSelect(); // orderÀÇ index°¡ ¼¯À̹ǷΠ¸ðµç ¼±ÅÃÀ» ÇØÁ¦½ÃŲ´Ù */ TDU->SrcData = rdata; END_LOG; return TDU; } case VU_ORDERB: { TPORDERBUndoData * TDU = new TPORDERBUndoData(); /* DataList->Move(udata->DstNumber, udata->IndexNumber); */ rdata->Kind = VU_ORDERF; rdata->IndexNumber = udata->DstNumber; rdata->DstNumber = udata->IndexNumber; rdata->VUndoData = NULL; rdata->bFirst = udata->bFirst; /* UndoList->Delete(i); i--; delete udata->VUndoData; udata->VUndoData = NULL; deSelect(); // orderÀÇ index°¡ ¼¯À̹ǷΠ¸ðµç ¼±ÅÃÀ» ÇØÁ¦½ÃŲ´Ù */ TDU->SrcData = rdata; END_LOG; return TDU; } /* case VU_NOTHING: { rdata->Kind = VU_NOTHING; rdata->IndexNumber = udata->IndexNumber; rdata->VUndoData = NULL; rdata->bFirst = udata->bFirst; UndoList->Delete(i); i--; delete udata->VUndoData; udata->VUndoData = NULL; break; } */ // for new font case VU_TEXTCREATE: { TPTextDeleteUndoData * TDU = new TPTextDeleteUndoData(); data = (TVecData*)DataList->Items[udata->IndexNumber]; rdata->Kind = VU_TEXTDELETE; rdata->IndexNumber = udata->IndexNumber; rdata->CurveDataIndexNumber = udata->CurveDataIndexNumber; // by linuxjun for CurvedVectorText rdata->VUndoData = new TVecData(MainImageForm->Number); rdata->VUndoData->Copy(data); rdata->bFirst = udata->bFirst; TDU->SrcData = rdata; END_LOG; return TDU; } case VU_TEXTDELETE: { TPTextCreateUndoData * TDU = new TPTextCreateUndoData(); rdata->Kind = VU_TEXTCREATE; rdata->IndexNumber = udata->IndexNumber; rdata->CurveDataIndexNumber = udata->CurveDataIndexNumber; // by linuxjun for CurvedVectorText rdata->VUndoData = NULL; rdata->bFirst = udata->bFirst; TDU->SrcData = rdata; END_LOG; return TDU; } case VU_TEXTMODIFY: { TPTextModifyUndoData * TDU = new TPTextModifyUndoData(); data = (TVecData*)DataList->Items[udata->IndexNumber]; rdata->Kind = VU_TEXTMODIFY; rdata->IndexNumber = udata->IndexNumber; rdata->CurveDataIndexNumber = udata->CurveDataIndexNumber; // by linuxjun for CurvedVectorText rdata->VUndoData = new TVecData(MainImageForm->Number); rdata->VUndoData->Copy(data); rdata->bFirst = udata->bFirst; TDU->SrcData = rdata; TDU->IndexOfWord = ((TPTextModifyUndoData*)TDUT)->IndexOfWord; END_LOG; return TDU; } } TPVectorUndoData * TDOU = new TPVectorUndoData(); TDOU->SrcData = rdata; END_LOG; return TDOU; } // --------------------------------------------------------------------------- bool __fastcall TPVectorUndoBundle::UndoDatas() { BEGIN_LOG(""); TPVectorUndoData *tempData; // for(int i = 0 ; i < BundleOfUndoData->Count; i++) for (int i = BundleOfUndoData->Count - 1; i >= 0; i--) { tempData = (TPVectorUndoData*)BundleOfUndoData->Items[i]; if (IsFirstRedoStep) { AddRedoData(tempData); // Redo Data¸¦ ¸¸µé±â À§ÇÑ ºÎºÐ } tempData->GetData(); } if (IsFirstRedoStep) { IsFirstRedoStep = false; } END_LOG; return true; } // --------------------------------------------------------------------------- bool __fastcall TPVectorUndoBundle::RedoDatas() { BEGIN_LOG(""); TPVectorUndoData *tempData; // for(int i = 0 ; i < BundleOfRedoData->Count; i++) for (int i = BundleOfUndoData->Count - 1; i >= 0; i--) { tempData = (TPVectorUndoData*)BundleOfRedoData->Items[i]; tempData->GetData(); } END_LOG; return true; } // --------------------------------------------------------------------------- int __fastcall TPVectorUndoBundle::RemoveLastEltNum(int num) { BEGIN_LOG(""); int cnt = BundleOfUndoData->Count; // int resultNum; if (num > 0) { if (!IsFirstRedoStep) { // redo µ¥ÀÌÅÍ´Â ±âº»ÀûÀ¸·Î reset½ÃÅ´. while (BundleOfRedoData->Count) { RemoveLastRedo(); } if (BundleOfRedoData) { delete BundleOfRedoData; BundleOfRedoData = NULL; } // by linuxjun 2004.09.02 IsFirstRedoStep = true; } // °¹¼ö¸¸Å­ UndoData¸¦ Áö¿ò. for (int i = 0; i < num && BundleOfUndoData->Count > 0; i++) { RemoveLastUndo(); } if (BundleOfUndoData->Count == 0) { if (BundleOfUndoData) { delete BundleOfUndoData; BundleOfUndoData = NULL; } // by linuxjun 2004.09.02 } } END_LOG; return num - cnt; } // --------------------------------------------------------------------------- bool __fastcall TPVectorUndoBundle::RemoveLastUndo() { BEGIN_LOG(""); TPVectorUndoData * tempData; tempData = (TPVectorUndoData*)BundleOfUndoData->Last(); BundleOfUndoData->Remove(tempData); tempData->bDeleteAtHead = bDeleteAtHead; tempData->bCreateAtTail = bCreateAtTail; DeleteData(tempData); // delete tempData; //delete´Â °¢°¢ÀÇ type¿¡ ¸Â°Ô Áö¿ö¾ß ÇϹǷΠ°¢ÀÚÀÇ Å¬·¡½º¿¡¼­ Çϴ°ÍÀ¸·Î ÇÑ´Ù. END_LOG; return true; } // --------------------------------------------------------------------------- bool __fastcall TPVectorUndoBundle::RemoveLastRedo() { BEGIN_LOG(""); TPVectorUndoData * tempData; tempData = (TPVectorUndoData*)BundleOfRedoData->Last(); BundleOfRedoData->Remove(tempData); tempData->bDeleteAtHead = bDeleteAtHead; tempData->bCreateAtTail = bCreateAtTail; DeleteData(tempData); // delete tempData; //delete´Â °¢°¢ÀÇ type¿¡ ¸Â°Ô Áö¿ö¾ß ÇϹǷΠ°¢ÀÚÀÇ Å¬·¡½º¿¡¼­ Çϴ°ÍÀ¸·Î ÇÑ´Ù. END_LOG; return true; } // --------------------------------------------------------------------------- bool __fastcall TPVectorUndoBundle::DeleteData(TPVectorUndoData *Data) { if (Data) delete Data; return true; } // --------------------------------------------------------------------------- __fastcall TPVectorUndoData::TPVectorUndoData() { SrcData = NULL; VUndoData = NULL; DataList = NULL; } // --------------------------------------------------------------------------- __fastcall TPVectorUndoData::~TPVectorUndoData() { BEGIN_LOG(""); if (SrcData->VUndoData) { // -->by linuxjun for CurvedVectorText // * if (SrcData->VUndoData->ListOfAllLine) { if (SrcData->VUndoData->ListOfAllLine->CurveData) { delete SrcData->VUndoData->ListOfAllLine->CurveData; SrcData->VUndoData->ListOfAllLine->CurveData = NULL; } } // */ // <--by linuxjun for CurvedVectorText delete SrcData->VUndoData; SrcData->VUndoData = NULL; } delete SrcData; SrcData = NULL; END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPVectorUndoData::deSelect() { BEGIN_LOG(""); TVecData * data; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; data->bSelected = false; } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPVectorUndoData::GetData() { return; } // --------------------------------------------------------------------------- void __fastcall TPCreateUndoData::GetData() { BEGIN_LOG(""); TVecData * data; data = (TVecData*)DataList->Items[SrcData->IndexNumber]; DataList->Delete(SrcData->IndexNumber); if (data) delete data; data = NULL; END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPDeleteUndoData::GetData() { BEGIN_LOG(""); TVecData * data; if ((data = new TVecData(MainImageForm->Number)) == NULL) goto fail; data->Copy(SrcData->VUndoData); DataList->Insert(SrcData->IndexNumber, data); END_LOG; return; fail: END_LOG; return; } // --------------------------------------------------------------------------- void __fastcall TPModifyUndoData::GetData() { BEGIN_LOG(""); TVecData * data; data = (TVecData*)DataList->Items[SrcData->IndexNumber]; data->Copy(SrcData->VUndoData); // for new font 11.08 aaaaaaaaaa if (data->Kind == V_TEXTBOX) { VecDraw->CurrentTextBox = SrcData->IndexNumber; VecDraw->SetCaretPozByIndex(IndexOfWord); // MainImageForm->tempRadioButton->SetFocus(); VecDraw->BeReadyEdit = true; // -->by linuxjun for CurvedVectorText if (data->ListOfAllLine) { if (data->ListOfAllLine->CurveData) { VecDraw->MakeTextBoxPointList(data); } } // <--by linuxjun for CurvedVectorText } // -->by linuxjun for CurvedVectorText if (data->ParentTextBox) { if (data->ParentTextBox->ListOfAllLine) { if (data->ParentTextBox->ListOfAllLine->CurveData) { VecDraw->MakeTextBoxPointList(data->ParentTextBox); } } } // <--by linuxjun for CurvedVectorText // data->bSelected = false; // NVector->bSelected = false; END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPORDERFUndoData::GetData() { DataList->Move(SrcData->DstNumber, SrcData->IndexNumber); deSelect(); // orderÀÇ index°¡ ¼¯À̹ǷΠ¸ðµç ¼±ÅÃÀ» ÇØÁ¦½ÃŲ´Ù } // --------------------------------------------------------------------------- void __fastcall TPORDERBUndoData::GetData() { DataList->Move(SrcData->DstNumber, SrcData->IndexNumber); deSelect(); // orderÀÇ index°¡ ¼¯À̹ǷΠ¸ðµç ¼±ÅÃÀ» ÇØÁ¦½ÃŲ´Ù } // --------------------------------------------------------------------------- // for new font void __fastcall TPTextCreateUndoData::GetData() { BEGIN_LOG(""); TVecData * data; data = (TVecData*)DataList->Items[SrcData->IndexNumber]; DataList->Delete(SrcData->IndexNumber); // -->by linuxjun for CurvedVectorText if (data->ListOfAllLine) { if (data->ListOfAllLine->CurveData) { if (SrcData->CurveDataIndexNumber >= 0) { DataList->Delete(SrcData->CurveDataIndexNumber); } delete data->ListOfAllLine->CurveData; data->ListOfAllLine->CurveData = NULL; } } // -->by linuxjun for CurvedVectorText if (data) delete data; data = NULL; VecDraw->BeReadyEdit = false; END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPTextDeleteUndoData::GetData() { BEGIN_LOG(""); TVecData * data; if ((data = new TVecData(MainImageForm->Number)) == NULL) goto fail; data->Copy(SrcData->VUndoData); // -->by linuxjun for CurvedVectorText if (data->ListOfAllLine) { if (data->ListOfAllLine->CurveData) { if (SrcData->CurveDataIndexNumber >= 0) { DataList->Insert(SrcData->CurveDataIndexNumber, data->ListOfAllLine->CurveData); VecDraw->MakeTextBoxPointList(data); } } } // <--by linuxjun for CurvedVectorText DataList->Insert(SrcData->IndexNumber, data); VecDraw->BeReadyEdit = false; END_LOG; return; fail: END_LOG; return; } // --------------------------------------------------------------------------- void __fastcall TPTextModifyUndoData::GetData() { BEGIN_LOG(""); TVecData * data; data = (TVecData*)DataList->Items[SrcData->IndexNumber]; data->Copy(SrcData->VUndoData); // -->by linuxjun for CurvedVectorText if (data->ListOfAllLine) { if (data->ListOfAllLine->CurveData) { VecDraw->MakeTextBoxPointList(data); } } // <--by linuxjun for CurvedVectorText VecDraw->CurrentTextBox = SrcData->IndexNumber; VecDraw->SetCaretPozByIndex(IndexOfWord); // MainImageForm->tempRadioButton->SetFocus(); VecDraw->BeReadyEdit = true; // data->bSelected = true; END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPMotiveCreateUndoData::GetData() { BEGIN_LOG(""); TVecData * data; data = (TVecData*)DataList->Items[SrcData->IndexNumber]; DataList->Delete(SrcData->IndexNumber); if (data) delete data; data = NULL; VecDraw->BeReadyEdit = false; END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPMotiveDeleteUndoData::GetData() { BEGIN_LOG(""); TVecData * data; if ((data = new TVecData(MainImageForm->Number)) == NULL) goto fail; data->Copy(SrcData->VUndoData); DataList->Insert(SrcData->IndexNumber, data); VecDraw->BeReadyEdit = false; END_LOG; return; fail: END_LOG; return; } // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // -------- Library Part --------------------------------------------- /************************************************************************* * FUNCTION: CCW (CounterClockWise) * * PURPOSE * Determines, given three points, if when travelling from the first to * the second to the third, we travel in a counterclockwise direction. * * RETURN VALUE * (int) 1 if the movement is in a counterclockwise direction, -1 if * not. *************************************************************************/ int CCW(POINT p0, POINT p1, POINT p2) { LONG dx1, dx2 ; LONG dy1, dy2 ; dx1 = p1.x - p0.x ; dx2 = p2.x - p0.x ; dy1 = p1.y - p0.y ; dy2 = p2.y - p0.y ; /* This is basically a slope comparison: we don't do divisions because * of divide by zero possibilities with pure horizontal and pure * vertical lines. */ return ((dx1 * dy2 > dy1 * dx2) ? 1 : -1) ; } // --------------------------------------------------------------------------- // µÎ ¶óÀÎÀÇ ±³Á¡ÀÌ ÀÖ´ÂÁö È®ÀÎÇÏ´Â ÇÔ¼ö /************************************************************************* * FUNCTION: Intersect * * PURPOSE * Given two line segments, determine if they intersect. * * RETURN VALUE * TRUE if they intersect, FALSE if not. *************************************************************************/ bool __fastcall TVecDraw::IsLineIntersect(POINT p1, POINT p2, POINT p3, POINT p4) { return ((( CCW(p1, p2, p3) * CCW(p1, p2, p4)) <= 0) && (( CCW(p3, p4, p1) * CCW(p3, p4, p2) <= 0) )) ; } // --------------------------------------------------------------------------- // Polygon¾È¿¡ Á¡ÀÌ Æ÷ÇԵǾî ÀÖ´ÂÁö È®ÀÎÇÏ´Â ÇÔ¼ö /************************************************************************* * FUNCTION: G_PtInPolygon * * PURPOSE * This routine determines if the point passed is in the polygon. It uses * the classical polygon hit-testing algorithm: a horizontal ray starting * at the point is extended infinitely rightwards and the number of * polygon edges that intersect the ray are counted. If the number is odd, * the point is inside the polygon. * * RETURN VALUE * (BOOL) TRUE if the point is inside the polygon, FALSE if not. *************************************************************************/ bool __fastcall TVecDraw::G_PtInPolygon(POINT *rgpts, WORD wnumpts, POINT ptTest, RECT *prbound) { RECT r ; POINT *ppt ; WORD i ; POINT pt1, pt2 ; WORD wnumintsct = 0 ; if (!G_PtInPolyRect(rgpts,wnumpts,ptTest,prbound)) return FALSE ; pt1 = pt2 = ptTest ; pt2.x = r.right + 50 ; // Now go through each of the lines in the polygon and see if it // intersects for (i = 0, ppt = rgpts ; i < wnumpts-1 ; i++, ppt++) { if (IsLineIntersect(ptTest, pt2, *ppt, *(ppt+1))) wnumintsct++ ; } // And the last line if (IsLineIntersect(ptTest, pt2, *ppt, *rgpts)) wnumintsct++ ; return (wnumintsct&1) ; } // --------------------------------------------------------------------------- /************************************************************************* * FUNCTION: G_PtInPolyRect * * PURPOSE * This routine determines if a point is within the smallest rectangle * that encloses a polygon. * * RETURN VALUE * (BOOL) TRUE or FALSE depending on whether the point is in the rect or * not. *************************************************************************/ bool __fastcall TVecDraw::G_PtInPolyRect(POINT *rgpts, WORD wnumpts, POINT ptTest, RECT *prbound) { RECT r ; // If a bounding rect has not been passed in, calculate it // if (prbound) // // r = *prbound ; // // else // { int xmin, xmax, ymin, ymax ; POINT *ppt ; WORD i ; xmin = ymin = INT_MAX ; xmax = ymax = -INT_MAX ; for (i=0, ppt = rgpts ; i < wnumpts ; i++, ppt++) { if (ppt->x < xmin) xmin = ppt->x ; if (ppt->x > xmax) xmax = ppt->x ; if (ppt->y < ymin) ymin = ppt->y ; if (ppt->y > ymax) ymax = ppt->y ; } ::SetRect(&r, xmin, ymin, xmax, ymax) ; // } return (PtInRect(&r,ptTest)) ; } // --------------------------------------------------------------------------- /** Vector Line ¼±Åà ±â´É * PathToRegion, PtInRegion ¹æ½ÄÀ» »ç¿ëÇÏÁö ¾Êµµ·Ï ±â´É °³¼± - by david (24.08.20) */ double __fastcall TVecDraw::PointOnCurvePath(TVecData *data, int X, int Y, int px, int py, int distance, double dRatio) { HDC dcDst = MainImageForm->iMainImage->Canvas->Handle; float nPenThick; double nResult = -1.0, CurDist = 0.0; bool bBreak = false; POINT *pPoints = NULL; // pPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) int nX, nY; float ZoomIn = MainImageForm->iMainImage->ZoomIn; // SelectObject½Ã ZoomÀÌ¿ë by hayoungc 150312 float ZoomOut = MainImageForm->iMainImage->ZoomOut; if (dRatio == 0) { return nResult; } nX = (X + px) / dRatio; nY = (Y + py) / dRatio; if (data->Kind == V_TEXTBOX) { pPoints = new POINT[5]; } else { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new POINT[(data->nCount + 1) * 3 + 1]; } else { pPoints = new POINT[data->nCount * 3 + 1]; } } int nNumPoints = data->nCount * 3 + 1; for (int i = 0; i < nNumPoints; i++) pPoints[i] = data->pList[i].P(); if (distance == -1) { // SelectObject½Ã ZoomÀÌ¿ë by hayoungc 150312 if (ZoomIn > ZoomOut) { if (ZoomIn/ZoomOut >= 6) { nPenThick = data->PenThick; } else { nPenThick = data->PenThick; if (data->PenThick <= 1) { // ±½±â°¡ <=2 ÀÏ °æ¿ì ¾à°£ÀÇ º¸Á¤ nPenThick = data->PenThick * 2; } else if (data->PenThick <= 2) { nPenThick = data->PenThick * 1.5; } } } else { nPenThick = data->PenThick < 5 / dRatio ? 5 / dRatio : data->PenThick; } // rgnÀ» ±×¸®´Â ÆæÀÇ ±½±â·Î ¸¶¿ì½º ÁÂÇ¥¿ÍÀÇ °Å¸®¸¦ ¾Ë¼ö ÀÖ´Ù } else { nPenThick = data->PenThick + distance; // rgnÀ» ±×¸®´Â ÆæÀÇ ±½±â·Î ¸¶¿ì½º ÁÂÇ¥¿ÍÀÇ °Å¸®¸¦ ¾Ë¼ö ÀÖ´Ù } // ¼Óµµ¸¦ ºü¸£°Ô Çϱâ À§ÇØ - by monkman (2007.10.05) if (nX < (data->First.x - nPenThick) || (data->Second.x + nPenThick) < nX || nY < (data->First.y - nPenThick) || (data->Second.y + nPenThick) < nY) { if (pPoints) delete[]pPoints; pPoints = NULL; return nResult; } //Begin the path. // POINT ptMouse = {nX, nY}; int GetPathNum = 0; if (BeginPath(dcDst)) { // //Draw a Bezier curve into the path. // PolyBezier(dcDst, pPoints, nNumPoints); // //Select the path into the DC. // if (EndPath(dcDst)) { // //Flatten the path to produce a list of the line segments used to produce //the curve. // if (FlattenPath(dcDst)) // //Get the number of vertices contained in the list of line segments. // GetPathNum = GetPath(dcDst, (LPPOINT)NULL, (LPBYTE)NULL, 0); // //If the call was successful then the number of points is known and > 0. // if (GetPathNum > 0) { // //Allocate memory for the list of path vertices and vertex types. // POINT *lpPt; BYTE *lpB; lpPt = (LPPOINT)malloc((DWORD)(sizeof(POINT) * GetPathNum)); lpB = (LPBYTE)malloc((DWORD)(sizeof(BYTE) * GetPathNum)); // //Go and really get them this time. // GetPathNum = GetPath(dcDst, lpPt, lpB, GetPathNum); // //Move through the list and test if the mouse click happened on any of the //line segments. // // Á÷¼±ÀÏ °æ¿ì line segment·Î ºÐÇØÇß´ø °ÍÀ» ´Ù½Ã ÃʱâÈ­ ÇØÁØ´Ù. by hayoungc 150313 int lpPtIndex = 0; for (int i = 0 ; i < nNumPoints ; i++) { if (i+3 < nNumPoints) { if (pPoints[i].x == pPoints[i+1].x && pPoints[i].y == pPoints[i+1].y) { if ( (pPoints[i+1].x != pPoints[i+2].x || pPoints[i+1].y != pPoints[i+2].y) && (pPoints[i+2].x == pPoints[i+3].x && pPoints[i+2].y == pPoints[i+3].y ) ) { // pPoints[0] == [1] À̰í pPoints[2] == [3] À̸é Á÷¼±ÀÌ´Ù. bool IsFind = false; while (!IsFind && lpPtIndex < GetPathNum) { if (pPoints[i].x == lpPt[lpPtIndex].x && pPoints[i].y == lpPt[lpPtIndex].y) { //lpPt¿¡¼­ Á÷¼±ÀÇ ½ÃÀÛÁ¡À» ã´Â´Ù. IsFind = true; } else { lpPtIndex++; } } IsFind = false; int lpPtEnd = lpPtIndex + 1; while (!IsFind && lpPtEnd < GetPathNum) { if ( (pPoints[i+2].x == lpPt[lpPtEnd].x && pPoints[i+2].y == lpPt[lpPtEnd].y) ) { //lpPt¿¡¼­ Á÷¼±ÀÇ ³¡Á¡À» ã´Â´Ù. IsFind = true; // ã¾ÒÀ¸¸é Áß°£ Á¡µéÀ» ¾ø¾ÖÁØ´Ù. ( ³¡Á¡°ªÀ¸·Î ¹Ù²ãÁÜ ) for (int k = lpPtIndex+1 ; k < lpPtEnd ; k++) { lpPt[k] = pPoints[i+2]; } lpPtIndex = lpPtEnd; // ´ÙÀ½ °Ë»öÀÇ ½ÃÀÛÁ¡ } else { lpPtEnd++; } } i = i + 2; // ÀÛ¾÷À» ÇØÁØ pPoints´Â °Ç³Ê¶Ú´Ù. } } } // if (i+3 < nNumPoints) } for (int nPt = 0; nPt < GetPathNum - 1; nPt++) { // Á÷¼±ÀÌ ¾Æ´Ñ °æ¿ì´Â °Ç³Ê¶Ù¾îµµ µÊ if (nPt+1 < GetPathNum && (lpPt[nPt].x == lpPt[nPt+1].x && lpPt[nPt].y == lpPt[nPt+1].y)) continue; // //Is the point on the line? // CurDist = HitTestLine(lpPt[nPt], lpPt[nPt+1], ptMouse, nPenThick); if (CurDist <= (nPenThick/2+0.25)) { nResult = CurDist; break; } } free(lpPt); free(lpB); } } } if (pPoints) delete[]pPoints; pPoints = NULL; return nResult; } // --------------------------------------------------------------------------- int __fastcall TVecDraw::InitTrans(bool Back) { TList *DataList = NVector->DataList; TVecData *data = NULL, *cdata = NULL, *childdata = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) PasteRange = Rect(50000, 50000, 0, 0); TList *TransList; RECT rect; // TEXTBOX¸¦ °¡Á®¿Ã ¼ö ¾ø´Ù´Â ¸Þ½ÃÁö¸¦ Çѹø¸¸ Ãâ·ÂÇϱâ À§ÇØ Ãß°¡ - by monkman (2004.11.05) bool bOKClick; ElementSet element; bool bDoNotMotiveTrans = false; bool bDoNotMotiveFill = false; if (Back) TransList = TransList2; else TransList = TransList1; if (TransList) { for (int i = 0; i < TransList->Count; i++) { cdata = (TVecData*)TransList->Items[i]; if (cdata) delete cdata; cdata = NULL; } TransList->Clear(); } bOKClick = false; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; // Motive Vector ³»ºÎ °Ë»ç - by monkman (2009.05.07) bDoNotMotiveTrans = false; if (data->bMotive && data->ChildList && data->ChildList->Count > 0) { element.Clear(); element = VecDraw->ElementsInList(data->ChildList, false); if (element.Contains(E_TEXTBOX) || element.Contains(E_PTEXTBOX)) { bDoNotMotiveTrans = true; } } // ¹®ÀÚ¸¦ Æ÷ÇÔÇÏ´Â º¤ÅÍ´Â °¡Á®¿Ã ¼ö ¾øÀ½ - by monkman (2009.05.07) if (data->Kind == V_TEXTBOX || data->ParentTextBox || bDoNotMotiveTrans) { if (!bOKClick) { // ¸Þ½ÃÁö : ¹®ÀÚ´Â °¡Á®¿Ã ¼ö ¾ø½À´Ï´Ù. MessageDlg(IDS_MESSAGE004, mtWarning, TMsgDlgButtons() << mbOK, 0); bOKClick = true; } continue; // MakeTextBoxPointList(data); // È®½ÇÇÏ°Ô È®ÀÎÇϱâ À§Çؼ­ ½ÇÇà // GetRectForMouseMove(data, rect); // PasteRange.left = min(PasteRange.left, rect.left); // PasteRange.right = max(PasteRange.right, rect.right); // PasteRange.top = min(PasteRange.top, rect.top); // PasteRange.bottom = max(PasteRange.bottom, rect.bottom); } else { SET_RECT; PasteRange.left = min(PasteRange.left, min(data->First.x, data->Second.x) - (data->PenThick + 1) * 2); PasteRange.right = max(PasteRange.right, max(data->First.x, data->Second.x) + (data->PenThick + 1) * 2); PasteRange.top = min(PasteRange.top, min(data->First.y, data->Second.y) - (data->PenThick + 1) * 2); PasteRange.bottom = max(PasteRange.bottom, max(data->First.y, data->Second.y) + (data->PenThick + 1) * 2); } } for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; // Motive Vector ³»ºÎ °Ë»ç - by monkman (2009.05.07) bDoNotMotiveTrans = false; bDoNotMotiveFill = false; if (data->bMotive && data->ChildList && data->ChildList->Count > 0) { element.Clear(); element = VecDraw->ElementsInList(data->ChildList, false); // ¹®ÀÚ¸¦ Æ÷ÇÔÇÏ´Â º¤ÅÍ´Â °¡Á®¿Ã ¼ö ¾øÀ½ - by monkman (2009.05.07) if (element.Contains(E_TEXTBOX) || element.Contains(E_PTEXTBOX)) { bDoNotMotiveTrans = true; } // ÆÐÅÏÇÊ, if (element.Contains(E_PFILL) || element.Contains(E_GRADIENTFILL)) { bDoNotMotiveFill = true; } } if (data->Kind == V_TEXTBOX || data->ParentTextBox || bDoNotMotiveTrans) continue; cdata = new TVecData(MainImageForm->Number); cdata->Copy(data); // ÆÐÅÏ, ±×¶óµ¥À̼ÇÀÌ µé¾îÀÖ´Â º¤ÅÍ´Â ¿Ü°û¼±¸¸ °¡Á®¿Â´Ù - by monkman (2009.05.08) if (cdata->bPatternFill) { cdata->bPatternFill = false; cdata->PatternAngle = 0; cdata->PatternAdjustX = 0; cdata->PatternAdjustY = 0; if (cdata->TBitmap) delete cdata->TBitmap; cdata->TBitmap = NULL; if (cdata->TBitmapSource) delete cdata->TBitmapSource; cdata->TBitmapSource = NULL; if (cdata->MaskBitmap) delete cdata->MaskBitmap; cdata->MaskBitmap = NULL; } if (cdata->bGradientFill) { cdata->bGradientFill = false; cdata->gradientItem = 0; cdata->gAngle = 0; cdata->gradientColorCount = 0; if (cdata->gradientColors) delete[]cdata->gradientColors; cdata->gradientColors = NULL; } if (cdata->bMotive && bDoNotMotiveFill) { for (int j = 0; j < cdata->ChildList->Count; j++) { childdata = (TVecData*)cdata->ChildList->Items[j]; if (childdata->bPatternFill) { childdata->bPatternFill = false; childdata->PatternAngle = 0; childdata->PatternAdjustX = 0; childdata->PatternAdjustY = 0; if (childdata->TBitmap) delete childdata->TBitmap; childdata->TBitmap = NULL; if (childdata->TBitmapSource) delete childdata->TBitmapSource; childdata->TBitmapSource = NULL; if (childdata->MaskBitmap) delete childdata->MaskBitmap; childdata->MaskBitmap = NULL; } if (childdata->bGradientFill) { childdata->bGradientFill = false; childdata->gradientItem = 0; childdata->gAngle = 0; childdata->gradientColorCount = 0; if (childdata->gradientColors) delete[]childdata->gradientColors; childdata->gradientColors = NULL; } } } cdata->First.x -= PasteRange.left; cdata->Second.x -= PasteRange.left; cdata->First.y -= PasteRange.top; cdata->Second.y -= PasteRange.top; cdata->GroupIndex = 0; // GroupIndex´Â copy¾ÈµÇ°Ô.. if (cdata->Kind == V_LINE || cdata->Kind == V_CURVE) for (int j = 0; j < cdata->nCount * 3 + 1; j++) { cdata->pList[j].x -= PasteRange.left; cdata->pList[j].y -= PasteRange.top; } // TEXTBOX ¼öÁ¤½Ã ÀÌ ºÎºÐÀ» ¼öÁ¤ - by monkman // if (cdata->Kind == V_TEXTBOX) { // cdata->StartPoint.x -= PasteRange.left; // cdata->StartPoint.y -= PasteRange.top; // cdata->CenterPoint.x -= PasteRange.left; // cdata->CenterPoint.y -= PasteRange.top; // for (int i = 0; i < 5; i++) { // cdata->pList[i].x -= PasteRange.left; // cdata->pList[i].y -= PasteRange.top; // } // } cdata->bPatternFill = false; // ÆÐÅÏÀº °¡Á®°¡Áö ¸»ÀÚ if (cdata->Bitmap) { delete cdata->Bitmap; cdata->Bitmap = NULL; } if (cdata->TBitmap) { delete cdata->TBitmap; cdata->TBitmap = NULL; } if (cdata->TBitmapSource) { delete cdata->TBitmapSource; cdata->TBitmapSource = NULL; } if (cdata->MaskBitmap) { delete cdata->MaskBitmap; cdata->MaskBitmap = NULL; } TransList->Add(cdata); } return TransList->Count; } // --------------------------------------------------------------------------- int __fastcall TVecDraw::GetTransCount(bool bBack) { if (!bBack) return TransList1->Count; else return TransList2->Count; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::OnMouseTransDown(TShiftState Shift, int X, int Y, bool Back, int px, int py, double dRatio) { double MinDist = 29999; int MinIndex = -1; int FirstX, FirstY, SecondX, SecondY; nSelPos = 0; TList *TransList; int nX, nY; nX = (X + px) / dRatio; nY = (Y + py) / dRatio; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) if (Back) TransList = TransList2; else TransList = TransList1; for (int i = 0; i < TransList->Count; i++) { data = (TVecData*)TransList->Items[i]; FirstX = data->First.x - data->PenThick; FirstY = data->First.y - data->PenThick; SecondX = data->Second.x + data->PenThick; SecondY = data->Second.y + data->PenThick; data->bSelected = false; if (nX < FirstX || nX > SecondX || nY < FirstY || nY > SecondY) continue; // »ç°¢Çü ¾È¿¡ ÀÖ´ÂÁö °Ë»ç if (data->Kind == V_LINE || data->Kind == V_CURVE) { // Á÷¼±, °î¼±¾ÈÀÇ ¿µ¿ª¿¡ ÀÖ´ÂÁö °Ë»ç if (PointOnCurvePath(data, X, Y, px, py, -1, dRatio) < 0) continue; } if (MinDist > sqrt(pow((nX - (FirstX + SecondX) / 2), 2) + pow((nY - (FirstY + SecondY) / 2), 2))) { MinDist = sqrt(pow((nX - (FirstX + SecondX) / 2), 2) + pow((nY - (FirstY + SecondY) / 2), 2)); MinIndex = i; } // Point MaskÃʱâÈ­ if (data->pMask) { memset(data->pMask, 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); } } if (MinIndex == -1) return; // ÇØ´çÇÏ´Â object°¡ ¾øÀ½ success: data = (TVecData*)TransList->Items[MinIndex]; data->bSelected = true; } // --------------------------------------------------------------------------- bool __fastcall TVecDraw::OnMouseTransMove(int X, int Y, bool Back, int px, int py, double dRatio) { RECT rc; int rg; TList *TransList; int nX, nY; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) if (dRatio == 0) return false; nX = (X + px) / dRatio; nY = (Y + py) / dRatio; if (Back) TransList = TransList2; else TransList = TransList1; for (int i = 0; i < TransList->Count; i++) { data = (TVecData*)TransList->Items[i]; if (!data->bSelected) continue; rg = data->PenThick > 3 ? 3 : data->PenThick; rc = Rect(nX - rg, nY - rg, nX + rg, nY + rg); for (int i = 0; i < data->nCount * 3 + 1; i += 3) { if (PtInRect(&rc, data->pList[i].P())) { return true; } } } return false; } // --------------------------------------------------------------------------- int __fastcall TVecDraw::OnMouseTransSelect(int X, int Y, EObjectTrait ObjectTrait, bool Back, int px, int py, double dRatio) { RECT rc; int rg; TList *TransList; int nX, nY; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) if (dRatio == 0) return -1; nX = (X + px) / dRatio; nY = (Y + py) / dRatio; if (Back) TransList = TransList2; else TransList = TransList1; for (int i = 0; i < TransList->Count; i++) { data = (TVecData*)TransList->Items[i]; if (!data->bSelected) continue; rg = data->PenThick > 3 ? 3 : data->PenThick; rc = Rect(nX - rg, nY - rg, nX + rg, nY + rg); for (int i = 0; i < data->nCount * 3 + 1; i += 3) { if (PtInRect(&rc, data->pList[i].P())) { data->TraitSet << ObjectTrait; return i; } } } return -1; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::InitCombiMerge(TList *list, int number, bool bRead, bool bBack) { TList *DataList = NVector->DataList; long minx = MaxInt, miny = MaxInt, maxx = 0, maxy = 0; int maxthick = 0, cenx, ceny, existindex, existcount, index; bool sw = true; TVecData *data = NULL, *childdata = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) TVecData *cdata = NULL; RECT rect; int srcMaxGroupIndex = 0; // ÀÌÀü¿¡ Merge ÁßÀÎ Vector°¡ ÀÖ´Ù¸é »èÁ¦ÇÑ´Ù - by monkman (2011.05.20) ExitMerge(); existcount = DataList->Count; /* for (int i = 0; i < existcount; i++) { // GroupIndex ¸ÂÃçÁÖ±â data = (TVecData *)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->GroupIndex) continue; existindex |= data->GroupIndex; } */ if (!bRead) { // ÇÕ¼º½Ã¿¡ deSelect(); NVector->bMergeMode = true; NVector->bSelected = true; } for (int i = 0; i < list->Count; i++) { // ¿ì¼± Range ±¸ÇØÁÖ°í data = (TVecData*)list->Items[i]; if (0 <= number && !data->Equal(number)) continue; if (data->Kind == V_TEXTBOX) { GetRectForMouseMove(data, rect); minx = min(minx, rect.left); miny = min(miny, rect.top); maxx = max(maxx, rect.right); maxy = max(maxy, rect.bottom); } else { // SET_RECT; // Ȥ½Ã³ª ÇØ¼­.. // TextBox¿¡¼­´Â SET_RECT¸¦ ¾²¸é ¾ÈµÇ´Âµ¥ À߸ø »ç¿ëÇØ¼­ ÁÖ¼®À¸·Î ¸·°í º¯°æ // by maxleo21c (06.06.17) if ((data->Kind == V_TEXTBOX && data->ParentTextBox) || data->Kind != V_TEXTBOX) { SET_RECT; } minx = min(minx, data->First.x); minx = min(minx, data->Second.x); maxx = max(maxx, data->First.x); maxx = max(maxx, data->Second.x); miny = min(miny, data->First.y); miny = min(miny, data->Second.y); maxy = max(maxy, data->First.y); maxy = max(maxy, data->Second.y); maxthick = max(maxthick, data->PenThick); } } PasteRange = Rect(minx - maxthick, miny - maxthick, maxx + maxthick, maxy + maxthick); cenx = MainImageForm->iMainImage->uBitmap->Width / 2 - (maxx + minx) / 2; ceny = MainImageForm->iMainImage->uBitmap->Height / 2 - (maxy + miny) / 2; MaxThick = maxthick; if (!bRead) { // ÇÕ¼º½Ã¿¡ for (int i = 0; i < list->Count; i++) { data = (TVecData*)list->Items[i]; if (0 <= number && !data->Equal(number)) continue; cdata = new TVecData(MainImageForm->Number); cdata->Copy(data); cdata->First.x -= PasteRange.left; cdata->Second.x -= PasteRange.left; cdata->First.y -= PasteRange.top; cdata->Second.y -= PasteRange.top; cdata->HeaderNumber = bBack ? -(MainImageForm->StyleHeader->Count + 1) : MainImageForm->StyleHeader->Count + 1; if (cdata->Kind == V_LINE || cdata->Kind == V_CURVE) for (int j = 0; j < cdata->nCount * 3 + 1; j++) { cdata->pList[j].x -= PasteRange.left; cdata->pList[j].y -= PasteRange.top; } if (cdata->Kind == V_TEXTBOX) { cdata->StartPoint.x -= PasteRange.left; cdata->StartPoint.y -= PasteRange.top; for (int k = 0; k < 5; k++) { cdata->pList[k].x -= PasteRange.left; cdata->pList[k].y -= PasteRange.top; } cdata->CenterPoint.x = (cdata->First.x + cdata->Second.x) / 2; cdata->CenterPoint.y = (cdata->First.y + cdata->Second.y) / 2; } DataList->Add(cdata); UndoSave(VU_CREATE, DataList->Count - 1, sw); sw = false; } } else { // ºÒ·¯¿À±â for (int i = 0; i < list->Count; i++) { data = (TVecData*)list->Items[i]; if (0 <= number && !data->Equal(number)) continue; cdata = new TVecData(MainImageForm->Number); cdata->Copy(data); cdata->First.x += cenx; cdata->Second.x += cenx; cdata->First.y += ceny; cdata->Second.y += ceny; cdata->HeaderNumber = bBack ? -(MainImageForm->StyleHeader->Count + 1) : MainImageForm->StyleHeader->Count + 1; if (cdata->Kind == V_LINE || cdata->Kind == V_CURVE) for (int j = 0; j < cdata->nCount * 3 + 1; j++) { cdata->pList[j].x += cenx; cdata->pList[j].y += ceny; } if (cdata->Kind == V_TEXTBOX) { cdata->StartPoint.x += cenx; cdata->StartPoint.y += ceny; for (int k = 0; k < 5; k++) { cdata->pList[k].x += cenx; cdata->pList[k].y += ceny; } cdata->CenterPoint.x = (cdata->First.x + cdata->Second.x) / 2; cdata->CenterPoint.y = (cdata->First.y + cdata->Second.y) / 2; } DataList->Add(cdata); UndoSave(VU_CREATE, DataList->Count - 1, sw); sw = false; } } /* for (int k = 10; k < 32; k++) { // µé¾î°¥ GroupindexÁöÁ¤ for (int i = 10; i < 32; i++) { if (existindex & (1 << i)) continue; index = i; break; } for (int i = existcount; i < DataList->Count; i++) { data = (TVecData *)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (data->bSelected) continue; // ÀÌ¹Ì Çѹø ÁöÁ¤µÇ¾îÀÖ´Â °æ¿ì´Â º¸³½´Ù if (!(data->GroupIndex & (1<GroupIndex &= 0x000001ff; data->GroupIndex += 1<bSelected = true; existindex |= 1<Count; i++) { data = (TVecData*)DataList->Items[i]; if (srcMaxGroupIndex < data->GroupIndex / 10000) srcMaxGroupIndex = data->GroupIndex / 10000; } for (int k = 1; k <= srcMaxGroupIndex; k++) { bool sw = true; for (int i = existcount; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (data->bSelected) continue; if (data->GroupIndex / 10000 != k) continue; if (sw) { MainImageForm->GroupIndexState += 10000; sw = false; } data->GroupIndex = ((data->GroupIndex % 10000) & 0x000001ff) + MainImageForm->GroupIndexState; data->bSelected = true; } } for (int i = existcount; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; data->bSelected = NVector->bMergeMode; // MergeÀΰæ¿ì´Â ¼±ÅÃÀÌ µÈ»óÅ·Π»ý¼º if (data->bMotive && data->ChildList && data->ChildList->Count > 0) { for (int j = 0; j < data->ChildList->Count; j++) { childdata = (TVecData*)data->ChildList->Items[j]; childdata->bSelected = NVector->bMergeMode; } } } } // --------------------------------------------------------------------------- void __fastcall TVecDraw::InitCombiRead(TList *list, TPCanvasInfor &CanvasInfor, int number) { TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) long minx = MaxInt, miny = MaxInt, maxx = 0, maxy = 0; int maxthick = 0; // bool sw = true; if (NVector->bMergeMode) { DeleteVectorObject(false); NVector->bMergeMode = false; } for (int i = 0; i < list->Count; i++) { // ¿ì¼± Range ±¸ÇØÁÖ°í data = (TVecData*)list->Items[i]; if (0 <= number && !data->Equal(number)) continue; // SET_RECT; // Ȥ½Ã³ª ÇØ¼­.. // TextBox¿¡¼­´Â SET_RECT¸¦ ¾²¸é ¾ÈµÇ´Âµ¥ À߸ø »ç¿ëÇØ¼­ ÁÖ¼®À¸·Î ¸·°í º¯°æ // by maxleo21c (06.06.17) if ((data->Kind == V_TEXTBOX && data->ParentTextBox) || data->Kind != V_TEXTBOX) { SET_RECT; } minx = min(minx, data->First.x); minx = min(minx, data->Second.x); maxx = max(maxx, data->First.x); maxx = max(maxx, data->Second.x); miny = min(miny, data->First.y); miny = min(miny, data->Second.y); maxy = max(maxy, data->First.y); maxy = max(maxy, data->Second.y); maxthick = max(maxthick, data->PenThick); } CanvasInfor.Width = maxx - minx + maxthick * 2; CanvasInfor.Height = maxy - miny + maxthick * 2; } // --------------------------------------------------------------------------- int __fastcall TVecDraw::CheckStyle() { TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) int number; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (data->bSelected && data->HeaderNumber) { return data->HeaderNumber; } } return 0; } // --------------------------------------------------------------------------- /** »õ TextBox data Ãß°¡ * For Text Processing in Vector by maxleo21c (2004.10.15) * X, Y´Â ½Ã½ºÅÛ ÁÂÇ¥¸¦ ³ªÅ¸³½´Ù. ÇÏÁö¸¸ ¿ì¸®°¡ ¿øÇÏ´Â °ÍÀº * È®´ë/Ãà¼Ò ÇßÀ» ¶§ À̹ÌÁö À§ÀÇ ÁÂÇ¥ÀÌ´Ù. * X * ZoomOut / ZoomIn + PositionX : È®´ë/Ãà¼ÒµÈ À̹ÌÁö À§ÀÇ ½ÇÁ¦ ÁÂÇ¥ * (X - PositionX) * ZoomIn / ZoomOut : È®´ë/Ãà¼ÒµÈ À̹ÌÁö À§ÀÇ º¸¿©Áö´Â ÁÂÇ¥ */ void __fastcall TVecDraw::AddTextBox(int X, int Y) { BEGIN_LOG(""); HDC hdc; TLineTextBox * tempTLineTextBox; int Num; RECT rc; int widthsum = 0, height; TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) int RealX, RealY; int ZoomIn = MainImageForm->iMainImage->ZoomIn; int ZoomOut = MainImageForm->iMainImage->ZoomOut; int PositionX = MainImageForm->sbHorz->Position; int PositionY = MainImageForm->sbVert->Position; int tPosX, tPosY; Char tString[2] = L"a"; SIZE size; RealX = MainImageForm->iMainImage->BitmapToCanvasX(X); RealY = MainImageForm->iMainImage->BitmapToCanvasY(Y); // if (BeReadyEdit) DeleteCaret(); if ((Num = ExistAnyTextBox(X, Y)) < 0) { if (CurrentTextBoxData) { delete CurrentTextBoxData; CurrentTextBoxData = NULL; } if ((CurrentTextBoxData = new TVecData(MainImageForm->Number)) == NULL) goto fail; CurrentTextBoxData->Kind = V_TEXTBOX; CurrentTextBoxData->Color = PenManagerForm->PenShape->Pen->Color; CurrentTextBoxData->nCount = 0; CurrentTextBoxData->ListOfAllLine = new TWordList; tempTLineTextBox = new TLineTextBox; CurrentTextBoxData->StartPoint.x = X; CurrentTextBoxData->StartPoint.y = Y; // Antialiasing ¼³Á¤ Vector Upgrade 0316 if (VectorForm->cbTextAntialiasing->Checked) CurrentTextBoxData->bAntialiasing = true; else CurrentTextBoxData->bAntialiasing = false; // »õ·Î¿î TextBox°¡ ¸¸µé¾îÁö¸é °ü·Ã º¯¼ö°¡ ÃʱâÈ­ µÇ¾î¾ß ÇÑ´Ù. tString[1] = '\0'; hdc = MainImageForm->iMainImage->Canvas->Handle; GetTextExtentPoint32(hdc, tString, 1, &size); IndexOfLine = 0; xCaretPoz = RealX; yCaretPoz = RealY; // Caret º¸¿©Áö´Â À§Ä¡ CaretW = 0; CaretH = size.cy; // ±ÛÀÚÀÇ Å©±â // *line = CaretH; tempTLineTextBox->lineHeight = CaretH; IndexOfWord = 0; CurrentTextBoxData->First.x = X; CurrentTextBoxData->First.y = Y - CaretH; CurrentTextBoxData->Second.x = X + 1; CurrentTextBoxData->Second.y = Y - CaretH + 1; CurrentTextBoxData->CenterPoint.x = (CurrentTextBoxData->First.x + CurrentTextBoxData->Second.x)/2; CurrentTextBoxData->CenterPoint.y = (CurrentTextBoxData->First.y + CurrentTextBoxData->Second.y)/2; TextAngle = 0.0; CurrentTextBoxData->ListOfAllLine->Add(tempTLineTextBox); CurrentTextBoxData->pList = (DPOINT*)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT) * 5); CurrentTextBoxData->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, 1); CurrentTextBoxData->pList[0].x = CurrentTextBoxData->First.x; CurrentTextBoxData->pList[0].y = CurrentTextBoxData->First.y; CurrentTextBoxData->pList[1].x = CurrentTextBoxData->First.x; CurrentTextBoxData->pList[1].y = CurrentTextBoxData->Second.y; CurrentTextBoxData->pList[2].x = CurrentTextBoxData->Second.x; CurrentTextBoxData->pList[2].y = CurrentTextBoxData->Second.y; CurrentTextBoxData->pList[3].x = CurrentTextBoxData->Second.x; CurrentTextBoxData->pList[3].y = CurrentTextBoxData->First.y; CurrentTextBoxData->pList[4].x = CurrentTextBoxData->First.x; CurrentTextBoxData->pList[4].y = CurrentTextBoxData->First.y; // ======= Undo Test // DataList->Add(data); // UndoSave(VU_TEXTCREATE, DataList->Count - 1); // for new font // ======= Undo Test NVector->bFirst = true; bInSel = false; SelStart = 0; SelEnd = 0; LineStart = 0; LineEnd = 0; CurrentTextBox = DataList->Count; // DataList->Count´Â 1ºÎÅÍ ½ÃÀÛ } else { if (CurrentTextBox >= 0 && CurrentTextBox < DataList->Count) { TVecData *olddata = (TVecData*)DataList->Items[CurrentTextBox]; if (olddata && olddata->Kind == V_TEXTBOX){ //DeleteCaret(olddata); DeSelectedTextProc(olddata); } } data = (TVecData*)DataList->Items[Num]; CurrentTextBox = Num; SelStart = SearchPozForCaret(X, Y, data); SelEnd = SelStart; LineStart = IndexOfLine; LineEnd = IndexOfLine; bInSel = true; ExistSelected = true; fore = GetSysColor(COLOR_HIGHLIGHTTEXT); back = GetSysColor(COLOR_HIGHLIGHT); SelStartPoz.x = xCaretPoz; SelStartPoz.y = yCaretPoz; TextAngle = data->TextAngle; TSWordData *tsWordData; for (int k = 0; k < data->nCount; k++) { tsWordData = (TSWordData*)data->ListOfAllLine->Items(k); tsWordData->Selected = false; tsWordData->bNameChanged = false; // 2005 Vector Upgrade 0316 } BeReadyEdit = true; // todo: ij·ÔÀ¸·Î ó¸®Çϱâ À§Çؼ­ CenterPoint.x = data->CenterPoint.x; CenterPoint.y = data->CenterPoint.y; } MainImageForm->iMainImage->Repaint(); END_LOG; return; fail: if (data) delete data; data = NULL; END_LOG; } // --------------------------------------------------------------------------- /// TextBox¾È¿¡¼­ ¼±ÅÃÀ» À§ÇØ mouse move void __fastcall TVecDraw::TextBoxMouseMove(int X, int Y) { if (bInSel) { RECT rect; int SelFirst, SelSecond; int SelTemp, TempxCaretPoz = xCaretPoz,TempyCaretPoz = yCaretPoz,TempIndexOfLine = IndexOfLine; TSWordData *tsWordData; TList *DataList = NVector->DataList; if (DataList->Count <= 0 || CurrentTextBox < 0) return; TVecData *tData; tData = (TVecData*)DataList->Items[CurrentTextBox]; SelectedWordData=0; SelTemp = IndexOfWord; SelEnd = SearchPozForCaret(X, Y, tData);//Textboxº¹»çÇÒ¶§ ¿¡·¯¹ß»ýÇØ¼­ ¼öÁ¤. if(SelTemp != SelEnd && bShiftState == true) {//¸¶¿ì½º·Î µå·¡±×ÇÒ ¶§´Â AddTextBox ºÎºÐÀÌ ¾Ë¾Æ¼­ ÃʱâÈ­ÇØÁֹǷΠif(SelEnd != 0) SelEnd = SelTemp; IndexOfWord = SelTemp;//shift±â´ÉÇÒ ¶§¸¸ º¯¼ö ÃʱâÈ­¸¦ ÇØÁØ´Ù. } if(bShiftState == true){//ȸÀüµÈ °î¼±¿¡¼­ÀÇ Shift±â´É ¿À·ù ÇØ°á (By NDJ 2014.05.30) IndexOfWord = SelTemp; xCaretPoz = TempxCaretPoz, yCaretPoz = TempyCaretPoz; IndexOfLine = TempIndexOfLine; } if(SelEnd == 0 && tData->ListOfAllLine->CurveData && bShiftState == true){ IndexOfWord = SelTemp; SelEnd = SelTemp; }//By NDJ ÆÐ½º¹®ÀÚÀÏ ¶§ µå·¡±× ¿À·ù¸¦ À§ÇØ ¼öÁ¤ (ÆÐ½º¹®ÀÚÀÏ ¶§ SelEnd=0) if(SelEnd != IndexOfWord && SelEnd != 0) SelEnd = IndexOfWord; LineEnd = IndexOfLine; if (SelEnd < SelStart) { SelFirst = SelEnd; SelSecond = SelStart; } else if (SelEnd > SelStart) { SelFirst = SelStart; SelSecond = SelEnd; } else { SelFirst = -1; SelSecond = -1; } if (SelSecond >= 0 && SelSecond < tData->nCount) { tsWordData = (TSWordData*)tData->ListOfAllLine->Items(SelSecond); if (tsWordData->Word[0] == '\r') { SelSecond++; if (SelEnd < SelStart) SelStart = SelSecond; else SelEnd = SelSecond; } } if(SelFirst != SelSecond){ for (int k = 0; k < tData->nCount; k++) { tsWordData = (TSWordData*)tData->ListOfAllLine->Items(k); if (k >= SelFirst && k < SelSecond){ tsWordData->Selected = true; SelectedWordData++;} else tsWordData->Selected = false; } } GetTextBoxRect(tData); MakeTextBoxPointList(tData); GetRectForMouseMove(tData, rect); // 05.07.28 Ãß°¡ by malxoe21c // ÀÌÀ¯: LineÀ» µû¶ó Text¸¦ ÀÔ·ÂÇÒ¶§ FullViewUpdateÀÌ µÇÁö ¾Ê´Â ¹®Á¦ // top, left°¡ À½¼ö°¡ ³ª¿Í¼­ rectpaintÇÒ¶§ FullViewUpdate°¡ µÇÁö ¾Ê¾Ò´Ù. rect.top = rect.top < 0 ? 0 : rect.top; rect.left = rect.left < 0 ? 0 : rect.left; rect.right = rect.right < 0 ? 0 : rect.right; rect.bottom = rect.bottom < 0 ? 0 : rect.bottom; MainImageForm->iMainImage->RectPaint(rect); // MainImageForm->iMainImage->Repaint(); ExistSelected = true; } } // --------------------------------------------------------------------------- /// TextBox¸¦ ¾²±â À§ÇÑ ¸¶¿ì½º DownÈÄÀÇ Up void __fastcall TVecDraw::TextBoxMouseUp(int X, int Y) { if (SelStart == SelEnd) { fore = RGB(0, 0, 0); back = GetSysColor(COLOR_WINDOW); BeReadyEdit = true; BeModified = false; // for new font ExistSelected = false; bInSel = false; return; } BeReadyEdit = true; BeModified = false; // for new font bInSel = false; } // --------------------------------------------------------------------------- /// TextBox°¡ ÀÖ´ÂÁö üũ (CaretÀÇ Ç¥½ÃÀ¯¹« µîÀ» À§ÇØ) int __fastcall TVecDraw::ExistAnyTextBox(int X, int Y) { TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) int FirstX, FirstY, SecondX, SecondY; int AX, AY, BX, BY, DX, DY; double Inside1, Inside2, dis1, dis2, dis3; int mouseCursor = 0; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (data->Kind != V_TEXTBOX) continue; if (CursorInTextBox(X, Y, data)) return i; continue; } return -1; } // --------------------------------------------------------------------------- /// Cursor°¡ TextBox¾È¿¡ ÀÖ´ÂÁö üũ. bool __fastcall TVecDraw::CursorInTextBox(int X, int Y, TVecData *data) { int FirstX, FirstY, SecondX, SecondY; int AX, AY, BX, BY, DX, DY; double Inside1, Inside2, dis1, dis2, dis3; if (data->ListOfAllLine->CurveData) { // -->by linuxjun for CurvedVectorText TVecData *Data; Data = data->ListOfAllLine->CurveData; int Margin; try { Margin = data->ListOfAllLine->GetLineTextBox(0)->lineHeight * 3; } catch(...) { Margin = 0; } FirstX = Data->First.x - Margin; FirstY = Data->First.y - Margin; SecondX = Data->Second.x + Margin; SecondY = Data->Second.y + Margin; if (X < FirstX || X > SecondX || Y < FirstY || Y > SecondY) return false; TSWordData *tsWordData; double dist; for (int k = 0; k < data->nCount; k++) { tsWordData = (TSWordData*)data->ListOfAllLine->Items(k); if (tsWordData->bVisible) { dist = (tsWordData->px - X) * (tsWordData->px - X) + (tsWordData->py - Y) * (tsWordData->py - Y); if (dist <= tsWordData->LFont.lfHeight * tsWordData->HeightGap * tsWordData->LFont.lfHeight * tsWordData->HeightGap) { return true; } } } // <--by linuxjun for CurvedVectorText } else if (data->TextAngle) { AX = data->pList[0].x; AY = data->pList[0].y; BX = data->pList[1].x; BY = data->pList[1].y; DX = data->pList[3].x; DY = data->pList[3].y; dis1 = (BX - AX) * (BX - AX) + (BY - AY) * (BY - AY); dis2 = (DX - AX) * (DX - AX) + (DY - AY) * (DY - AY); if (dis1 == 0 || dis2 == 0) return false; Inside1 = ((BX - AX) * (X - AX) + (BY - AY) * (Y - AY)) / dis1; Inside2 = ((DX - AX) * (X - AX) + (DY - AY) * (Y - AY)) / dis2; if (Inside1 > 0 && Inside2 > 0) if (Inside1 < 1 && Inside2 < 1) return true; } else { FirstX = data->First.x; FirstY = data->First.y; SecondX = data->Second.x; SecondY = data->Second.y; if (X < FirstX || X > SecondX || Y < FirstY || Y > SecondY) return false; return true; } return false; } // --------------------------------------------------------------------------- /// È®´ëÃà¼ÒÁßÀÎ TextBox¸¦ ±×¸°´Ù. void __fastcall TVecDraw::DrawProportionTextBox(HDC dcDst, TVecData *data, int CenterX, int CenterY, int px, int py) { ///* °íÄ¥°Í int fontSize; TSWordData *tsWordData; HFONT font = NULL, oldfont = NULL; int ZoomIn = MainImageForm->iMainImage->ZoomIn; int ZoomOut = MainImageForm->iMainImage->ZoomOut; int tLine = 0, *line, tempHeight; RECT rt; HBRUSH Brush; int tempX = 0, tempY, tempPlus, StartX, StartY; double realCharX, realCharY; double angleChangedX, angleChangedY; double angle; int cx, cy; double zoom = 1; // -------------> 2005 Vector Upgrade Shin 0315 // Char fname[100], wordBstr[100]; String fname, wordBstr; String tempString, wordString; int PositionX = MainImageForm->sbHorz->Position; int PositionY = MainImageForm->sbVert->Position; double rx = VectorForm->eXSize->Value; double ry = VectorForm->eYSize->Value; double ratiox = rx / 100.0, ratioy = ry / 100.0; // --------------< zoom = min(fabs(ratiox), fabs(ratioy)); angle = data->TextAngle; // angle = angle / 180 * M_PI; line = (int*)data->ProportionLineList->Items[0]; data->ProportionStart.x = data->ProportionFirst.x; data->ProportionStart.y = data->ProportionFirst.y + *line; StartX = data->ProportionStart.x; StartY = data->ProportionStart.y; realCharX = StartX; realCharY = StartY; cx = (PropPoints[0].x + PropPoints[2].x) / 2; cy = (PropPoints[0].y + PropPoints[2].y) / 2; tempY = ((*line) * 0.8) * ZoomIn / ZoomOut; gdp::Graphics graphics(dcDst); // using GDI+ 2005 Vector Upgrade Shin 0315 graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); // antialiasing gdp::StringFormat fontFormat; fontFormat.SetFormatFlags(gdp::StringFormatFlagsNoClip); for (int k = 0; k < data->ProportionWordDataList->Count; k++) { tsWordData = (TSWordData*)data->ProportionWordDataList->Items[k]; fontSize = tsWordData->LFont.lfHeight; tsWordData->LFont.lfHeight = tsWordData->LFont.lfHeight * ZoomIn / ZoomOut; if (tsWordData->LFont.lfHeight == 0) tsWordData->LFont.lfHeight = 1; // SetTextAlign(dcDst, TA_BOTTOM); // SetTextColor(dcDst, 0xD35F54); // 0xD35F54 : ÆÄ¶õ»ö // SetBkMode(dcDst, TRANSPARENT); // // font = CreateFontIndirect(&tsWordData->LFont); // oldfont = (HFONT)SelectObject(dcDst, font); tempString = tsWordData->LFont.lfFaceName; // ZeroMemory(fname, sizeof(fname)); // MultiByteToWideChar(CP_ACP, 0, tempString.c_str(), tempString.Length(), fname, sizeof(fname) / sizeof(fname[0])); fname = tempString; wordBstr = tsWordData->Word; gdp::FontFamily fontFamily(fname.c_str()); gdp::Font font(dcDst, &tsWordData->LFont); gdp::Color wordColor(gdp::Color(128, 0x54, 0x5F, 0xD3)); gdp::SolidBrush wordBrush(wordColor); if (tsWordData->Word[0] == '\r') { tLine++; line = (int*)data->ProportionLineList->Items[tLine]; realCharX = StartX; tempY = ((*line) * 0.8 * tsWordData->HeightGap) * ZoomIn / ZoomOut; if (tempY == 0) tempY = 1; realCharY += tempY; } else { tempX = realCharX; realCharX += tsWordData->Interval * tsWordData->WidthGap * ZoomIn / ZoomOut; /* ZeroMemory(wordBstr, sizeof(wordBstr)); if (tsWordData->UsedByte == 1){ MultiByteToWideChar(CP_ACP, 0, tsWordData->Word, 1, wordBstr, sizeof(wordBstr) / sizeof(wordBstr[0])); } else { MultiByteToWideChar(CP_ACP, 0, tsWordData->Word, 2, wordBstr, sizeof(wordBstr) / sizeof(wordBstr[0])); } */ int celldescent = fontFamily.GetCellDescent(gdp::FontStyleRegular); float descent = font.GetSize() * celldescent / fontFamily.GetEmHeight (gdp::FontStyleRegular); int cellascent = fontFamily.GetCellAscent(gdp::FontStyleRegular); // float ascent = font.GetSize()*cellascent/fontFamily.GetEmHeight(gdp::FontStyleRegular); ////////////////////////////////////// º¤ÅÍ ÆùÆ® ¿¡·¯ ¼öÁ¤ (2007. 06. 25 Annualring) float emHeight = fontFamily.GetEmHeight(gdp::FontStyleRegular); float ascent; if (emHeight) { ascent = font.GetSize() * cellascent / fontFamily.GetEmHeight (gdp::FontStyleRegular); } else { font.GetFamily(&fontFamily); cellascent = fontFamily.GetCellAscent(gdp::FontStyleRegular); emHeight = fontFamily.GetEmHeight(gdp::FontStyleRegular); if (emHeight) ascent = font.GetSize() * cellascent / emHeight; else ascent = font.GetHeight(&graphics); } ////////////////////////////////////// º¤ÅÍ ÆùÆ® ¿¡·¯ ¼öÁ¤ (2007. 06. 25 Annualring) // baseInterval : realCharY(¶óÀÎÀÇ ½ÃÀÛÁ¡ yÁÂÇ¥)¿¡¼­ ±âÁؼ±(ascentÀÇ ÇÏÇѼ±)±îÁöÀÇ °£°Ý float baseInterval = ((*line) * 0.15 * tsWordData->HeightGap) * ZoomIn / ZoomOut; float fontsize = font.GetSize(); float leftInterval = fontsize * 0.15; gdp::PointF origin((float)tempX - leftInterval, (float)(realCharY - ascent - baseInterval)); if (tsWordData->LFont.lfEscapement) { gdp::Matrix matrix; matrix.RotateAt(360 - angle, gdp::PointF(cx, cy), gdp::MatrixOrderAppend); graphics.SetTransform(&matrix); graphics.DrawString(wordBstr.c_str(), _tcslen(wordBstr.c_str()), &font, origin, &fontFormat, &wordBrush); // graphics.DrawString(wordBstr, _tcslen(wordBstr), &font, origin, &fontFormat, &wordBrush); graphics.ResetTransform(); } else { graphics.DrawString(wordBstr.c_str(), _tcslen(wordBstr.c_str()), &font, origin, &fontFormat, &wordBrush); // graphics.DrawString(wordBstr, _tcslen(wordBstr), &font, origin, &fontFormat, &wordBrush); } } tsWordData->LFont.lfHeight = fontSize; } // */ } // --------------------------------------------------------------------------- /// ¼±ÅõǾîÁ®¼­ »öÀÌ ¹ÝÀüµÈ TextBox¸¦ ±×¸°´Ù. void __fastcall TVecDraw::DrawMaskTextBox(HDC dcDst, TVecData *tData, int StartX, int StartY, double CenterX, double CenterY, double FontZoom, int OffsetX, int OffsetY) { /* °íÄ¥°Í int fontSize; TSWordData *tsWordData; HFONT font = NULL, oldfont = NULL; int tLine = 0, line; HBRUSH Brush; int tSecondX, tSecondY; double realCharX, realCharY, tempX = 0.0, tempY; double angleChangedX, angleChangedY; //double angle = tData->TextAngle / 180 * M_PI; int cx, cy; //----------> 2005 Vector Upgrade Shin 0315 double angle = tData->TextAngle; //Char fname[100], wordBstr[100]; String fname, wordBstr; String tempString, wordString; gdp::Graphics graphics(dcDst); // using GDI+ graphics.SetPageUnit(gdp::UnitPixel); //graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); // antialiasing if (tData->bAntialiasing) graphics.SetTextRenderingHint(gdp::TextRenderingHintAntiAlias); gdp::PointF *pPoints; //---------------------< realCharX = StartX; realCharY = StartY; cx = CenterX; cy = CenterY; line = (tData->ListOfAllLine->GetLineTextBox(0))->lineHeight; tempY = ((line) * 0.8) * FontZoom; for (int k = 0; k < tData->nCount; k++) { tsWordData = (TSWordData *)tData->ListOfAllLine->Items(k); fontSize = tsWordData->LFont.lfHeight; tsWordData->LFont.lfHeight = fontSize * FontZoom; if (tsWordData->LFont.lfHeight == 0) tsWordData->LFont.lfHeight = 1; //----------> 2005 Vector Upgrade Shin 0315 using GDI+ if (!tsWordData->bNameChanged) tempString = tsWordData->LFont.lfFaceName; else tempString = DefaultFontName; //ZeroMemory(fname, sizeof(fname)); //MultiByteToWideChar(CP_ACP, 0, tempString.c_str(), tempString.Length(), fname, sizeof(fname) / sizeof(fname[0])); fname = tempString; wordBstr = tsWordData->Word; gdp::FontFamily fontFamily(fname.c_str()); gdp::Font font(dcDst, &tsWordData->LFont); gdp::Color wordColor(GetRValue(clBlack), GetGValue(clBlack), GetBValue(clBlack)); gdp::SolidBrush wordBrush(wordColor); gdp::StringFormat fontFormat; //fontFormat.SetAlignment(gdp::StringAlignmentNear); fontFormat.SetFormatFlags(gdp::StringFormatFlagsNoClip); if (tsWordData->Word[0] == '\r') { tLine++; line = (tData->ListOfAllLine->GetLineTextBox(tLine))->lineHeight; realCharX = StartX; tempY = ((line) * 0.8 * tsWordData->HeightGap) * FontZoom; realCharY += tempY; } else { tempX = realCharX; realCharX += tsWordData->Interval * tsWordData->WidthGap * FontZoom; float cellascent, emHeight, ascent; cellascent = fontFamily.GetCellAscent(gdp::FontStyleRegular); emHeight = fontFamily.GetEmHeight(gdp::FontStyleRegular); if (emHeight) ascent = font.GetSize()*cellascent/emHeight; else { font.GetFamily(&fontFamily); cellascent = fontFamily.GetCellAscent(gdp::FontStyleRegular); emHeight = fontFamily.GetEmHeight(gdp::FontStyleRegular); if (emHeight) ascent = font.GetSize()*cellascent/emHeight; else ascent = font.GetHeight(&graphics); } // baseInterval : realCharY(¶óÀÎÀÇ ½ÃÀÛÁ¡ yÁÂÇ¥)¿¡¼­ ±âÁؼ±(ascentÀÇ ÇÏÇѼ±)±îÁöÀÇ °£°Ý float baseInterval = (line * 0.142 * tsWordData->HeightGap) * FontZoom; //float leftInterval = tsWordData->Interval * tsWordData->WidthGap * FontZoom * 0.1; float fontsize = font.GetSize(); float leftInterval = fontsize*0.17; if(tData->ListOfAllLine->CurveData){ //-->by linuxjun for CurvedVectorText double dTemp; int PositionX; int PositionY; int px; int py; double OriginX,OriginY; double tempCenterX, tempCenterY; px = (tData->StartPoint.x - OffsetX)*FontZoom - StartX; py = (tData->StartPoint.y - OffsetY)*FontZoom - StartY; PositionX = OffsetX; PositionY = OffsetY; OriginX = (tsWordData->px - OffsetX)*FontZoom - tsWordData->Interval * tsWordData->WidthGap * FontZoom / 2 - px; OriginY = (tsWordData->py - OffsetY)*FontZoom - ascent - py; tempCenterX = (tsWordData->px - OffsetX)*FontZoom - px; tempCenterY = (tsWordData->py - OffsetY)*FontZoom - py; angle = acos(tsWordData->tx); if(tsWordData->ty >= 0){ angle = 180*angle/M_PI; }else{ angle = 360 - 180*angle/M_PI; } gdp::PointF origin((float)OriginX, (float)OriginY); gdp::Matrix matrix; matrix.RotateAt(angle, gdp::PointF(tempCenterX, tempCenterY), gdp::MatrixOrderAppend); graphics.SetTransform(&matrix); graphics.DrawString(wordBstr.c_str(), _tcslen(wordBstr.c_str()), &font, origin, &fontFormat, &wordBrush); graphics.ResetTransform(); //<--by linuxjun for CurvedVectorText } else{ gdp::PointF origin((float)tempX - leftInterval, (float)(realCharY - ascent - baseInterval)); if (tsWordData->LFont.lfEscapement) { gdp::Matrix matrix; matrix.RotateAt(360 - angle, gdp::PointF(CenterX, CenterY), gdp::MatrixOrderAppend); graphics.SetTransform(&matrix); graphics.DrawString(wordBstr.c_str(), _tcslen(wordBstr.c_str()), &font, origin, &fontFormat, &wordBrush); graphics.ResetTransform(); } else { graphics.DrawString(wordBstr.c_str(), _tcslen(wordBstr.c_str()), &font, origin, &fontFormat, &wordBrush); } } } tsWordData->LFont.lfHeight = fontSize; //----------------------------------< } */ } // --------------------------------------------------------------------------- /// TextBox(Text data - V_TEXTBOX)¸¦ ±×¸°´Ù. ±ô¹ÚÀÓÀ» ÁÙÀ̱â À§Çؼ­ Edit»óÅÂ¿Í ±×·¸Áö ¾ÊÀ» ¶§¸¦ ±¸ºÐÇß´Ù. void __fastcall TVecDraw::DrawTextBox(HDC dcDst, TVecData *tData, int StartX, int StartY, double CenterX, double CenterY, double FontZoom, int OffsetX, int OffsetY) { int fontSize; TSWordData *tsWordData; HFONT font = NULL, oldfont = NULL; int tLine = 0, line; HBRUSH Brush; int tSecondX, tSecondY; double realCharX, realCharY, tempX = 0.0, tempY; double angleChangedX, angleChangedY; // double angle = tData->TextAngle / 180 * M_PI; int cx, cy; // -----------------> 2005 Vector Upgrade Shin 0315 double angle = tData->TextAngle; // Char fname[100], wordBstr[100]; String fname, wordBstr; String tempString, wordString; gdp::Graphics graphics(dcDst); // using GDI+ graphics.SetPageUnit(gdp::UnitPixel); if (!(NVector->bCancelAntialiasing) && tData->bAntialiasing) { graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); // antialiasing graphics.SetTextRenderingHint(gdp::TextRenderingHintAntiAlias); } else { graphics.SetSmoothingMode(gdp::SmoothingModeNone); // 2017.04.11 @jhs - ¾ÈƼ¾Ë¸®¾î½ÌÀÌ Ã¼Å©µÇÁö ¾Ê¾Ò´Âµ¥ ŸÀÌÇÎ ÈÄ ÆùÆ®°¡ º¯°æµÇ´Â°Í ó·³ º¸ÀÓ (¾÷ü¿äû - È£Àü½Ç¾÷) //graphics.SetTextRenderingHint(gdp::TextRenderingHintSingleBitPerPixel); graphics.SetTextRenderingHint(gdp::TextRenderingHintSystemDefault); /* typedef enum { TextRenderingHintSystemDefault = 0, TextRenderingHintSingleBitPerPixelGridFit = 1, TextRenderingHintSingleBitPerPixel = 2, TextRenderingHintAntiAliasGridFit = 3, TextRenderingHintAntiAlias = 4, TextRenderingHintClearTypeGridFit = 5 } TextRenderingHint; °ªÀÌ ÀÛÀ»¼ö·Ï ǰÁúÀº ¶³¾îÁöÁö¸¸ Ãâ·Â ¼Óµµ´Â ºü¸£¸ç °ªÀÌ ³ô¾ÆÁú¼ö·Ï ǰÁúÀº ÁÁ¾ÆÁöÁö¸¸ ¼Óµµ´Â ´À¸² */ } // text antialiasing 20050211 // ---------------------------------------< realCharX = StartX; realCharY = StartY; cx = CenterX; cy = CenterY; line = (tData->ListOfAllLine->GetLineTextBox(0))->lineHeight; tempY = ((line) * 0.8) * FontZoom; MakeTextBoxPointList(tData); for (int k = 0; k < tData->nCount; k++) { tsWordData = (TSWordData*)tData->ListOfAllLine->Items(k); fontSize = tsWordData->LFont.lfHeight; tsWordData->LFont.lfHeight = fontSize * FontZoom; if (tsWordData->LFont.lfHeight == 0) tsWordData->LFont.lfHeight = 1; // ----------> 2005 Vector Upgrade Shin 0315 using GDI+ if (!tsWordData->bNameChanged) tempString = tsWordData->LFont.lfFaceName; else tempString = DefaultFontName; // ZeroMemory(fname, sizeof(fname)); // MultiByteToWideChar(CP_ACP, 0, tempString.c_str(), tempString.Length(), fname, sizeof(fname) / sizeof(fname[0])); fname = tempString; wordBstr = tsWordData->Word; gdp::FontFamily fontFamily(fname.c_str()); if (fontFamily.IsAvailable()) { // gdp::FontFamily fontFamily(fname); gdp::Font font(dcDst, &tsWordData->LFont); gdp::Color wordColor(GetRValue(tsWordData->Color), GetGValue(tsWordData->Color), GetBValue(tsWordData->Color)); gdp::SolidBrush wordBrush(wordColor); gdp::StringFormat fontFormat; fontFormat.SetFormatFlags(gdp::StringFormatFlagsNoClip); if (tsWordData->Word[0] == '\r') { tLine++; line = (tData->ListOfAllLine->GetLineTextBox(tLine))->lineHeight; realCharX = StartX; tempY = ((line) * 0.8 * tsWordData->HeightGap) * FontZoom; realCharY += tempY; } else { tempX = realCharX; realCharX += tsWordData->Interval * tsWordData->WidthGap * FontZoom; /* ZeroMemory(wordBstr, sizeof(wordBstr)); if (tsWordData->UsedByte == 1){ MultiByteToWideChar(CP_ACP, 0, tsWordData->Word, 1, wordBstr, sizeof(wordBstr) / sizeof(wordBstr[0])); } else { MultiByteToWideChar(CP_ACP, 0, tsWordData->Word, 2, wordBstr, sizeof(wordBstr) / sizeof(wordBstr[0])); } */ float cellascent, emHeight, ascent; cellascent = fontFamily.GetCellAscent(gdp::FontStyleRegular); emHeight = fontFamily.GetEmHeight(gdp::FontStyleRegular); if (emHeight) { int size = font.GetSize(); if (size > 0) ascent = font.GetSize() * cellascent / emHeight; else ascent = font.GetHeight(&graphics); } else { font.GetFamily(&fontFamily); cellascent = fontFamily.GetCellAscent(gdp::FontStyleRegular); emHeight = fontFamily.GetEmHeight(gdp::FontStyleRegular); if (emHeight) { ascent = font.GetSize() * cellascent / emHeight; } else ascent = font.GetHeight(&graphics); } // baseInterval : realCharY(¶óÀÎÀÇ ½ÃÀÛÁ¡ yÁÂÇ¥)¿¡¼­ ±âÁؼ±(ascentÀÇ ÇÏÇѼ±)±îÁöÀÇ °£°Ý float baseInterval = (line * 0.142 * tsWordData->HeightGap) * FontZoom; float fontsize = font.GetSize(); float leftInterval = fontsize * 0.17; if (tData->ListOfAllLine->CurveData) { // -->by linuxjun for CurvedVectorText double dTemp; int PositionX; int PositionY; int px; int py; double OriginX, OriginY; double tempCenterX, tempCenterY; if (tsWordData->bVisible) { px = (tData->StartPoint.x - OffsetX) * FontZoom - StartX; py = (tData->StartPoint.y - OffsetY) * FontZoom - StartY; PositionX = OffsetX; PositionY = OffsetY; OriginX = ((tsWordData->px - OffsetX) * FontZoom - tsWordData->Interval * tsWordData->WidthGap * FontZoom / 2 - px); OriginY = ((tsWordData->py - OffsetY) * FontZoom) - ascent - py; tempCenterX = (tsWordData->px - OffsetX) * FontZoom - px; tempCenterY = (tsWordData->py - OffsetY) * FontZoom - py; if((tsWordData->tx < -1) || (tsWordData->tx > 1)){ angle=0; return; } else angle = acos(tsWordData->tx); if (tsWordData->ty >= 0) { angle = 180 * angle / M_PI; } else { angle = 360 - 180 * angle / M_PI; } gdp::PointF origin((float)OriginX - leftInterval, (float)OriginY); gdp::Matrix matrix; matrix.RotateAt(angle, gdp::PointF(tempCenterX, tempCenterY), gdp::MatrixOrderAppend); graphics.SetTransform(&matrix); graphics.DrawString(wordBstr.c_str(), _tcslen(wordBstr.c_str()), &font, origin, &fontFormat, &wordBrush); graphics.ResetTransform(); } // <--by linuxjun for CurvedVectorText } else { gdp::PointF origin((float)(tempX - leftInterval), (float)(realCharY - ascent - baseInterval)); if (tsWordData->LFont.lfEscapement) { gdp::Matrix matrix; matrix.RotateAt(360 - angle, gdp::PointF(CenterX, CenterY), gdp::MatrixOrderAppend); graphics.SetTransform(&matrix); graphics.DrawString(wordBstr.c_str(), _tcslen(wordBstr.c_str()), &font, origin, &fontFormat, &wordBrush); graphics.ResetTransform(); } else { graphics.DrawString(wordBstr.c_str(), _tcslen(wordBstr.c_str()), &font, origin, &fontFormat, &wordBrush); } } } // ---------------------------< } else { SetTextAlign(dcDst, TA_BOTTOM); SetTextColor(dcDst, tsWordData->Color); SetBkMode(dcDst, TRANSPARENT); font = CreateFontIndirect(&tsWordData->LFont); oldfont = (HFONT)SelectObject(dcDst, font); angle = 2 * M_PI * tsWordData->LFont.lfEscapement / 10 / 360; if (tsWordData->UsedByte == 1) { if (tsWordData->Word[0] == '\r') { tLine++; line = (tData->ListOfAllLine->GetLineTextBox(tLine))->lineHeight; realCharX = StartX; tempY = ((line) * 0.8 * tsWordData->HeightGap) * FontZoom; realCharY += tempY; } else { tempX = realCharX; if (tsWordData->LFont.lfEscapement) { double tx = tempX - cx; double ty = cy - realCharY; angleChangedX = tx * cos(-angle) + ty * sin(-angle) + cx; angleChangedY = cy - (-tx * sin(-angle) + ty * cos(-angle)); TextOut(dcDst, angleChangedX, angleChangedY, tsWordData->Word, 1); realCharX += tsWordData->Interval * tsWordData->WidthGap * FontZoom; } else { realCharX += tsWordData->Interval * tsWordData->WidthGap * FontZoom; TextOut(dcDst, tempX, realCharY, tsWordData->Word, 1); } } } else { tempX = realCharX; if (tsWordData->LFont.lfEscapement) { double tx = tempX - cx; double ty = cy - realCharY; angleChangedX = tx * cos(-angle) + ty * sin(-angle) + cx; angleChangedY = cy - (-tx * sin(-angle) + ty * cos(-angle)); TextOut(dcDst, angleChangedX, angleChangedY, tsWordData->Word, 2); realCharX += tsWordData->Interval * tsWordData->WidthGap * FontZoom; } else { realCharX += tsWordData->Interval * tsWordData->WidthGap * FontZoom; TextOut(dcDst, tempX, realCharY, tsWordData->Word, 2); } } SelectObject(dcDst, oldfont); DeleteObject(font); } tsWordData->LFont.lfHeight = fontSize; } } // --------------------------------------------------------------------------- /// ÆíÁýÁßÀÎ TextBox¸¦ ±×·ÁÁØ´Ù. void __fastcall TVecDraw::DrawEditTextBox(HDC dcDst, TVecData *tData, int StartX, int StartY, double FontZoom, double CenterX, double CenterY, int OffsetX, int OffsetY) { int fontSize; TSWordData *tsWordData; HFONT font = NULL, oldfont = NULL; int tLine = 0, line, tempHeight; RECT rt; HBRUSH Brush; int tSecondX, tSecondY; double realCharX, realCharY, tempX = 0.0, tempY; double angleChangedX, angleChangedY; int cx, cy; RECT rect; // -------> 2005 Vector Upgrade Shin 0315 double angle = tData->TextAngle; // Char fname[100], wordBstr[100]; String fname, wordBstr; String tempString, wordString; gdp::Graphics graphics(dcDst); // using GDI+ if (VectorForm->cbTextAntialiasing->Checked) tData->bAntialiasing = true; // 20050211 shin else tData->bAntialiasing = false; // ---------------< realCharX = StartX; realCharY = StartY; cx = CenterX; cy = CenterY; line = (tData->ListOfAllLine->GetLineTextBox(0))->lineHeight; tempY = ((line) * 0.8) * FontZoom; EndLine = 0; MakeTextBoxPointList(tData); for (int k = 0; k < tData->nCount; k++) { tsWordData = (TSWordData*)tData->ListOfAllLine->Items(k); fontSize = tsWordData->LFont.lfHeight; tsWordData->LFont.lfHeight = fontSize * FontZoom; if (tsWordData->LFont.lfHeight == 0) tsWordData->LFont.lfHeight = 1; // ------------> 2005 Vector Upgrade Shin 0315 using GDI+ if (!tsWordData->bNameChanged) tempString = tsWordData->LFont.lfFaceName; else tempString = DefaultFontName; fname = tempString; wordBstr = tsWordData->Word; // tempString = tsWordData->LFont.lfFaceName; // ZeroMemory(fname, sizeof(fname)); // MultiByteToWideChar(CP_ACP, 0, tempString.c_str(), tempString.Length(), fname, sizeof(fname) / sizeof(fname[0])); gdp::FontFamily fontFamily(fname.c_str()); if (fontFamily.IsAvailable()) { gdp::Font font(dcDst, &tsWordData->LFont); gdp::Color wordColor(GetRValue(tsWordData->Color), GetGValue(tsWordData->Color), GetBValue(tsWordData->Color)); gdp::SolidBrush wordBrush(wordColor); gdp::SolidBrush whiteBrush(gdp::Color(0xFF, 0xFF, 0xFF)); gdp::SolidBrush blackBrush(gdp::Color(0x00, 0x00, 0x00)); gdp::StringFormat stringFormat; // stringFormat.SetAlignment(gdp::StringAlignmentNear); // stringFormat.SetLineAlignment(gdp::StringAlignmentFar); gdp::StringFormat fontFormat; fontFormat.SetFormatFlags(gdp::StringFormatFlagsNoClip); if (tsWordData->Word[0] == '\r') { tLine++; line = (tData->ListOfAllLine->GetLineTextBox(tLine))->lineHeight; realCharX = StartX; tempY = ((line) * 0.8 * tsWordData->HeightGap) * FontZoom; realCharY += tempY; EndLine++; } else { tempX = realCharX; realCharX += tsWordData->Interval * tsWordData->WidthGap * FontZoom; /* ZeroMemory(wordBstr, sizeof(wordBstr)); if (tsWordData->UsedByte == 1){ MultiByteToWideChar(CP_ACP, 0, tsWordData->Word, 1, wordBstr, sizeof(wordBstr) / sizeof(wordBstr[0])); } else { MultiByteToWideChar(CP_ACP, 0, tsWordData->Word, 2, wordBstr, sizeof(wordBstr) / sizeof(wordBstr[0])); } */ float cellascent, emHeight, ascent; cellascent = fontFamily.GetCellAscent(gdp::FontStyleRegular); emHeight = fontFamily.GetEmHeight(gdp::FontStyleRegular); if (emHeight) ascent = font.GetSize() * cellascent / emHeight; else { font.GetFamily(&fontFamily); cellascent = fontFamily.GetCellAscent(gdp::FontStyleRegular); emHeight = fontFamily.GetEmHeight(gdp::FontStyleRegular); if (emHeight) ascent = font.GetSize() * cellascent / emHeight; else ascent = font.GetHeight(&graphics); } // baseInterval : realCharY(¶óÀÎÀÇ ½ÃÀÛÁ¡ yÁÂÇ¥)¿¡¼­ ±âÁؼ±(ascentÀÇ ÇÏÇѼ±)±îÁöÀÇ °£°Ý float baseInterval = (line * 0.142 * tsWordData->HeightGap) * FontZoom; float fontsize = font.GetSize(); float leftInterval = fontsize * 0.17; if (tData->ListOfAllLine->CurveData) { // -->by linuxjun for CurvedVectorText double dTemp; int PositionX; int PositionY; int px; int py; double OriginX, OriginY; double tempCenterX, tempCenterY; if (tsWordData->bVisible) { px = (tData->StartPoint.x - OffsetX) * FontZoom - StartX; py = (tData->StartPoint.y - OffsetY) * FontZoom - StartY; PositionX = OffsetX; PositionY = OffsetY; OriginX = ((tsWordData->px - OffsetX) * FontZoom - tsWordData->Interval * tsWordData->WidthGap * FontZoom / 2 - px); OriginY = ((tsWordData->py - OffsetY) * FontZoom - ascent - py); tempCenterX = (tsWordData->px - OffsetX) * FontZoom - px; tempCenterY = (tsWordData->py - OffsetY) * FontZoom - py; if((tsWordData->tx < -1) || (tsWordData->tx > 1)){ angle=0; return; } else angle = acos(tsWordData->tx); if (tsWordData->ty >= 0) { angle = 180 * angle / M_PI; } else { angle = 360 - 180 * angle / M_PI; } gdp::PointF origin((float)OriginX - leftInterval, (float)OriginY); gdp::RectF selRect((float)OriginX, (float)OriginY, tsWordData->Interval * tsWordData->WidthGap * FontZoom, ascent); // if (tsWordData->LFont.lfEscapement) gdp::Matrix matrix; // matrix.RotateAt(360 - angle, gdp::PointF(tempCenterX, tempCenterY), gdp::MatrixOrderAppend); matrix.RotateAt(angle, gdp::PointF(tempCenterX, tempCenterY), gdp::MatrixOrderAppend); graphics.SetTransform(&matrix); // graphics.DrawString(wordBstr, _tcslen(wordBstr), &font, origin, &fontFormat, &wordBrush); if (tsWordData->Selected) { graphics.FillRectangle(&blackBrush, selRect); graphics.DrawString(wordBstr.c_str(), _tcslen(wordBstr.c_str()), &font, origin, &fontFormat, &whiteBrush); } else { graphics.DrawString(wordBstr.c_str(), _tcslen(wordBstr.c_str()), &font, origin, &fontFormat, &wordBrush); } graphics.ResetTransform(); } // <--by linuxjun for CurvedVectorText } else { gdp::PointF origin((float)tempX - leftInterval, (float)(realCharY - ascent - baseInterval)); gdp::RectF selRect(tempX, realCharY - tempY, realCharX - tempX, tempY); if (tsWordData->LFont.lfEscapement) { gdp::Matrix matrix; matrix.RotateAt(360 - angle, gdp::PointF(CenterX, CenterY), gdp::MatrixOrderAppend); graphics.SetTransform(&matrix); if (tsWordData->Selected) { graphics.FillRectangle(&blackBrush, selRect); graphics.DrawString(wordBstr.c_str(), _tcslen(wordBstr.c_str()), &font, origin, &fontFormat, &whiteBrush); } else { graphics.DrawString(wordBstr.c_str(), _tcslen(wordBstr.c_str()), &font, origin, &fontFormat, &wordBrush); } graphics.ResetTransform(); } else { if (tsWordData->Selected) { graphics.FillRectangle(&blackBrush, selRect); graphics.DrawString(wordBstr.c_str(), _tcslen(wordBstr.c_str()), &font, origin, &fontFormat, &whiteBrush); } else { graphics.DrawString(wordBstr.c_str(), _tcslen(wordBstr.c_str()), &font, origin, &fontFormat, &wordBrush); } } } } } else { // -------------------------------------------< SetTextAlign(dcDst, TA_BOTTOM); if (tsWordData->Selected) { SetTextColor(dcDst, fore); SetBkMode(dcDst, TRANSPARENT); } else { SetTextColor(dcDst, tsWordData->Color); SetBkMode(dcDst, TRANSPARENT); } font = CreateFontIndirect(&tsWordData->LFont); oldfont = (HFONT)SelectObject(dcDst, font); angle = 2 * M_PI * tsWordData->LFont.lfEscapement / 10 / 360; if (tsWordData->UsedByte == 1) { if (tsWordData->Word[0] == '\r') { tLine++; line = (tData->ListOfAllLine->GetLineTextBox(tLine))->lineHeight; realCharX = StartX; tempY = ((line) * 0.8 * tsWordData->HeightGap) * FontZoom; realCharY += tempY; EndLine++; } else { tempX = realCharX; if (tsWordData->LFont.lfEscapement) { double tx = tempX - cx; double ty = cy - realCharY; if (tsWordData->Selected) { SetTextColor(dcDst, fore); SetBkColor(dcDst, back); SetBkMode(dcDst, OPAQUE); } angleChangedX = tx * cos(-angle) + ty * sin(-angle) + cx; angleChangedY = cy - (-tx * sin(-angle) + ty * cos(-angle)); TextOut(dcDst, angleChangedX, angleChangedY, tsWordData->Word, 1); realCharX += tsWordData->Interval * tsWordData->WidthGap * FontZoom; } else { realCharX += tsWordData->Interval * tsWordData->WidthGap * FontZoom; if (tsWordData->Selected) { ::SetRect(&rt, tempX, realCharY - tempY, realCharX, realCharY); Brush = CreateSolidBrush(back); FillRect(dcDst, &rt, Brush); DeleteObject(Brush); } TextOut(dcDst, tempX, realCharY, tsWordData->Word, 1); } } } else { tempX = realCharX; if (tsWordData->LFont.lfEscapement) { double tx = tempX - cx; double ty = cy - realCharY; if (tsWordData->Selected) { SetTextColor(dcDst, fore); SetBkColor(dcDst, back); SetBkMode(dcDst, OPAQUE); } angleChangedX = tx * cos(-angle) + ty * sin(-angle) + cx; angleChangedY = cy - (-tx * sin(-angle) + ty * cos(-angle)); TextOut(dcDst, angleChangedX, angleChangedY, tsWordData->Word, 2); realCharX += tsWordData->Interval * tsWordData->WidthGap * FontZoom; } else { realCharX += tsWordData->Interval * tsWordData->WidthGap * FontZoom; if (tsWordData->Selected) { ::SetRect(&rt, tempX, realCharY - tempY, realCharX, realCharY); Brush = CreateSolidBrush(back); FillRect(dcDst, &rt, Brush); DeleteObject(Brush); } TextOut(dcDst, tempX, realCharY, tsWordData->Word, 2); } } SelectObject(dcDst, oldfont); DeleteObject(font); } tsWordData->LFont.lfHeight = fontSize; } GetTextBoxRect(tData); } // --------------------------------------------------------------------------- /// Text data(V_TEXTBOX)¸¦ ¾²´Â µµÁßÀÇ KeyDown¿¡ ´ëÇÑ Ã³¸® void __fastcall TVecDraw::KeyDownInTextBox(int Key) { if (!VecDraw->BeReadyEdit) return; TList *DataList = NVector->DataList; TSWordData *tsWordData, *tempWordData; // by maxleo21c (2004.08.07) TVecData *tData; TWordList *WordDataList; String temp; SIZE size; int FirstX, FirstY; int ZoomIn = MainImageForm->iMainImage->ZoomIn; int ZoomOut = MainImageForm->iMainImage->ZoomOut; int PositionX = MainImageForm->sbHorz->Position; int PositionY = MainImageForm->sbVert->Position; int tline = 0, i, rectBottom; int CountOfData=0;//IndexOfWord RECT rect; CountOfData = IndexOfWord; if (DataList->Count < 1 && CurrentTextBoxData == NULL) return; if (CurrentTextBox < 0) return; BEGIN_LOG(""); if (CurrentTextBox < DataList->Count){ tData = (TVecData*)DataList->Items[CurrentTextBox]; } else { tData = new TVecData(MainImageForm->Number); if (CurrentTextBoxData){ tData->Copy(CurrentTextBoxData); DataList->Add(tData); UndoSave(VU_TEXTCREATE, DataList->Count - 1); // for new font delete CurrentTextBoxData; CurrentTextBoxData = NULL; CurrentTextBox = DataList->Count - 1; } } if (tData->Kind != V_TEXTBOX) { END_LOG; return; } WordDataList = (TWordList*)tData->ListOfAllLine; FirstX = (tData->StartPoint.x - PositionX) * ZoomIn / ZoomOut; FirstY = (tData->StartPoint.y - PositionY) * ZoomIn / ZoomOut; if (tData->nCount < 0) { END_LOG; return; } switch(Key) { case VK_HOME: DeleteCaret(tData); if (xCaretPoz == FirstX && xCaretPoz!=0) { if(!bShiftState) ShiftKeyInitialization(xCaretPoz,yCaretPoz,tData); END_LOG; return; } if(!bShiftState){ DeSelectedTextProc(tData); ShiftKeyInitialization(xCaretPoz,yCaretPoz,tData); } for (i = 0; i < IndexOfWord; i++) { tsWordData = (TSWordData*)WordDataList->Items(i); if (tsWordData->Word[0] == '\r') tline++; if (tline == IndexOfLine) { if (IndexOfLine == 0) IndexOfWord = 0; else IndexOfWord = i + 1; xCaretPoz = FirstX; VectorForm->CurrentFontState(tData); if (bShiftState) { bInSel = true; TextBoxMouseMove(xCaretPoz, yCaretPoz-(CaretH/2)); //bInSel = false; bShiftState=false; END_LOG; return;} else{ ShiftKeyInitialization(xCaretPoz,yCaretPoz,tData); }//º¯¼ö ÃʱâÈ­ºÎºÐ(Shift + Key & Delete °ü·Ã ¿À·ù) ÇØ°á END_LOG; return; } } case VK_END: DeleteCaret(tData); if(!bShiftState){ DeSelectedTextProc(tData); ShiftKeyInitialization(xCaretPoz,yCaretPoz,tData); } for (i = IndexOfWord; i < tData->nCount; i++) { tsWordData = (TSWordData*)WordDataList->Items(i); if (tsWordData->Word[0] == '\r') break; xCaretPoz += tsWordData->Interval * tsWordData->WidthGap * ZoomIn / ZoomOut; } IndexOfWord = i; VectorForm->CurrentFontState(tData); if (bShiftState) { bInSel = true; TextBoxMouseMove(xCaretPoz, yCaretPoz-(CaretH/2)); //bInSel = false; bShiftState=false; END_LOG; return; } else{ ShiftKeyInitialization(xCaretPoz,yCaretPoz,tData); }//º¯¼ö ÃʱâÈ­ºÎºÐ(Shift + Key & Delete °ü·Ã ¿À·ù) ÇØ°á break; case VK_PRIOR: DeleteCaret(tData); break; case VK_NEXT: DeleteCaret(tData); break; case VK_LEFT: DeleteCaret(tData); if (CountOfData == 0) { if(!bShiftState) ShiftKeyInitialization(xCaretPoz,yCaretPoz,tData); END_LOG; return; } if(!bShiftState){ DeSelectedTextProc(tData); ShiftKeyInitialization(xCaretPoz,yCaretPoz,tData); } IndexOfWord--; if (IndexOfWord < 0) IndexOfWord = 0; SetCaretPoz(-1, 0, tData); CaretH = (tData->ListOfAllLine->GetLineTextBox(IndexOfLine))->lineHeight; VectorForm->CurrentFontState(tData); if (bShiftState) { bInSel = true; TextBoxMouseMove(xCaretPoz, yCaretPoz-(CaretH/2)); //bInSel = false; bShiftState=false; END_LOG; return; } else{ ShiftKeyInitialization(xCaretPoz,yCaretPoz,tData); }//º¯¼ö ÃʱâÈ­ºÎºÐ(Shift + Key & Delete °ü·Ã ¿À·ù) ÇØ°á break; case VK_RIGHT: DeleteCaret(tData); if (IndexOfWord >= tData->nCount) { if(!bShiftState) ShiftKeyInitialization(xCaretPoz,yCaretPoz,tData); IndexOfWord = tData->nCount; END_LOG; return; } if(!bShiftState){ DeSelectedTextProc(tData); ShiftKeyInitialization(xCaretPoz,yCaretPoz,tData); } SetCaretPoz(1, 0, tData); CaretH = (tData->ListOfAllLine->GetLineTextBox(IndexOfLine))->lineHeight; IndexOfWord++; if (IndexOfWord > tData->nCount) IndexOfWord = tData->nCount; VectorForm->CurrentFontState(tData); if (bShiftState) { bInSel = true; TextBoxMouseMove(xCaretPoz, yCaretPoz-(CaretH/2)); //bInSel = false; bShiftState=false; END_LOG; return; } else{ ShiftKeyInitialization(xCaretPoz,yCaretPoz,tData); }//º¯¼ö ÃʱâÈ­ºÎºÐ(Shift + Key & Delete °ü·Ã ¿À·ù) ÇØ°á break; case VK_UP: DeleteCaret(tData); if (IndexOfLine == 0) { yCaretPoz = FirstY; if(!bShiftState) ShiftKeyInitialization(xCaretPoz,yCaretPoz,tData); END_LOG; return; } if(!bShiftState){ DeSelectedTextProc(tData); ShiftKeyInitialization(xCaretPoz,yCaretPoz,tData); } if (IndexOfWord >= tData->nCount) IndexOfWord = tData->nCount; // »ç½Ç ÇÊ¿ä¾øÁö¸¸ ±×·¡µµ.. SetCaretPoz(0, -1, tData); CaretH = (tData->ListOfAllLine->GetLineTextBox(IndexOfLine))->lineHeight; VectorForm->CurrentFontState(tData); if (bShiftState) { bInSel = true; TextBoxMouseMove(xCaretPoz, yCaretPoz-(CaretH/2)); //bInSel = false; bShiftState=false; END_LOG; return; } else{ ShiftKeyInitialization(xCaretPoz,yCaretPoz,tData); }//º¯¼ö ÃʱâÈ­ºÎºÐ(Shift + Key & Delete °ü·Ã ¿À·ù) ÇØ°á break; case VK_DOWN: DeleteCaret(tData); if (IndexOfLine == EndLine) { if(!bShiftState) ShiftKeyInitialization(xCaretPoz,yCaretPoz,tData); END_LOG; return; } if(!bShiftState){ DeSelectedTextProc(tData); ShiftKeyInitialization(xCaretPoz,yCaretPoz,tData); } if (IndexOfWord >= tData->nCount) IndexOfWord = tData->nCount; // »ç½Ç ÇÊ¿ä¾øÁö¸¸ ±×·¡µµ.. SetCaretPoz(0, 1, tData); CaretH = (tData->ListOfAllLine->GetLineTextBox(IndexOfLine))->lineHeight; VectorForm->CurrentFontState(tData); if (bShiftState) { bInSel = true; TextBoxMouseMove(xCaretPoz, yCaretPoz-(CaretH/2)); //bInSel = false; bShiftState=false; END_LOG; return; } else{ ShiftKeyInitialization(xCaretPoz,yCaretPoz,tData); }//º¯¼ö ÃʱâÈ­ºÎºÐ(Shift + Key & Delete °ü·Ã ¿À·ù) ÇØ°á break; case VK_DELETE: DeleteCaret(tData); TextModUndoSave(); // for new font BeModified = false; // for new font GetRectForMouseMove(tData, rect); rectBottom = rect.bottom; if (ExistSelected) { // ¼±ÅÃµÈ ¿µ¿ªÀÌ ÀÖÀ¸¸é ¿µ¿ªÀ» Á¦°ÅÇÑ´Ù. int SelFirst, SelSecond, tempLine; if (SelStart < SelEnd) { SelFirst = SelStart; SelSecond = SelEnd; xCaretPoz = SelStartPoz.x; yCaretPoz = SelStartPoz.y; } else { SelFirst = SelEnd; SelSecond = SelStart; } // IndexOfWord offset °áÀý IndexOfWord = SelFirst; if (LineStart > LineEnd) { tempLine = LineStart; LineStart = LineEnd; // Line offset °áÁ¤ LineEnd = tempLine; } IndexOfLine = LineStart; if (SelSecond > tData->nCount) { END_LOG; return; } // Ȥ½Ã³ª ÇÏ´Â ¿¡·¯¸¦ ¹æÁöÇϱâ À§Çؼ­ for (int k = SelFirst; k < SelSecond; k++) { tsWordData = (TSWordData*)WordDataList->Items(SelFirst); if (tsWordData->Word[0] == '\r') { int sline, tline; sline = (tData->ListOfAllLine->GetLineTextBox(IndexOfLine)) ->lineHeight; // ù¹øÂ° ¶óÀÎ tline = (tData->ListOfAllLine->GetLineTextBox(IndexOfLine + 1)) ->lineHeight; // ±× ¾Æ·¡ ¶óÀÎ sline = sline < tline ? tline : sline; (tData->ListOfAllLine->GetLineTextBox(IndexOfLine)) ->lineHeight = sline; WordDataList->Delete(SelFirst); for (int j = 0; j < tData->ListOfAllLine->GetLineTextBox(IndexOfLine + 1) ->LineDataList->Count; j++) { tempWordData = (TSWordData*)tData->ListOfAllLine->GetLineTextBox (IndexOfLine + 1)->LineDataList->Items[j]; tData->ListOfAllLine->GetLineTextBox(IndexOfLine)->LineDataList->Add (tempWordData); } tData->ListOfAllLine->GetLineTextBox(IndexOfLine + 1) ->LineDataList->Clear(); tData->ListOfAllLine->DeleteLine(IndexOfLine + 1); } else WordDataList->Delete(SelFirst); } tData->nCount = WordDataList->Count; VectorForm->CaretHeightChange(tData, IndexOfLine); VectorForm->CaretYPozChange(FirstY, tData, WordDataList); VectorForm->CurrentFontState(tData); fore = RGB(0, 0, 0); back = GetSysColor(COLOR_WINDOW); ExistSelected = false; bInSel = false; } else { if (IndexOfWord == tData->nCount) { END_LOG; return; } // if (WordDataList->Count == IndexOfWord) return; tsWordData = (TSWordData*)WordDataList->Items(IndexOfWord); if (tsWordData->Word[0] == '\r') { int sline, tline; sline = (tData->ListOfAllLine->GetLineTextBox(IndexOfLine)) ->lineHeight; // ù¹øÂ° ¶óÀÎ tline = (tData->ListOfAllLine->GetLineTextBox(IndexOfLine + 1)) ->lineHeight; // ±× ¾Æ·¡ ¶óÀÎ sline = sline < tline ? tline : sline; (tData->ListOfAllLine->GetLineTextBox(IndexOfLine))->lineHeight = sline; WordDataList->Delete(IndexOfWord); // ¸ÕÀú ÇöÀç Word¸¦ Áö¿ì°í for (int j = 0; j < tData->ListOfAllLine->GetLineTextBox(IndexOfLine + 1) ->LineDataList->Count; j++) { tempWordData = (TSWordData*)tData->ListOfAllLine->GetLineTextBox (IndexOfLine + 1)->LineDataList->Items[j]; tData->ListOfAllLine->GetLineTextBox(IndexOfLine)->LineDataList->Add (tempWordData); } tData->ListOfAllLine->GetLineTextBox(IndexOfLine + 1) ->LineDataList->Clear(); tData->ListOfAllLine->DeleteLine(IndexOfLine + 1); } else WordDataList->Delete(IndexOfWord); tData->nCount = WordDataList->Count; VectorForm->CaretHeightChange(tData, IndexOfLine); VectorForm->CaretYPozChange(FirstY, tData, WordDataList); VectorForm->CurrentFontState(tData); } // MakeTextBoxPointList(GetTextBoxRect()); // MainImageForm->iMainImage->Repaint(); MakeTextBoxPointList(tData); GetRectForMouseMove(tData, rect); rect.bottom = rect.bottom > rectBottom ? rect.bottom : rectBottom; MainImageForm->iMainImage->RectPaint(rect); ShiftKeyInitialization(xCaretPoz,yCaretPoz,tData); break; } END_LOG; } // --------------------------------------------------------------------------- /// tData(Text data)¿¡¼­ ¼±ÅÃµÈ ¿µ¿ª ¼±ÅÃÇØÁ¦ void __fastcall TVecDraw::DeSelectedTextProc(TVecData *tData) { //½ºÄð·è½º¿¡¼­ Text »ç¿ëÀ» ÇÒ ¶§ ¿¡·¯°¡ ¹ß»ýÇß´Ù. //AddText¿¡¼­ CurrentTextBox°¡ ´Ù¸¥ ĵ¹ö½ºÀÇ °ªÀ¸·Î Á¢±ÙÇØ¼­ ¹®Á¦°¡ //¹ß»ýÇÏ´Â °ÍÀ¸·Î »ý°¢µÇ¸ç ¾Æ·¡¿Í °°ÀÌ TextBox°¡ ¾Æ´Ï¸é ReturnÇÏ°Ô //ó¸®Çß´Ù. if (!tData) return; if (tData && tData->Kind != V_TEXTBOX) return; BEGIN_LOG(""); TSWordData *tsWordData; int SelFirst, SelSecond; RECT rect; if (ExistSelected) { // ¼±ÅÃµÈ ¿µ¿ªÀÌ ÀÖÀ¸¸é ¿µ¿ªÀ» Á¦°ÅÇÑ´Ù. if (SelStart < SelEnd) { SelFirst = SelStart; SelSecond = SelEnd; } else { SelFirst = SelEnd; SelSecond = SelStart; } if (SelSecond > tData->nCount) { END_LOG; return; } for (int k = SelFirst; k < SelSecond; k++) { tsWordData = (TSWordData*)tData->ListOfAllLine->Items(k); tsWordData->Selected = false; } fore = RGB(0, 0, 0); back = GetSysColor(COLOR_WINDOW); ExistSelected = false; bInSel = false; SelectedWordData = 0; } // MainImageForm->iMainImage->Repaint(); GetTextBoxRect(tData); // MakeTextBoxPointList(data); MakeTextBoxPointList(tData); // by maxleo21c (06.10.09)¿¡·¯ ¹ß»ýÀ¸·Î ¼öÁ¤ GetRectForMouseMove(tData, rect); MainImageForm->iMainImage->RectPaint(rect); END_LOG; } // --------------------------------------------------------------------------- /// CaretÀÇ À§Ä¡¸¦ ¼³Á¤. void __fastcall TVecDraw::SetCaretPoz(int X, int Y, TVecData *tData) { BEGIN_LOG(""); TSWordData *tsWordData, *tempData; HFONT font = NULL, oldfont = NULL; int FirstX, FirstY; TWordList *WordDataList = tData->ListOfAllLine; int ZoomIn = MainImageForm->iMainImage->ZoomIn; int ZoomOut = MainImageForm->iMainImage->ZoomOut; int PositionX = MainImageForm->sbHorz->Position; int PositionY = MainImageForm->sbVert->Position; int tline, count; if (tData->ListOfAllLine->CurveData) { // -->by linuxjun for CurvedVectorText /* FirstX = (tData->StartPoint.x - PositionX) * ZoomIn / ZoomOut ; FirstY = (tData->StartPoint.y - PositionY) * ZoomIn / ZoomOut ; if (X==-1 && Y==0) { // Left tsWordData = (TSWordData *)WordDataList->Items(IndexOfWord); if (tsWordData->Word[0] == '\r') { IndexOfLine--; xCaretPoz = FirstX; yCaretPoz = GetLineHeight(tData, IndexOfLine, FirstY, ZoomIn, ZoomOut); count = tData->ListOfAllLine->GetLineTextBox(IndexOfLine)->LineDataList->Count; for (int j=0; jListOfAllLine->GetLineTextBox(IndexOfLine)->LineDataList->Items[j]; xCaretPoz += tsWordData->Interval * tsWordData->WidthGap * ZoomIn / ZoomOut; } } else xCaretPoz -= tsWordData->Interval * tsWordData->WidthGap * ZoomIn / ZoomOut; } else if (X==1 && Y==0) { // Right tsWordData = (TSWordData *)WordDataList->Items(IndexOfWord); if (tsWordData->Word[0] == '\r') {// xCaretPoz == FirstXÀÏ °æ¿ì´Â ÇöÀç »óŰ¡ Enter·Î ÁÙÀ» IndexOfLine++; // ¹Ù²Û»óÅÂÀ̱⠶§¹®¿¡ ÀÌ·¸°Ô ó¸®Çß´Ù. xCaretPoz = FirstX; yCaretPoz = GetLineHeight(tData, IndexOfLine, FirstY, ZoomIn, ZoomOut); } else xCaretPoz += tsWordData->Interval * tsWordData->WidthGap * ZoomIn / ZoomOut; } else if (X==0 && Y==-1) { // Up IndexOfLine--; X = xCaretPoz; yCaretPoz = GetLineHeight(tData, IndexOfLine, FirstY, ZoomIn, ZoomOut); int j, temp = 0, dis = 9999; double tPos = FirstX; count = tData->ListOfAllLine->GetLineTextBox(IndexOfLine)->LineDataList->Count; for (j=0; jListOfAllLine->GetLineTextBox(IndexOfLine)->LineDataList->Items[j]; if (abs(tPos-X) < dis) { dis = abs(tPos-X); temp = j; xCaretPoz = tPos; } tPos += tsWordData->Interval * tsWordData->WidthGap * ZoomIn / ZoomOut; } if (count==0) xCaretPoz = FirstX; count=0; for (j=0; j<=IndexOfLine-1; j++) { count += tData->ListOfAllLine->GetLineTextBox(j)->LineDataList->Count; } IndexOfWord = count + temp; } else if (X==0 && Y==1) { // Down IndexOfLine++; X = xCaretPoz; yCaretPoz = GetLineHeight(tData, IndexOfLine, FirstY, ZoomIn, ZoomOut); int j, temp = 0, dis = 9999; double tPos = FirstX; count = tData->ListOfAllLine->GetLineTextBox(IndexOfLine)->LineDataList->Count; for (j=0; jListOfAllLine->GetLineTextBox(IndexOfLine)->LineDataList->Items[j]; if (abs(tPos-X) < dis) { dis = abs(tPos-X); temp = j; xCaretPoz = tPos; } tPos += tsWordData->Interval * tsWordData->WidthGap * ZoomIn / ZoomOut; } if (count==0) xCaretPoz = FirstX; if (IndexOfLine == EndLine) { if (abs(tPos-X) < dis) { dis = abs(tPos-X); temp++; xCaretPoz = tPos; } } count=0; for (j=0; j<=IndexOfLine-1; j++) { count += tData->ListOfAllLine->GetLineTextBox(j)->LineDataList->Count; } IndexOfWord = count + temp; if (IndexOfWord > tData->nCount) { IndexOfWord = tData->nCount; // tsWordData = (TSWordData *)tData->ListOfAllLine->Items(IndexOfWord-1); // if (tsWordData->Word[0] == '\r') IndexOfWord--; } } //<-- by linuxjun for CurvedVectorText // */ } else { FirstX = (tData->StartPoint.x - PositionX) * ZoomIn / ZoomOut; FirstY = (tData->StartPoint.y - PositionY) * ZoomIn / ZoomOut; if (X == -1 && Y == 0) { // Left tsWordData = (TSWordData*)WordDataList->Items(IndexOfWord); //if(!bShiftState) //SelStart = SearchPozForCaret(xCaretPoz,yCaretPoz,tData); if (tsWordData->Word[0] == '\r') { IndexOfLine--; xCaretPoz = FirstX; yCaretPoz = GetLineHeight(tData, IndexOfLine, FirstY, ZoomIn, ZoomOut); count = tData->ListOfAllLine->GetLineTextBox(IndexOfLine) ->LineDataList->Count; for (int j = 0; j < count - 1; j++) { tsWordData = (TSWordData*)tData->ListOfAllLine->GetLineTextBox (IndexOfLine)->LineDataList->Items[j]; xCaretPoz += tsWordData->Interval * tsWordData->WidthGap * ZoomIn / ZoomOut; } } else xCaretPoz -= tsWordData->Interval * tsWordData->WidthGap * ZoomIn / ZoomOut; } else if (X == 1 && Y == 0) { // Right tsWordData = (TSWordData*)WordDataList->Items(IndexOfWord); //if(!bShiftState) //SelStart = SearchPozForCaret(xCaretPoz,yCaretPoz,tData); if (tsWordData->Word[0] == '\r') { // xCaretPoz == FirstXÀÏ °æ¿ì´Â ÇöÀç »óŰ¡ Enter·Î ÁÙÀ» IndexOfLine++; // ¹Ù²Û»óÅÂÀ̱⠶§¹®¿¡ ÀÌ·¸°Ô ó¸®Çß´Ù. xCaretPoz = FirstX; yCaretPoz = GetLineHeight(tData, IndexOfLine, FirstY, ZoomIn, ZoomOut); } else xCaretPoz += tsWordData->Interval * tsWordData->WidthGap * ZoomIn / ZoomOut; } else if (X == 0 && Y == -1) { // Up //if(!bShiftState) //SelStart = SearchPozForCaret(xCaretPoz,yCaretPoz,tData); IndexOfLine--; X = xCaretPoz; yCaretPoz = GetLineHeight(tData, IndexOfLine, FirstY, ZoomIn, ZoomOut); int j, temp = 0, dis = 9999; double tPos = FirstX; count = tData->ListOfAllLine->GetLineTextBox(IndexOfLine) ->LineDataList->Count; for (j = 0; j < count; j++) { tsWordData = (TSWordData*)tData->ListOfAllLine->GetLineTextBox (IndexOfLine)->LineDataList->Items[j]; if (abs(long(tPos - X)) < dis) { dis = abs(long(tPos - X)); temp = j; xCaretPoz = tPos; } tPos += tsWordData->Interval * tsWordData->WidthGap * ZoomIn / ZoomOut; } if (count == 0) xCaretPoz = FirstX; count = 0; for (j = 0; j <= IndexOfLine - 1; j++) { count += tData->ListOfAllLine->GetLineTextBox(j)->LineDataList->Count; } IndexOfWord = count + temp; } else if (X == 0 && Y == 1) { // Down //if(!bShiftState) //SelStart = SearchPozForCaret(xCaretPoz,yCaretPoz,tData); IndexOfLine++; X = xCaretPoz; yCaretPoz = GetLineHeight(tData, IndexOfLine, FirstY, ZoomIn, ZoomOut); int j, temp = 0, dis = 9999; double tPos = FirstX; count = tData->ListOfAllLine->GetLineTextBox(IndexOfLine) ->LineDataList->Count; for (j = 0; j < count; j++) { tsWordData = (TSWordData*)tData->ListOfAllLine->GetLineTextBox (IndexOfLine)->LineDataList->Items[j]; if (abs(long(tPos - X)) < dis) { dis = abs(long(tPos - X)); temp = j; xCaretPoz = tPos; } tPos += tsWordData->Interval * tsWordData->WidthGap * ZoomIn / ZoomOut; } if (count == 0) xCaretPoz = FirstX; if (IndexOfLine == EndLine) { if (abs(long(tPos - X)) < dis) { dis = abs(long(tPos - X)); temp++; xCaretPoz = tPos; } } count = 0; for (j = 0; j <= IndexOfLine - 1; j++) { count += tData->ListOfAllLine->GetLineTextBox(j)->LineDataList->Count; } IndexOfWord = count + temp; if (IndexOfWord > tData->nCount) { IndexOfWord = tData->nCount; // tsWordData = (TSWordData *)tData->ListOfAllLine->Items(IndexOfWord-1); // if (tsWordData->Word[0] == '\r') IndexOfWord--; } } } END_LOG; } // --------------------------------------------------------------------------- /// ±×·ÁÁø CaretÀ» Áö¿î´Ù. void __fastcall TVecDraw::DeleteCaret(TVecData *tData) { if (tData == NULL) return; RECT rect; GetRectForMouseMove(tData, rect); // 05.07.28 Ãß°¡ by malxoe21c // ÀÌÀ¯: LineÀ» µû¶ó Text¸¦ ÀÔ·ÂÇÒ¶§ FullViewUpdateÀÌ µÇÁö ¾Ê´Â ¹®Á¦ // top, left°¡ À½¼ö°¡ ³ª¿Í¼­ rectpaintÇÒ¶§ FullViewUpdate°¡ µÇÁö ¾Ê¾Ò´Ù. rect.top = rect.top - 10 < 0 ? 0 : rect.top - 10; rect.left = rect.left - 10 < 0 ? 0 : rect.left - 10; rect.right = rect.right + 10 < 0 ? 0 : rect.right + 10; rect.bottom = rect.bottom + 10 < 0 ? 0 : rect.bottom + 10; MainImageForm->iMainImage->RectPaint(rect); } // --------------------------------------------------------------------------- /// tData¿¡¼­ CaretÀÇ À§Ä¡¸¦ ã¾Æ¼­ ¸®ÅÏ. int __fastcall TVecDraw::SearchPozForCaret(int X, int Y, TVecData *tData) { TWordList *WordDataList = tData->ListOfAllLine; int tDis = 0, dis = 99999, tCount = 0, tCaretH = 0, tLine = 0; int FirstX, FirstY, StartY; double realCharX, realCharY, tempY; TSWordData *tsWordData; int ZoomIn = MainImageForm->iMainImage->ZoomIn; int ZoomOut = MainImageForm->iMainImage->ZoomOut; int PositionX = MainImageForm->sbHorz->Position; int PositionY = MainImageForm->sbVert->Position; int line, line2, checkLine; double angle, tx, ty, tPos; int cx, cy; int j, temp = 0, count, tcount; if (tData->ListOfAllLine->CurveData) { // -->by linuxjun for CurvedVectorText TVecData *Data; Data = tData->ListOfAllLine->CurveData; int Margin; try { Margin = tData->ListOfAllLine->GetLineTextBox(0)->lineHeight * 3; } catch(...) { Margin = 0; } FirstX = Data->First.x - Margin; FirstY = Data->First.y - Margin; int SecondX = Data->Second.x + Margin; int SecondY = Data->Second.y + Margin; if (X < FirstX || X > SecondX || Y < FirstY || Y > SecondY) { IndexOfWord = 0; VectorForm->CurrentFontState(tData); return IndexOfWord; } TSWordData *tsWordData; double dist; int minNum = -1; double minDist; for (int k = 0; k < tData->nCount; k++) { tsWordData = (TSWordData*)tData->ListOfAllLine->Items(k); if (tsWordData->bVisible) { dist = (tsWordData->px - X) * (tsWordData->px - X) + (tsWordData->py - Y) * (tsWordData->py - Y); if (dist <= tsWordData->LFont.lfHeight * tsWordData->HeightGap * tsWordData->LFont.lfHeight * tsWordData->HeightGap) { if (minNum == -1) { minDist = dist + 1; } if (dist < minDist) { minNum = k; minDist = dist; } } } } if (minNum == -1) { IndexOfWord = 0; VectorForm->CurrentFontState(tData); return IndexOfWord; } tsWordData = (TSWordData*)tData->ListOfAllLine->Items(minNum); if ((X - tsWordData->px) * tsWordData->tx + (Y - tsWordData->py) * tsWordData->ty >= 0) { IndexOfWord = minNum + 1; VectorForm->CurrentFontState(tData); return IndexOfWord; } else { IndexOfWord = minNum; VectorForm->CurrentFontState(tData); return IndexOfWord; } // <--by linuxjun for CurvedVectorText } else { FirstX = (tData->First.x - PositionX) * ZoomIn / ZoomOut; FirstY = (tData->First.y - PositionY) * ZoomIn / ZoomOut; StartY = (tData->StartPoint.y - PositionY) * ZoomIn / ZoomOut; X = (X - PositionX) * ZoomIn / ZoomOut; Y = (Y - PositionY) * ZoomIn / ZoomOut; realCharX = FirstX; realCharY = StartY; xCaretPoz = FirstX; angle = tData->TextAngle; line = 0; checkLine = 0; if (angle) { angle = angle / 180 * M_PI; cx = (tData->CenterPoint.x - PositionX) * ZoomIn / ZoomOut; cy = (tData->CenterPoint.y - PositionY) * ZoomIn / ZoomOut; tx = X - cx; ty = cy - Y; X = tx * cos(angle) + ty * sin(angle) + cx; // X,Y°¡ º¯°æµÈ Á¡À̶ó°í »ý°¢Çϰí Y = cy - (-tx * sin(angle) + ty * cos(angle)); // º¯°æµÇ±â ÀüÀ» °è»êÇϸé...? ¸Â³ª? } if (FirstY < Y && Y < StartY) { line = (tData->ListOfAllLine->GetLineTextBox(checkLine))->lineHeight; } else { for (int i = 1; i < tData->ListOfAllLine->LineCount; i++) { line = (tData->ListOfAllLine->GetLineTextBox(i))->lineHeight; tempY = realCharY; tsWordData = (TSWordData*)tData->ListOfAllLine->GetLineTextBox(i - 1) ->LineDataList->Last(); realCharY += ((line) * 0.8 * tsWordData->HeightGap) * ZoomIn / ZoomOut; if (tempY < Y && Y < realCharY) { checkLine = i; break; } } } tPos = FirstX; count = tData->ListOfAllLine->GetLineTextBox(checkLine) ->LineDataList->Count; for (j = 0; j < count; j++) { tsWordData = (TSWordData*)tData->ListOfAllLine->GetLineTextBox(checkLine) ->LineDataList->Items[j]; if (abs(long(tPos - X)) < dis) { dis = abs(long(tPos - X)); temp = j; xCaretPoz = tPos; } tPos += tsWordData->Interval * tsWordData->WidthGap * ZoomIn / ZoomOut; } if (checkLine == EndLine) { if (abs(long(tPos - X)) < dis) { dis = abs(long(tPos - X)); temp++; xCaretPoz = tPos; } } count = 0; for (j = 0; j <= checkLine - 1; j++) { count += tData->ListOfAllLine->GetLineTextBox(j)->LineDataList->Count; } IndexOfWord = count + temp; // ¸¶Áö¸· ¶óÀÎÀÌ Enter·Î ¾Æ¹«Data°¡ ¾øÀ» °æ¿ì temp°¡ 1ÀÌ µÇ´Âµ¥ ÀÌ·¯¸é ¼ýÀÚ°¡ ³Ñ¾î°£´Ù. if (IndexOfWord > tData->nCount) IndexOfWord = tData->nCount; yCaretPoz = realCharY; IndexOfLine = checkLine; CaretH = line; } VectorForm->CurrentFontState(tData); return IndexOfWord; } // --------------------------------------------------------------------------- /// ÁÖ¾îÁø FirstY¿¡ line height°¡ ´õÇØÁø °ªÀ» ¸®ÅÏ. int __fastcall TVecDraw::GetLineHeight(TVecData *tData, int Line, int FirstY, int ZoomIn, int ZoomOut) { TSWordData *tsWordData; int LineHeight; double tPozY = FirstY; int Count, tcount; for (int i = 1; i <= Line; i++) { LineHeight = (tData->ListOfAllLine->GetLineTextBox(i))->lineHeight; tsWordData = (TSWordData*)tData->ListOfAllLine->GetLineTextBox(i - 1) ->LineDataList->Last(); tPozY += (LineHeight * 0.8 * tsWordData->HeightGap) * ZoomIn / ZoomOut; } return tPozY; } // ---------------------------------------------------------------------------- /// ¼±ÅÃµÈ WordData¸¦ º¹»ç. void __fastcall TVecDraw::CopySelectedWordData() { TVecData *tData; TSWordData *tsWordData, *newWordData=NULL; int SelFirst, SelSecond; TList *DataList = NVector->DataList; HGLOBAL hMem; sTemp=""; char *ptr={0}; if (CurrentTextBox < 0) return; BEGIN_LOG(""); if (ExistSelected) { // ¼±ÅÃµÈ ¿µ¿ªÀÌ ÀÖÀ¸¸é ¿µ¿ªÀ» Á¦°ÅÇÑ´Ù. if (SelStart < SelEnd) { SelFirst = SelStart; SelSecond = SelEnd; } else { SelFirst = SelEnd; SelSecond = SelStart; } while (ListOfSelectedWord->Count) { tsWordData = (TSWordData*)ListOfSelectedWord->First(); delete tsWordData; ListOfSelectedWord->Remove(tsWordData); } tData = (TVecData*)DataList->Items[CurrentTextBox]; for (int k = SelFirst; k < SelSecond; k++) { newWordData = new TSWordData; tsWordData = (TSWordData*)tData->ListOfAllLine->Items(k); newWordData->Selected = false; newWordData->bNameChanged = tsWordData->bNameChanged; // 2005 Vector Upgrade Shin 0315 newWordData->Color = tsWordData->Color; newWordData->PPoint.x = tsWordData->PPoint.x; newWordData->PPoint.y = tsWordData->PPoint.y; newWordData->Interval = tsWordData->Interval; newWordData->UsedByte = tsWordData->UsedByte; _tcscpy(newWordData->Word, tsWordData->Word); newWordData->WidthGap = tsWordData->WidthGap; // º¯°æµÉ ±ÛÀÚ°£°Ý % newWordData->HeightGap = tsWordData->HeightGap; // º¯°æµÉ ÁÙ°£°Ý % newWordData->LFont.lfHeight = tsWordData->LFont.lfHeight; newWordData->LFont.lfWidth = tsWordData->LFont.lfWidth; newWordData->LFont.lfEscapement = tsWordData->LFont.lfEscapement; newWordData->LFont.lfOrientation = tsWordData->LFont.lfOrientation; newWordData->LFont.lfWeight = tsWordData->LFont.lfWeight; newWordData->LFont.lfItalic = tsWordData->LFont.lfItalic; newWordData->LFont.lfUnderline = tsWordData->LFont.lfUnderline; newWordData->LFont.lfStrikeOut = tsWordData->LFont.lfStrikeOut; newWordData->LFont.lfCharSet = tsWordData->LFont.lfCharSet; newWordData->LFont.lfPitchAndFamily = tsWordData->LFont.lfPitchAndFamily; _tcscpy(newWordData->LFont.lfFaceName, tsWordData->LFont.lfFaceName); ListOfSelectedWord->Add(newWordData); if (newWordData->Word[0] == '\r') { //sTemp += "\r\n"; //by Gaeseong sTemp += "\r"; } else { sTemp += newWordData->Word; } } int count = sTemp.Length(); //hMem=GlobalAlloc(GHND,strlen(str)+1); hMem=GlobalAlloc(GHND,count+1); ptr=(char *)GlobalLock(hMem); if (ptr[count] == '\n') { memcpy(ptr,sTemp.c_str(),sizeof(char)*count-2); } else memcpy(ptr,sTemp.c_str(),sizeof(char)*count); GlobalUnlock(hMem); if(OpenClipboard(hWnd)){ EmptyClipboard(); SetClipboardData(CF_TEXT,hMem); CloseClipboard(); } //2014.04.15 NDJ (Windows API Clipboard¸¦ ÀÌ¿ëÇÏ¿© Window·Î µ¥ÀÌÅͺ¹»ç°¡ °¡´ÉÇÏ°Ô ÇÑ´Ù. } END_LOG; } // ---------------------------------------------------------------------------- /// º¹»çÇÑ WordData¸¦ ºÙÀÓ. void __fastcall TVecDraw::PasteSelectedWordData(TVecData *tData,String clipText) { BEGIN_LOG(""); if(clipText!=sTemp){ ClipPasteProcessing(clipText); END_LOG; return; } int tline, indexInLine, count, wordcount; TWordList *WordDataList; TLineTextBox *tempTLineTextBox, *newTLineTextBox; TSWordData *tsWordData, *newWordData, *tempWordData; int ZoomIn = MainImageForm->iMainImage->ZoomIn; int ZoomOut = MainImageForm->iMainImage->ZoomOut; int PositionX = MainImageForm->sbHorz->Position; int PositionY = MainImageForm->sbVert->Position; int FirstX = (tData->StartPoint.x - PositionX) * ZoomIn / ZoomOut; int FirstY = (tData->StartPoint.y - PositionY) * ZoomIn / ZoomOut; RECT rect; TextModUndoSave(); // for new font WordDataList = (TWordList*)tData->ListOfAllLine; for (int i = 0; i < ListOfSelectedWord->Count; i++) { tsWordData = (TSWordData*)ListOfSelectedWord->Items[i]; if(tData->ListOfAllLine->CurveData && tData->ListOfAllLine->CurveData->ParentTextBox && tsWordData->Word[0] == '\r') continue; newWordData = new TSWordData; newWordData->Selected = false; newWordData->bNameChanged = tsWordData->bNameChanged; // 2005 Vector Upgrade Shin 0315 newWordData->Color = tsWordData->Color; newWordData->PPoint.x = tsWordData->PPoint.x; newWordData->PPoint.y = tsWordData->PPoint.y; newWordData->Interval = tsWordData->Interval; newWordData->UsedByte = tsWordData->UsedByte; _tcscpy(newWordData->Word, tsWordData->Word); newWordData->WidthGap = tsWordData->WidthGap; // º¯°æµÉ ±ÛÀÚ°£°Ý % newWordData->HeightGap = tsWordData->HeightGap; // º¯°æµÉ ÁÙ°£°Ý % newWordData->LFont.lfHeight = tsWordData->LFont.lfHeight; newWordData->LFont.lfWidth = tsWordData->LFont.lfWidth; newWordData->LFont.lfEscapement = tData->TextAngle * 10; newWordData->LFont.lfOrientation = tsWordData->LFont.lfOrientation; newWordData->LFont.lfWeight = tsWordData->LFont.lfWeight; newWordData->LFont.lfItalic = tsWordData->LFont.lfItalic; newWordData->LFont.lfUnderline = tsWordData->LFont.lfUnderline; newWordData->LFont.lfStrikeOut = tsWordData->LFont.lfStrikeOut; newWordData->LFont.lfCharSet = tsWordData->LFont.lfCharSet; newWordData->LFont.lfPitchAndFamily = tsWordData->LFont.lfPitchAndFamily; _tcscpy(newWordData->LFont.lfFaceName, tsWordData->LFont.lfFaceName); tempTLineTextBox = (TLineTextBox*)WordDataList->GetLineTextBox(IndexOfLine); indexInLine = WordDataList->GetIndexInLine(IndexOfWord); if (tempTLineTextBox->LineDataList->Count) tempTLineTextBox->LineDataList->Insert(indexInLine, newWordData); else tempTLineTextBox->LineDataList->Add(newWordData); /* tline = tempTLineTextBox->lineHeight; xCaretPoz += newWordData->Interval * tsWordData->WidthGap * ZoomIn / ZoomOut; // for caret tline = tline >= newWordData->PPoint.y ? tline : newWordData->PPoint.y; tempTLineTextBox->lineHeight = tline; CaretH = tline; */ tData->nCount++; IndexOfWord++; if (newWordData->Word[0] == '\r') { IndexOfLine++; newTLineTextBox = new TLineTextBox; wordcount = WordDataList->GetLineTextBox(IndexOfLine - 1) ->LineDataList->Count; indexInLine = WordDataList->GetIndexInLine(IndexOfWord); count = wordcount - indexInLine; if (count) { while (count > 0) { tempWordData = (TSWordData*) (WordDataList->GetLineTextBox(IndexOfLine - 1)) ->LineDataList->Items[indexInLine]; (WordDataList->GetLineTextBox(IndexOfLine - 1))->LineDataList->Remove (tempWordData); newTLineTextBox->LineDataList->Add(tempWordData); count--; } } newTLineTextBox->lineHeight = newWordData->PPoint.y; if (tData->ListOfAllLine->LineCount == IndexOfLine) // LineCount°¡ 1ºÎÅÍ ½ÃÀÛÇϱ⠶§¹® tData->ListOfAllLine->Add(newTLineTextBox); else tData->ListOfAllLine->Insert(IndexOfLine, newTLineTextBox); } } VectorForm->CaretHeightChange(tData, IndexOfLine); GetTextBoxRect(tData); MakeTextBoxPointList(tData); SetCaretPozByIndex(IndexOfWord); MainImageForm->iMainImage->Repaint(); ShiftKeyInitialization(xCaretPoz,yCaretPoz,tData); // MainImageForm->iMainImage->RectPaint(rect); END_LOG; } // --------------------------------------------------------------------------- /// ÁÖ¾îÁø À妽º(WordIndex)¿¡ CaretÀÇ À§Ä¡, ±æÀÌ µîÀ» ¼³Á¤. void __fastcall TVecDraw::SetCaretPozByIndex(int WordIndex) { TVecData *tData; TList *DataList = NVector->DataList; if (DataList->Count <= 0 || CurrentTextBox < 0) return; tData = (TVecData*)DataList->Items[CurrentTextBox]; if (!tData->Equal(MainImageForm->Number)) return; TSWordData *tsWordData; int ZoomIn = MainImageForm->iMainImage->ZoomIn; int ZoomOut = MainImageForm->iMainImage->ZoomOut; int PositionX = MainImageForm->sbHorz->Position; int PositionY = MainImageForm->sbVert->Position; int StartX, StartY; double realCharX, realCharY; int lineHeight = 0, lineCount = 0; StartX = (tData->StartPoint.x - PositionX) * ZoomIn / ZoomOut; StartY = (tData->StartPoint.y - PositionY) * ZoomIn / ZoomOut; realCharX = StartX; realCharY = StartY; for (int i = 0; i < WordIndex; i++) { tsWordData = (TSWordData*)tData->ListOfAllLine->Items(i); if (tsWordData == NULL) { // Error Handling //Index Out Of Bounds Exception. realCharX = StartX; realCharY = StartY; lineCount = 0; WordIndex = 0; TextAngle = 0; break; } if (tsWordData->Word[0] == '\r') { lineCount++; lineHeight = (tData->ListOfAllLine->GetLineTextBox(lineCount)) ->lineHeight; realCharX = StartX; realCharY += (lineHeight * 0.8 * tsWordData->HeightGap) * ZoomIn / ZoomOut; } else realCharX += tsWordData->Interval * tsWordData->WidthGap * ZoomIn / ZoomOut; } if (lineCount == 0) lineHeight = (tData->ListOfAllLine->GetLineTextBox(lineCount))->lineHeight; CaretH = lineHeight; xCaretPoz = realCharX; yCaretPoz = realCharY; IndexOfWord = WordIndex; IndexOfLine = lineCount; ShiftKeyInitialization(xCaretPoz,yCaretPoz,tData); if (tData->ListOfAllLine->Count == 0) TextAngle = 0; else { tsWordData = (TSWordData*)tData->ListOfAllLine->Items(0); if (tsWordData == NULL) TextAngle = 0; else TextAngle = tsWordData->LFont.lfEscapement / 10; } // MainImageForm->tempRadioButton->SetFocus(); } // --------------------------------------------------------------------------- /// ÇöÀç tDataÀÇ ¿µ¿ª(tData->Second)À» °è»êÇÑ´Ù. TVecData * __fastcall TVecDraw::GetTextBoxRect(TVecData *tData) { if (tData == NULL) { TList *DataList = NVector->DataList; if (DataList->Count <= 0 || CurrentTextBox < 0) return NULL; tData = (TVecData*)DataList->Items[CurrentTextBox]; } TSWordData *tsWordData; int ZoomIn = MainImageForm->iMainImage->ZoomIn; int ZoomOut = MainImageForm->iMainImage->ZoomOut; int PositionX = MainImageForm->sbHorz->Position; int PositionY = MainImageForm->sbVert->Position; int StartX, StartY; double realCharX, realCharY, tSecondX, tSecondY; int lineHeight = 0, lineCount = 0, templine, tempHeight; float MarginY; tData->Second.x = tData->StartPoint.x; tData->Second.y = tData->StartPoint.y; StartX = (tData->StartPoint.x - PositionX) * ZoomIn / ZoomOut; StartY = (tData->StartPoint.y - PositionY) * ZoomIn / ZoomOut; realCharX = StartX; realCharY = StartY; for (int i = 0; i < tData->nCount; i++) { tsWordData = (TSWordData*)tData->ListOfAllLine->Items(i); if (tsWordData->Word[0] == '\r') { tSecondX = realCharX * ZoomOut / ZoomIn + PositionX; tData->Second.x = tData->Second.x >= tSecondX ? tData->Second.x : tSecondX; lineCount++; lineHeight = (tData->ListOfAllLine->GetLineTextBox(lineCount)) ->lineHeight; realCharX = StartX; realCharY += ((lineHeight) * 0.8 * tsWordData->HeightGap) * ZoomIn / ZoomOut; } else realCharX += tsWordData->Interval * tsWordData->WidthGap * ZoomIn / ZoomOut; } templine = (tData->ListOfAllLine->GetLineTextBox(0))->lineHeight; tempHeight = abs(tData->First.y - tData->StartPoint.y); if (tempHeight != templine) tData->First.y = tData->StartPoint.y - templine; tSecondX = realCharX * ZoomOut / ZoomIn + PositionX; tSecondY = realCharY * ZoomOut / ZoomIn + PositionY; tData->Second.x = tData->Second.x >= tSecondX ? tData->Second.x : tSecondX; tData->Second.y = tData->Second.y >= tSecondY ? tData->Second.y : tSecondY; MarginY = (float)lineHeight / 5; // ÆùÆ®ÀÇ ¾Æ·¡ ºÎºÐÀÌ Æ÷ÇÔµÇÁö ¾Ê´Â °æ¿ì¸¦ ´ëºñÇØ¼­ tData->Second.y += MarginY; return tData; } // --------------------------------------------------------------------------- /// ¸¶¿ì½º°¡ ¿òÁ÷ÀÎ ¿µ¿ª °è»ê(ÇöÀç object¸¦ ´Ù½Ã ±×¸± ¿µ¿ª °è»ê) void __fastcall TVecDraw::GetRectForMouseMove(TVecData *tData, RECT &rect) { POINT pTemp[5]; int temp; double angle; // -->by linuxjun for CurvedVectorText // * if (tData->ListOfAllLine && tData->ListOfAllLine->CurveData) { // by linuxjun for CurvedVectorText TVecData *Data; Data = tData->ListOfAllLine->CurveData; int Margin; try { Margin = tData->ListOfAllLine->GetLineTextBox(0)->lineHeight * 3; } catch(...) { Margin = 0; } rect.left = Data->First.x - Margin; rect.top = Data->First.y - Margin; rect.right = Data->Second.x + Margin; rect.bottom = Data->Second.y + Margin; // <--by linuxjun for CurvedVectorText } else if (tData->TextAngle) { for (int i = 0; i < 5; i++) pTemp[i] = tData->pList[i].P(); for (int i = 0; i < 4; i++) { for (int j = 0; j < i; j++) { if (pTemp[i].x > pTemp[j].x) { temp = pTemp[i].x; pTemp[i].x = pTemp[j].x; pTemp[j].x = temp; } if (pTemp[i].y > pTemp[j].y) { temp = pTemp[i].y; pTemp[i].y = pTemp[j].y; pTemp[j].y = temp; } } } rect.left = pTemp[3].x; rect.top = pTemp[3].y; rect.right = pTemp[0].x; rect.bottom = pTemp[0].y; } else if (tData->ChildList) { // 09.02.28 TVecData *item = NULL; int w, h, maxthick = 0; long minx = MaxInt, miny = MaxInt, maxx = 0, maxy = 0; for (int i = 0; i < tData->ChildList->Count; i++) { item = (TVecData*)tData->ChildList->Items[i]; minx = min(minx, item->First.x); minx = min(minx, item->Second.x); maxx = max(maxx, item->First.x); maxx = max(maxx, item->Second.x); miny = min(miny, item->First.y); miny = min(miny, item->Second.y); maxy = max(maxy, item->First.y); maxy = max(maxy, item->Second.y); } w = (maxx - minx) / 2; h = (maxy - miny) / 2; w = sqrt(w * w + h * h) + 0.5; rect.left = tData->First.x - w; rect.top = tData->First.y - w; rect.right = tData->Second.x + w; rect.bottom = tData->Second.y + w; } else { rect.left = tData->First.x; rect.top = tData->First.y; rect.right = tData->Second.x; rect.bottom = tData->Second.y; } } // --------------------------------------------------------------------------- /// Text data ¶Ç´Â Curved Text¿¡¼­ °¢ ±ÛÀÚ°¡ ¾²¿©Áú À§Ä¡ °è»ê void __fastcall TVecDraw::MakeTextBoxPointList(TVecData *data) { BEGIN_LOG(""); int cx, cy; double angle, tx, ty; if (data && data->ListOfAllLine && data->ListOfAllLine->CurveData) { // -->by linuxjun for CurvedVectorText TBezierPointList * BezierPointList = new TBezierPointList(); // »ý¼º TList * ResultBezierPointList; TPointList *tempPointList; LengthPOINT * LengthPt; TList * LengthList = new TList(); double *dInterval; int tLine = 0; ////////////////////////////////°¢´Ü¾îÀÇ ±æÀ̸¦ °è»êÇÏ¿© BezierPointList·Î À§Ä¡°è»ê TSWordData *tsWordData; double prev, next; prev = next = 0.0; for (int k = 0; k < data->nCount; k++) { tsWordData = (TSWordData*)data->ListOfAllLine->Items(k); if (tsWordData->Word[0] == '\r') { dInterval = new double; *dInterval = 0; LengthList->Add(dInterval); tLine++; } else { next = tsWordData->Interval * tsWordData->WidthGap; dInterval = new double; *dInterval = prev / 2 + next / 2; prev = next; LengthList->Add(dInterval); } } ResultBezierPointList = BezierPointList->Calculate (data->ListOfAllLine->CurveData, LengthList); ///////////////////////////////////////// °è»êµÈ ´Ü¾îÀÇ À§Ä¡¸¦ °¢ ´Ü¾îº°·Î °®°íÀÖ°Ô ÀÔ·Â int num = 0; for (int i = 0; i < ResultBezierPointList->Count; i++) { tempPointList = (TPointList*)ResultBezierPointList->Items[i]; for (tempPointList->First(); !tempPointList->IsDone(); tempPointList->Next()) { LengthPt = tempPointList->CurrentPt(); if (num < data->nCount) { tsWordData = (TSWordData*)data->ListOfAllLine->Items(num); if (tsWordData->Word[0] == '\r') { tsWordData->bVisible = false; tsWordData->px = LengthPt->px; tsWordData->py = LengthPt->py; tsWordData->tx = LengthPt->tx; tsWordData->ty = LengthPt->ty; tsWordData->nx = LengthPt->nx; tsWordData->ny = LengthPt->ny; num++; } else { tsWordData->bVisible = true; tsWordData->px = LengthPt->px; tsWordData->py = LengthPt->py; tsWordData->tx = LengthPt->tx; tsWordData->ty = LengthPt->ty; tsWordData->nx = LengthPt->nx; tsWordData->ny = LengthPt->ny; num++; } } } } /////////////////////////////////////////±æÀ̰¡ ³Ñ¾î°¡ÀÖ´Â ´Ü¾îÀÇ °æ¿ì º¸ÀÌÁö ¾Ê°Ô ÇÔ. for (int k = num; k < data->nCount; k++) { tsWordData = (TSWordData*)data->ListOfAllLine->Items(k); tsWordData->bVisible = false; } ////////////////////////////////////// // ±ú²ýÇÏ°Ô Resouce Á¦°Å while (LengthList->Count) { dInterval = (double*)LengthList->Last(); LengthList->Remove(dInterval); delete dInterval; dInterval = NULL; } delete LengthList; LengthList = NULL; delete BezierPointList; BezierPointList = NULL; // ¼Ò¸ê // <--by linuxjun for CurvedVectorText } else { data->pList[0].x = data->First.x; data->pList[0].y = data->First.y; data->pList[1].x = data->First.x; data->pList[1].y = data->Second.y; data->pList[2].x = data->Second.x; data->pList[2].y = data->Second.y; data->pList[3].x = data->Second.x; data->pList[3].y = data->First.y; data->pList[4].x = data->First.x; data->pList[4].y = data->First.y; if (data->TextAngle) { cx = data->CenterPoint.x; cy = data->CenterPoint.y; angle = data->TextAngle; angle = angle / 180 * M_PI; for (int j = 0; j < 5; j++) { tx = data->pList[j].x - cx; ty = cy - data->pList[j].y; data->pList[j].x = tx * cos(-angle) + ty * sin(-angle) + cx; data->pList[j].y = cy - (-tx * sin(-angle) + ty * cos(-angle)); } } } END_LOG; } // --------------------------------------------------------------------------- /// ÇöÀç ÆíÁýÁßÀÎ Vector object(Textdata)¿¡¼­ ¼±ÅÃµÈ ºÎºÐÀÇ ÆùÆ® º¯°æ void __fastcall TVecDraw::ChangeFontSeletedWordData(TFont *font) { SIZE size; HDC hdc; TVecData *tData; TList *DataList = NVector->DataList; if (DataList->Count < 0 || CurrentTextBox < 0) return; tData = (TVecData*)DataList->Items[CurrentTextBox]; if (tData == NULL) return; BEGIN_LOG(""); TSWordData *tsWordData; int SelFirst, SelSecond; int SelLineFirst, SelLineSecond; RECT rect; TextModUndoSave(); // for new font if (LineEnd < LineStart) { SelLineFirst = LineEnd; SelLineSecond = LineStart; } else { SelLineFirst = LineStart; SelLineSecond = LineEnd; } if (SelEnd < SelStart) { SelFirst = SelEnd; SelSecond = SelStart; } else { SelFirst = SelStart; SelSecond = SelEnd; } for (int k = SelFirst; k < SelSecond; k++) { tsWordData = (TSWordData*)tData->ListOfAllLine->Items(k); if (!tsWordData->Selected) continue; _tcscpy(tsWordData->LFont.lfFaceName, font->Name.c_str()); font->Size = tsWordData->LFont.lfHeight; tsWordData->LFont.lfCharSet = font->Charset; tsWordData->LFont.lfPitchAndFamily = font->Pitch | FF_DONTCARE; hdc = MainImageForm->iMainImage->Canvas->Handle; /////////////////////// Vista Font¿¡ ´ëÇØ SizeÁ¦´ë·Î ¸ø°¡Á®¿Í¼­ »ý±â´Â ¹®Á¦ ó¸® (2007. 06. 27 Annualring) size = GetVectorTextExtent(MainImageForm->iMainImage->Canvas, font, tsWordData); tsWordData->PPoint.x = size.cx; tsWordData->PPoint.y = size.cy; tsWordData->Interval = size.cx * 4 / 5; if (tsWordData->Word[0] == '\r') { VectorForm->CaretHeightChange(tData, SelLineFirst); SelLineFirst++; } } VectorForm->CheckNChangeFont(true, tData); if(tsWordData != NULL){ if (tsWordData->Word[0] != '\r') VectorForm->CaretHeightChange(tData, SelLineFirst); } /* text ºí·Ï¼³Á¤ ÈÄ text ¼Ó¼º º¯°æ½Ã ºí·Ï¼³Á¤ ÇØÁ¦µÇÁö ¾Êµµ·Ï Çϱâ À§ÇØ ÁÖ¼®Ã³¸® by G.H. GetTextBoxRect(tData); MakeTextBoxPointList(tData); SetCaretPozByIndex(IndexOfWord); */ // MainImageForm->iMainImage->RectPaint(rect); MainImageForm->iMainImage->Repaint(); END_LOG; } // --------------------------------------------------------------------------- /// ÇöÀç ÆíÁýÁßÀÎ Vector object(Textdata)¿¡¼­ ¼±ÅÃµÈ ºÎºÐÀÇ »çÀÌÁî º¯°æ void __fastcall TVecDraw::ChangeSizeSeletedWordData(TFont *font) { SIZE size; HDC hdc; TVecData *tData; TList *DataList = NVector->DataList; if (DataList->Count < 0 || CurrentTextBox < 0) return; tData = (TVecData*)DataList->Items[CurrentTextBox]; if (tData == NULL) return; BEGIN_LOG(""); TSWordData *tsWordData; int SelFirst, SelSecond; int SelLineFirst, SelLineSecond, k; RECT rect; TextModUndoSave(); // for new font if (LineEnd < LineStart) { SelLineFirst = LineEnd; SelLineSecond = LineStart; } else { SelLineFirst = LineStart; SelLineSecond = LineEnd; } if (SelEnd < SelStart) { SelFirst = SelEnd; SelSecond = SelStart; } else { SelFirst = SelStart; SelSecond = SelEnd; } for (k = SelFirst; k < SelSecond; k++) { tsWordData = (TSWordData*)tData->ListOfAllLine->Items(k); //if (!tsWordData->Selected) //continue;(±ÛÀÚ Å©±â º¯°æ Àû¿ëÀÌ ¾ÈµÇ¼­ Àá½Ã ÁÖ¼®Ã³¸®¸¦ ÇÏ¿´´Ù. 2014.06.09) tsWordData->LFont.lfHeight = font->Size; font->Name = tsWordData->LFont.lfFaceName; hdc = MainImageForm->iMainImage->Canvas->Handle; /* if (tsWordData->UsedByte == 1) GetTextExtentPoint32(hdc, tsWordData->Word, 1, &size); else GetTextExtentPoint32(hdc, tsWordData->Word, 2, &size); */ /////////////////////// Vista Font¿¡ ´ëÇØ SizeÁ¦´ë·Î ¸ø°¡Á®¿Í¼­ »ý±â´Â ¹®Á¦ ó¸® (2007. 06. 27 Annualring) size = GetVectorTextExtent(MainImageForm->iMainImage->Canvas, font, tsWordData); tsWordData->PPoint.x = size.cx; tsWordData->PPoint.y = size.cy; tsWordData->Interval = size.cx * 4 / 5; if (tsWordData->Word[0] == '\r') { VectorForm->CaretHeightChange(tData, SelLineFirst); SelLineFirst++; } } VectorForm->CheckNChangeFont(true, tData); for (int k = SelLineFirst; k <=SelLineSecond; k++) VectorForm->CaretHeightChange(tData, k); /* text ºí·Ï¼³Á¤ ÈÄ text ¼Ó¼º º¯°æ½Ã ºí·Ï¼³Á¤ ÇØÁ¦µÇÁö ¾Êµµ·Ï Çϱâ À§ÇØ ÁÖ¼®Ã³¸® by G.H. GetTextBoxRect(tData); MakeTextBoxPointList(tData); SetCaretPozByIndex(IndexOfWord); */ // MainImageForm->iMainImage->RectPaint(rect); MainImageForm->iMainImage->Repaint(); END_LOG; } // --------------------------------------------------------------------------- /// ÇöÀç ÆíÁýÁßÀÎ Vector object(Textdata)¿¡¼­ ¼±ÅÃµÈ ºÎºÐÀÇ ½ºÅ¸ÀÏ º¯°æ void __fastcall TVecDraw::ChangeStyleSeletedWordData(TFont *font) { SIZE size; HDC hdc; TVecData *tData; TList *DataList = NVector->DataList; if (DataList->Count < 0 || CurrentTextBox < 0) return; BEGIN_LOG(""); tData = (TVecData*)DataList->Items[CurrentTextBox]; TSWordData *tsWordData; int SelFirst, SelSecond; int SelLineFirst, SelLineSecond, k; RECT rect; TextModUndoSave(); // for new font if (LineEnd < LineStart) { SelLineFirst = LineEnd; SelLineSecond = LineStart; } else { SelLineFirst = LineStart; SelLineSecond = LineEnd; } if (SelEnd < SelStart) { SelFirst = SelEnd; SelSecond = SelStart; } else { SelFirst = SelStart; SelSecond = SelEnd; } for (k = SelFirst; k < SelSecond; k++) { tsWordData = (TSWordData*)tData->ListOfAllLine->Items(k); if (!tsWordData) continue; if (!tsWordData->Selected) continue; font->Name = tsWordData->LFont.lfFaceName; font->Size = tsWordData->LFont.lfHeight; hdc = MainImageForm->iMainImage->Canvas->Handle; tsWordData->LFont.lfItalic = font->Style.Contains(fsItalic); tsWordData->LFont.lfUnderline = font->Style.Contains(fsUnderline); if (font->Style.Contains(fsBold)) tsWordData->LFont.lfWeight = FW_BOLD; else tsWordData->LFont.lfWeight = FW_NORMAL; tsWordData->LFont.lfStrikeOut = font->Style.Contains(fsStrikeOut); /* if (tsWordData->UsedByte == 1) GetTextExtentPoint32(hdc, tsWordData->Word, 1, &size); else GetTextExtentPoint32(hdc, tsWordData->Word, 2, &size); */ /////////////////////// Vista Font¿¡ ´ëÇØ SizeÁ¦´ë·Î ¸ø°¡Á®¿Í¼­ »ý±â´Â ¹®Á¦ ó¸® (2007. 06. 27 Annualring) size = GetVectorTextExtent(MainImageForm->iMainImage->Canvas, font, tsWordData); tsWordData->PPoint.x = size.cx; tsWordData->PPoint.y = size.cy; tsWordData->Interval = size.cx * 4 / 5; if (tsWordData->Word[0] == '\r') { VectorForm->CaretHeightChange(tData, SelLineFirst); SelLineFirst++; } } VectorForm->CheckNChangeFont(true, tData); if(tsWordData != NULL){ if (tsWordData->Word[0] != '\r') VectorForm->CaretHeightChange(tData, SelLineFirst); } /* text ºí·Ï¼³Á¤ ÈÄ text ¼Ó¼º º¯°æ½Ã ºí·Ï¼³Á¤ ÇØÁ¦µÇÁö ¾Êµµ·Ï Çϱâ À§ÇØ ÁÖ¼®Ã³¸® by G.H. GetTextBoxRect(tData); MakeTextBoxPointList(tData); SetCaretPozByIndex(IndexOfWord); */ // MainImageForm->iMainImage->RectPaint(rect); MainImageForm->iMainImage->Repaint(); END_LOG; } // --------------------------------------------------------------------------- /// ÇöÀç Vector data(CurrentTextBox)ÀÇ ÀÚ°£ º¯°æ void __fastcall TVecDraw::ChangeWGapSeletedWordData(int wGap) { SIZE size; TVecData *tData; TList *DataList = NVector->DataList; if (DataList->Count <= 0 || CurrentTextBox < 0) return; tData = (TVecData*)DataList->Items[CurrentTextBox]; BEGIN_LOG(""); TSWordData *tsWordData; int SelFirst, SelSecond; int SelLineFirst, SelLineSecond, k; RECT rect; TextModUndoSave(); // for new font if (LineEnd < LineStart) { SelLineFirst = LineEnd; SelLineSecond = LineStart; } else { SelLineFirst = LineStart; SelLineSecond = LineEnd; } if (SelEnd < SelStart) { SelFirst = SelEnd; SelSecond = SelStart; } else { SelFirst = SelStart; SelSecond = SelEnd; } for (k = SelFirst; k < SelSecond; k++) { tsWordData = (TSWordData*)tData->ListOfAllLine->Items(k); if (!tsWordData->Selected) continue; tsWordData->WidthGap = (float)wGap / 100; if (tsWordData->Word[0] == '\r') { VectorForm->CaretHeightChange(tData, SelLineFirst); SelLineFirst++; } } // VectorForm->CheckNChangeFont(false, tData); if (tsWordData != NULL){ if (tsWordData->Word[0] != '\r') VectorForm->CaretHeightChange(tData, SelLineFirst); } /* text ºí·Ï¼³Á¤ ÈÄ text ¼Ó¼º º¯°æ½Ã ºí·Ï¼³Á¤ ÇØÁ¦µÇÁö ¾Êµµ·Ï Çϱâ À§ÇØ ÁÖ¼®Ã³¸® by G.H. GetTextBoxRect(tData); MakeTextBoxPointList(tData); SetCaretPozByIndex(IndexOfWord); */ // MainImageForm->iMainImage->RectPaint(rect); MainImageForm->iMainImage->Repaint(); END_LOG; } // --------------------------------------------------------------------------- /// ÇöÀç Vector data(CurrentTextBox)ÀÇ ÁÙ°£°Ý º¯°æ void __fastcall TVecDraw::ChangeHGapSeletedWordData(int hGap) { SIZE size; TVecData *tData; TList *DataList = NVector->DataList; if (DataList->Count <= 0 || CurrentTextBox < 0) return; tData = (TVecData*)DataList->Items[CurrentTextBox]; BEGIN_LOG(""); TSWordData *tsWordData; int SelFirst, SelSecond; int SelLineFirst, SelLineSecond, k; RECT rect; TextModUndoSave(); // for new font if (LineEnd < LineStart) { SelLineFirst = LineEnd; SelLineSecond = LineStart; } else { SelLineFirst = LineStart; SelLineSecond = LineEnd; } if (SelEnd < SelStart) { SelFirst = SelEnd; SelSecond = SelStart; } else { SelFirst = SelStart; SelSecond = SelEnd; } for (int k = SelFirst; k < SelSecond; k++) { tsWordData = (TSWordData*)tData->ListOfAllLine->Items(k); if (!tsWordData->Selected) continue; tsWordData->HeightGap = (float)hGap / 100; if (tsWordData->Word[0] == '\r') { VectorForm->CaretHeightChange(tData, SelLineFirst); SelLineFirst++; } } VectorForm->CheckNChangeFont(false, tData); if(tsWordData != NULL){ if (tsWordData->Word[0] != '\r') VectorForm->CaretHeightChange(tData, SelLineFirst); } /* text ºí·Ï¼³Á¤ ÈÄ text ¼Ó¼º º¯°æ½Ã ºí·Ï¼³Á¤ ÇØÁ¦µÇÁö ¾Êµµ·Ï Çϱâ À§ÇØ ÁÖ¼®Ã³¸® by G.H. GetTextBoxRect(tData); MakeTextBoxPointList(tData); SetCaretPozByIndex(IndexOfWord); */ // MainImageForm->iMainImage->RectPaint(rect); MainImageForm->iMainImage->Repaint(); END_LOG; } // --------------------------------------------------------------------------- /** ¼±ÅÃµÈ objectÀÇ Antialiasing ¼³Á¤À» º¯°æÇÔ. 2005 Vector Upgrade shin 0315 */ void __fastcall TVecDraw::ChangeAntialiasing() { TList *DataList = NVector->DataList; TVecData *tData; for (int i = 0; i < DataList->Count; i++) { tData = (TVecData*)DataList->Items[i]; if (tData->Equal(MainImageForm->Number) && tData->bSelected) { // tData = (TVecData *)DataList->Items[Index]; if (VectorForm->bAntialiasing) tData->bAntialiasing = true; else tData->bAntialiasing = false; } } } // --------------------------------------------------------------------------- /// ¼±ÅÃµÈ Object°¡ AntialiasingÀÌ Àû¿ëµÇ¾ú´ÂÁö üũ /** // 090811 Áߺ¹ ÁöÁ¤À» À§ÇØ ¼öÁ¤ by david // 00000000 00000000 00000000 00000001 Bit·Î ó¸® * -# Method 00000001(1) : Default * -# Method 00000010(2) : ÇÑ Á¡ÀÌ¶óµµ Area¾È¿¡ Àִ°æ¿ì ÀúÀå * -# Method 00000100(4) : ÇÑ Á¡ÀÌ¶óµµ Area¹Û¿¡ ÀÖÀ¸¸é ÀúÀåÇÏÁö ¾ÊÀ½ * -# Method 00001000(8) : ¼±ÅÃµÈ Object¸¸ ÀúÀåµÊ * -# Method 00010000(16) : Moptive Object ÀúÀåÀ¸·Î ÀÛ¾÷±¸¿ª°ú »ó°ü¾øÀÌ ÀúÀåÇÑ´Ù. * -# Method 00100000(32) : Style Data(Color´Â ºí·¢, ColorFill, Pattern, Gradient Á¦¿Ü Çϰí ÀúÀå) */ bool __fastcall TVecDraw::IsAntialiasing(bool bSelected, bool bWorkArea) { // Antialiasing ÀÎÁö üũ - by monkman (2005.04.21) TList *DataList = NVector->DataList; TVecData *tData; bool bAntialiasing = false; TRect WorkArea; if (bWorkArea && MainImageForm->WorkArea->Mask) { WorkArea = MainImageForm->WorkArea->Range; } for (int i = 0; i < DataList->Count; i++) { tData = (TVecData*)DataList->Items[i]; if (bSelected && !tData->bSelected) continue; if (!tData->Equal(MainImageForm->Number)) continue; if (bWorkArea) { // ÀÛ¾÷±¸¿ª ¹Ù±ù °´Ã¼´Â °É·¯ÁÜ // INRECTMETHOD; // ¿µ¿ª ¾È¿¡ ¾ø´Â°ÍÀº °É·¯³»´Â define // if (!InRectMethod(WorkArea, tData, 4, bWorkArea)) continue; if (!InRectMethod(WorkArea, tData, 8, bWorkArea)) continue; // 090811 by david } if (tData->bAntialiasing) { bAntialiasing = true; return bAntialiasing; } } return bAntialiasing; } // --------------------------------------------------------------------------- /** ¼±ÅÃµÈ Vector dataÀÇ Ææ¸ð¾ç º¯°æ 2005 Vector Upgrade shin 0315 */ void __fastcall TVecDraw::ChangePenShape(bool bMulti, bool bShapeRound) { TList *DataList = NVector->DataList; TVecData *tData; if (DataList->Count == 0) return; if (bMulti) { for (int i = 0; i < DataList->Count; i++) { tData = (TVecData*)DataList->Items[i]; if (tData->Equal(MainImageForm->Number) && tData->bSelected) { tData->bRound = bShapeRound; } } } else { tData = (TVecData*)DataList->Items[Index]; if (tData->Equal(MainImageForm->Number) && tData->bSelected) { tData->bRound = bShapeRound; } } MainImageForm->iMainImage->Repaint(); } // --------------------------------------------------------------------------- /** ÇöÀç ÆÄÀÏ¿¡ »ç¿ëµÈ ÆùÆ®ÀÇ Áö¿ø¿©ºÎ¸¦ üũÇÏ°í º¯°æÇØÁØ´Ù. * ÆÄÀÏÀ» ºÒ·¯¿Ã ¶§ - ¾ø´Â ÆùÆ®ÀÇ °æ¿ì µðÆúÆ® ÆùÆ®·Î º¸ÀÏ °ÍÀÎÁö ¿­Áö ¾ÊÀ» °ÍÀÎÁö µîÀ» user°¡ ¼±ÅÃÇϵµ·Ï ÇÔ. * ÆÄÀÏÀ» ÀúÀåÇÒ ¶§ - ÆÄÀÏ¿¡ »ç¿ëµÈ ÆùÆ®·Î ÀúÀåÇÒ °ÍÀÎÁö, ÇöÀç È­¸é¿¡ º¸ÀÌ´Â ´ë·Î ÀúÀåÇÒ °ÍÀÎÁö¸¦ ¼±ÅÃÇϵµ·Ï ÇÔ. 2005 Vector Upgrade shin 0315 */ bool __fastcall TVecDraw::FontCheckAndChange(bool bSave) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *tData; TSWordData *tsWordData, *newWordData; SIZE size, sz; int FontCount, count = 0, sel; String FontName, OrgFontName; bool matching = false; Char *tempstr = L""; int widthsum = 0, height, length = 0; String strtemp; HDC hdc; Graphics::TBitmap *DefaultBitmap = new Graphics::TBitmap(); DefaultBitmap->PixelFormat = pf24bit; DefaultBitmap->Height = 100; DefaultBitmap->Width = 100; TFont *font = new TFont(); font->Handle = (HFONT)GetStockObject(DEFAULT_GUI_FONT); // ±¼¸² DefaultFontName = ChangeEnglishFontName(font->Name); if (font) { delete font; font = NULL; } NVector->bFontChange = false; for (int i = 0; i < DataList->Count; i++) { tData = (TVecData*)DataList->Items[i]; if (tData->Kind == V_TEXTBOX) { for (int j = 0; j < tData->nCount; j++) { tsWordData = (TSWordData*)tData->ListOfAllLine->Items(j); matching = false; OrgFontName = tsWordData->LFont.lfFaceName; FontCount = MainMenuForm->getVectorFontName->VectorFontName->Count; for (int k = 0; k < FontCount; k++) { FontName = MainMenuForm->getVectorFontName->VectorFontName->Strings [k]; OrgFontName = tsWordData->LFont.lfFaceName; String checkFontName = ChangeEnglishFontName(OrgFontName); if (checkFontName == FontName && !tsWordData->bNameChanged) matching = true; // if (OrgFontName == FontName ) matching = true; } // if (VectorForm->FontNameBox->Items->IndexOf(OrgFontName) < 0) matching = false; if (!matching) { if (!bSave) { // ------------------------------------------ file load if (tsWordData->bNameChanged) { tsWordData->bNameChanged = false; DefaultBitmap->Canvas->Font->Size = tsWordData->LFont.lfHeight; DefaultBitmap->Canvas->Font->Name = tsWordData->LFont.lfFaceName; /* hdc = DefaultBitmap->Canvas->Handle; if (tsWordData->UsedByte == 1) GetTextExtentPoint32(hdc, tsWordData->Word, 1, &size); else GetTextExtentPoint32(hdc, tsWordData->Word, 2, &size); */ /////////////////////// Vista Font¿¡ ´ëÇØ SizeÁ¦´ë·Î ¸ø°¡Á®¿Í¼­ »ý±â´Â ¹®Á¦ ó¸® (2007. 06. 27 Annualring) font = DefaultBitmap->Canvas->Font; font->Name = DefaultBitmap->Canvas->Font->Name; font->Size = DefaultBitmap->Canvas->Font->Size; size = GetVectorTextExtent(DefaultBitmap->Canvas, font, tsWordData); tsWordData->PPoint.x = size.cx; tsWordData->PPoint.y = size.cy; tsWordData->Interval = size.cx * 4 / 5; } else { count++; // ¸Þ½ÃÁö : default font·Î º¸ÀϰÍÀÎÁö ¿©ºÎ if (count == 1) { sel = Application->MessageBox(IDS_MESSAGE005.c_str(), L"Information", MB_YESNO); } if (sel == 6) { // defaultÀΰæ¿ì size´Ù½Ã °è»ê tsWordData->bNameChanged = true; // default font·Î º¯°æÇÔ NVector->bFontChange = true; // º¯°æµÈ ÆùÆ®°¡ ÀÖÀ½ _tcscpy(tsWordData->LFont.lfFaceName, DefaultFontName.c_str()); DefaultBitmap->Canvas->Font->Size = tsWordData->LFont.lfHeight; DefaultBitmap->Canvas->Font->Name = DefaultFontName; /* hdc = DefaultBitmap->Canvas->Handle; if (tsWordData->UsedByte == 1) GetTextExtentPoint32(hdc, tsWordData->Word, 1, &size); else GetTextExtentPoint32(hdc, tsWordData->Word, 2, &size); */ /////////////////////// Vista Font¿¡ ´ëÇØ SizeÁ¦´ë·Î ¸ø°¡Á®¿Í¼­ »ý±â´Â ¹®Á¦ ó¸® (2007. 06. 27 Annualring) // size = GetVectorTextExtent(MainImageForm->iMainImage->Canvas, font, tsWordData); // font°¡ deleteµÈ »óÅ·ΠÁøÇàµÇ¾î access°¡ ¹ß»ýÇß´Ù. ±×·¡¼­ ¾Æ·¡¿Í °°ÀÌ ¼öÁ¤ by david 081020 font = DefaultBitmap->Canvas->Font; font->Name = DefaultBitmap->Canvas->Font->Name; font->Size = DefaultBitmap->Canvas->Font->Size; size = GetVectorTextExtent(DefaultBitmap->Canvas, font, tsWordData); tsWordData->PPoint.x = size.cx; tsWordData->PPoint.y = size.cy; tsWordData->Interval = size.cx * 4 / 5; } else if (sel == 7) { END_LOG; return false; } } } else { // ------------------------------------------ file save count++; if (count == 1) { // ¸Þ½ÃÁö : ÇöÀç º¸¿©Áö´Â ÆùÆ®·Î ÀúÀå or ¿ø·¡ ÆùÆ®·Î ÀúÀå sel = Application->MessageBox(IDS_MESSAGE006.c_str(), L"Information", MB_YESNO); } if (sel == 6) { // ÇöÀç default ÆùÆ®·Î ÀúÀå : tsWordData->LFont.lfFaceNameÀ» default ÆùÆ®¸íÀ¸·Î º¯°æ _tcscpy(tsWordData->LFont.lfFaceName, DefaultFontName.c_str()); tsWordData->bNameChanged = false; NVector->bFontChange = false; } else if (sel == 7) { // ¿ø·¡ ÆùÆ®·Î ÀúÀå : ÆùÆ®¸íÀÌ º¯°æµÇ¾úÀ½ bNameChanged = true tsWordData->bNameChanged = true; } } } } GetTextBoxRect(tData); MakeTextBoxPointList(tData); } } if (DefaultBitmap) { delete DefaultBitmap; DefaultBitmap = NULL; } END_LOG; return true; } // --------------------------------------------------------------------------- /** User°¡ ÀÔ·ÂÇØ¼­ ¸¸µå´Â object¸¦ ±×·ÁÁØ´Ù. 2005 Vector Upgrade shin 0315 */ void __fastcall TVecDraw::DrawUserObject(HDC dcDst, int px, int py) { int ZoomIn = MainImageForm->iMainImage->ZoomIn; int ZoomOut = MainImageForm->iMainImage->ZoomOut; int PositionX = MainImageForm->iMainImage->PositionX; int PositionY = MainImageForm->iMainImage->PositionY; int Lex = ((NVector->Lex) - PositionX) * ZoomIn / ZoomOut - px; int Ley = ((NVector->Ley) - PositionY) * ZoomIn / ZoomOut - py; int Lsx = ((NVector->Lsx) - PositionX) * ZoomIn / ZoomOut - px; int Lsy = ((NVector->Lsy) - PositionY) * ZoomIn / ZoomOut - py; int Cux = ((NVector->Cux) - PositionX) * ZoomIn / ZoomOut - px; int Cuy = ((NVector->Cuy) - PositionY) * ZoomIn / ZoomOut - py; gdp::Rect rect; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.06.14) gdp::Rect ReflectionRect; int ReflectionIndex = -1; if (NVector->bVectorReflectionMode && ((NVector->ReflectionVH == 1 && NVector->ReflectionVIndex >= 0) || (NVector->ReflectionVH == 2 && NVector->ReflectionHIndex >= 0))) { // ¼öÁ÷ ±âÁؼ± if (NVector->ReflectionVH == 1) ReflectionIndex = (NVector->ReflectionVIndex - PositionX) * ZoomIn / ZoomOut - px; // ¼öÆò ±âÁؼ± if (NVector->ReflectionVH == 2) ReflectionIndex = (NVector->ReflectionHIndex - PositionY) * ZoomIn / ZoomOut - py; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- if (VectorForm->V_Item != M_D_LINE && VectorForm->V_Item != M_D_CURVE) VectorForm->CalculateObject(rect, px, py, true); gdp::Graphics graphics(dcDst); // graphics.SetSmoothingMode(gdp::SmoothingModeHighQuality); // antialiasing gdp::Color penColor(GetRValue(PenManagerForm->PenShape->Pen->Color), GetGValue(PenManagerForm->PenShape->Pen->Color), GetBValue(PenManagerForm->PenShape->Pen->Color)); gdp::Color pathColor(GetRValue(PathColor), GetGValue(PathColor), GetBValue(PathColor)); gdp::Pen ObjectPen(penColor, VectorForm->DrawingThick * ZoomIn / ZoomOut); gdp::Pen pathPen(pathColor, 1); int penstyle = VectorForm->PenStyle; // 0303 shin // if (!IsFloat(VectorForm->VectorPenComboBox->Text)) return; double thick = 0; // thick = StrToFloat(VectorForm->VectorPenComboBox->Text); if (!TryStrToFloat(VectorForm->PenComboBox->Text, thick)) thick = 1; float *dashValues = NULL; int count = 0; if (penstyle == P_USERSTYLE) { if (dashcount == 2) { count = 2; dashValues = new float[count]; dashValues[0] = dset[0] / thick; dashValues[1] = dset[1] / thick; } else if (dashcount == 4) { if ((dset[0] > 0) && (dset[1] > 0) && (dset[2] > 0) && (dset[3] > 0)) { count = 4; dashValues = new float[count]; dashValues[0] = dset[0] / thick; dashValues[1] = dset[1] / thick; dashValues[2] = dset[2] / thick; dashValues[3] = dset[3] / thick; } else { count = 2; dashValues = new float[count]; dashValues[0] = dset[0] / thick + dset[2] / thick; dashValues[1] = dset[1] / thick + dset[3] / thick; } } else if (dashcount == 6) { if ((dset[0] > 0) && (dset[1] > 0) && (dset[2] > 0) && (dset[3] > 0) && (dset[4] > 0) && (dset[5] > 0)) { count = 6; dashValues = new float[count]; dashValues[0] = dset[0] / thick; dashValues[1] = dset[1] / thick; dashValues[2] = dset[2] / thick; dashValues[3] = dset[3] / thick; dashValues[4] = dset[4] / thick; dashValues[5] = dset[5] / thick; } else { if ((dset[0] > 0) && (dset[1] > 0)) { if (((dset[2] > 0) && (dset[3] > 0)) && ((dset[4] <= 0) || (dset[5] <= 0))) { count = 4; dashValues = new float[count]; dashValues[0] = dset[0] / thick; dashValues[1] = dset[1] / thick; if (dset[4] <= 0) { dashValues[2] = dset[2] / thick; dashValues[3] = dset[3] / thick + dset[5] / thick; } else { dashValues[2] = dset[2] / thick; dashValues[3] = dset[3] / thick; dashValues[0] += dset[4] / thick; } } else if (((dset[2] <= 0) || (dset[3] <= 0)) && ((dset[4] <= 0) || (dset[5] <= 0))) { count = 2; dashValues = new float[count]; dashValues[0] = dset[0] / thick + dset[3] / thick + dset[4] / thick; dashValues[1] = dset[1] / thick + dset[3] / thick + dset[5] / thick; } else { if (dset[2] <= 0) { count = 4; dashValues = new float[count]; dashValues[0] = dset[0] / thick; dashValues[1] = dset[1] / thick + dset[3] / thick; dashValues[2] = dset[4] / thick; dashValues[3] = dset[5] / thick; } else { count = 4; dashValues = new float[count]; dashValues[0] = dset[0] / thick; dashValues[1] = dset[1] / thick; dashValues[2] = dset[2] / thick + dset[4] / thick; dashValues[3] = dset[5] / thick; } } } else { if ((dset[2] > 0) && (dset[3] > 0) && (dset[4] > 0) && (dset[5] > 0)) { count = 4; dashValues = new float[count]; if (dset[0] <= 0) { dashValues[0] = dset[2] / thick; dashValues[1] = dset[3] / thick; dashValues[2] = dset[4] / thick; dashValues[3] = dset[5] / thick + dset[1] / thick; } else { dashValues[0] = dset[0] / thick + dset[2] / thick; dashValues[1] = dset[3] / thick; dashValues[2] = dset[4] / thick; dashValues[3] = dset[5] / thick; } } else { count = 2; dashValues = new float[count]; dashValues[0] = dset[0] / thick + dset[2] / thick + dset[4] / thick; dashValues[1] = dset[1] / thick + dset[3] / thick + dset[5] / thick; } } } } ObjectPen.SetDashPattern(dashValues, count); } if (!PenManagerForm->Pen->Shape) { if ((VectorForm->CapStyle[0] == 1) && (NVector->bFstLine)) ObjectPen.SetStartCap(gdp::LineCapArrowAnchor); else ObjectPen.SetStartCap(gdp::LineCapRound); ObjectPen.SetEndCap(gdp::LineCapRound); ObjectPen.SetLineJoin(gdp::LineJoinRound); ObjectPen.SetDashStyle((gdp::DashStyle)penstyle); ObjectPen.SetDashCap(gdp::DashCapRound); } else { if ((VectorForm->CapStyle[0] == 1) && (NVector->bFstLine)) ObjectPen.SetStartCap(gdp::LineCapArrowAnchor); else ObjectPen.SetStartCap(gdp::LineCapFlat); ObjectPen.SetEndCap(gdp::LineCapFlat); ObjectPen.SetLineJoin(gdp::LineJoinMiter); ObjectPen.SetDashStyle((gdp::DashStyle)penstyle); ObjectPen.SetDashCap(gdp::DashCapFlat); } // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.06.14) if (NVector->bVectorReflectionMode) { if (NVector->ReflectionVH == 1) { // ¼öÁ÷ ±âÁؼ± ReflectionRect.X = ReflectionIndex * 2 - rect.X - rect.Width; ReflectionRect.Y = rect.Y; ReflectionRect.Width = rect.Width; ReflectionRect.Height = rect.Height; } if (NVector->ReflectionVH == 2) { // ¼öÆò ±âÁؼ± ReflectionRect.X = rect.X; ReflectionRect.Y = ReflectionIndex * 2 - rect.Y - rect.Height; ReflectionRect.Width = rect.Width; ReflectionRect.Height = rect.Height; } } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // int Lsx, Lsy, Lex, Ley, Cux, Cuy; switch(VectorForm->V_Item) { case M_D_LINE: // Line // lx = rect.X; // ly = rect.Y; if (NVector->step != 0) { graphics.DrawLine(&ObjectPen, Lsx, Lsy, Lex, Ley); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.06.14) if (NVector->bVectorReflectionMode) { if (NVector->ReflectionVH == 1) { // ¼öÁ÷ ±âÁؼ± graphics.DrawLine(&ObjectPen, ReflectionIndex * 2 - Lsx, Lsy, ReflectionIndex * 2 - Lex, Ley); } if (NVector->ReflectionVH == 2) { // ¼öÆò ±âÁؼ± graphics.DrawLine(&ObjectPen, Lsx, ReflectionIndex * 2 - Lsy, Lex, ReflectionIndex * 2 - Ley); } } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } break; case M_D_CURVE: // Curve if (NVector->step != 0) { graphics.DrawLine(&ObjectPen, Lsx, Lsy, Lex, Ley); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.06.14) if (NVector->bVectorReflectionMode) { if (NVector->ReflectionVH == 1) { // ¼öÁ÷ ±âÁؼ± graphics.DrawLine(&ObjectPen, ReflectionIndex * 2 - Lsx, Lsy, ReflectionIndex * 2 - Lex, Ley); } if (NVector->ReflectionVH == 2) { // ¼öÆò ±âÁؼ± graphics.DrawLine(&ObjectPen, Lsx, ReflectionIndex * 2 - Lsy, Lex, ReflectionIndex * 2 - Ley); } } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } break; case M_D_SQUARE: // Square if (NVector->bUserLength1) { graphics.DrawRectangle(&ObjectPen, rect); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.06.14) if (NVector->bVectorReflectionMode) { graphics.DrawRectangle(&ObjectPen, ReflectionRect); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } break; case M_D_RECT: // Rectangle if (NVector->bUserLength1 && NVector->bUserLength2) { graphics.DrawRectangle(&ObjectPen, rect); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.06.14) if (NVector->bVectorReflectionMode) { graphics.DrawRectangle(&ObjectPen, ReflectionRect); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } break; case M_D_CIRCLE: // Circle if (NVector->bUserLength1) { graphics.DrawEllipse(&ObjectPen, rect); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.06.14) if (NVector->bVectorReflectionMode) { graphics.DrawEllipse(&ObjectPen, ReflectionRect); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } break; case M_D_ELLIPSE: // Ellipse if (NVector->bUserLength1 && NVector->bUserLength2) { graphics.DrawEllipse(&ObjectPen, rect); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - º¤Å͸¦ ±×¸±¶§ °°ÀÌ ±×·ÁÁØ´Ù - by monkman(2005.06.14) if (NVector->bVectorReflectionMode) { graphics.DrawEllipse(&ObjectPen, ReflectionRect); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } break; } if (dashValues) delete[]dashValues; dashValues = NULL; } // --------------------------------------------------------------------------- // 2005 Vector Upgrade shin 0317 /// User input data¸¦ À§ÇÑ À§Ä¡ µîÀÇ °è»ê void __fastcall TVecDraw::CalculateObject(gdp::Rect &rect, int px, int py, bool bView) { BEGIN_LOG(""); int ZoomIn = MainImageForm->iMainImage->ZoomIn; int ZoomOut = MainImageForm->iMainImage->ZoomOut; int PositionX = MainImageForm->iMainImage->PositionX; int PositionY = MainImageForm->iMainImage->PositionY; int Lex, Ley, Lsx, Lsy, Cux, Cuy; if (!bView) { Cux = (NVector->Cux); Cuy = (NVector->Cuy); } else { Cux = ((NVector->Cux) - PositionX) * ZoomIn / ZoomOut - px; Cuy = ((NVector->Cuy) - PositionY) * ZoomIn / ZoomOut - py; } int i, j, count = 0; double UserData1 = 0, UserData2 = 0; double dTemp = 0; if (NVector->bUserLength1) { UserData1 = VectorForm->eData1->Value; } if (NVector->bUserLength2) { UserData2 = VectorForm->eData2->Value; } switch(MainImageForm->CurrentUnit) { case uDot: break; case uInch: UserData1 = UserData1 * MainImageForm->CanvasInfor.DotsPerInch; if (VectorForm->V_Item != M_D_LINE || VectorForm->V_Item != M_D_CURVE) UserData2 = UserData2 * MainImageForm->CanvasInfor.DotsPerInch; break; case uCm: UserData1 = UserData1 * MainImageForm->CanvasInfor.DotsPerInch / 2.54; if (VectorForm->V_Item != M_D_LINE || VectorForm->V_Item != M_D_CURVE) UserData2 = UserData2 * MainImageForm->CanvasInfor.DotsPerInch / 2.54; break; } if (UserData1 && bView) UserData1 = UserData1 * ZoomIn / ZoomOut; if (UserData2 && bView) UserData2 = UserData2 * ZoomIn / ZoomOut; int calx, caly, calLength, dx, dy; switch(VectorForm->V_Item) { case M_D_LINE: // Line calx = Cux - (NVector->Lsx); caly = Cuy - (NVector->Lsy); calLength = sqrt(calx * calx + caly * caly); if (calLength < UserData1) { rect.X = Cux; rect.Y = Cuy; } else { dx = (NVector->Lsx) + UserData1 / calLength * calx; dy = (NVector->Lsx) + UserData1 / calLength * caly; rect.X = dx; rect.Y = dy; } break; case M_D_CURVE: // Curve break; case M_D_SQUARE: // Square if (NVector->bUserLength1) { Lsx = Cux - UserData1 / 2; Lex = Lsx + UserData1; Lsy = Cuy - UserData1 / 2; Ley = Cuy + UserData1; rect.X = Lsx; rect.Y = Lsy; rect.Width = UserData1; rect.Height = UserData1; } break; case M_D_RECT: // Rectangle if (NVector->bUserLength1 && NVector->bUserLength2) { Lsx = Cux - UserData1 / 2; Lex = Lsx + UserData1; Lsy = Cuy - UserData2 / 2; Ley = Cuy + UserData2; rect.X = Lsx; rect.Y = Lsy; rect.Width = UserData1; rect.Height = UserData2; } break; case M_D_CIRCLE: // Circle if (NVector->bUserLength1) { double ra = UserData1; rect.X = Cux - ra; rect.Y = Cuy - ra; rect.Width = ra * 2; rect.Height = ra * 2; } break; case M_D_ELLIPSE: // Ellipse if (NVector->bUserLength1 && NVector->bUserLength2) { Lsx = Cux - UserData1 / 2; Lsy = Cuy - UserData2 / 2; Lex = Lsx + UserData1; Ley = Cuy + UserData2; rect.X = Lsx; rect.Y = Lsy; rect.Width = UserData1; rect.Height = UserData2; } break; } END_LOG; } // --------------------------------------------------------------------------- /** ÇöÀç ±×¸®°í ÀÖ´Â objectÀÇ Ã¹Á¡°ú ³¡Á¡ ÀÕ±â 2005 Vector Upgrade shin 0315 */ void __fastcall TVecDraw::JoinFirstPoint() { TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) RECT rect; // °î¼± ±×¸®´Â Áß¿¡ ùÁ¡À¸·Î Çϸé ÀÌÀü ¿ÀºêÁ§Æ®ÀÇ °î¼±ÀÌ Ã¹Á¡À¸·Î °¡´Â ¿¡·¯ ¼öÁ¤ - by monkman (2012.01.16) if (DataList->Count < 1 || (VectorForm->V_Item == M_D_CURVE && NVector->step == 2)) return; BEGIN_LOG(""); data = (TVecData*)DataList->Items[DataList->Count - 1]; // if (!data->Equal(MainImageForm->Number)) continue; // if (data->bLocked) {data->bSelected = false; continue;} // if (data->bClosed) continue; // if (data->Kind == V_TEXTBOX) continue; if (data->Kind != V_TEXTBOX && data->ParentTextBox == NULL) { // if (!Shift.Contains(ssShift) && !Shift.Contains(ssAlt)) data->bSelected = false; 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] = data->pList[(data->nCount - 1) * 3]; data->pList[data->nCount * 3 - 1] = data->pList[0]; data->pList[data->nCount * 3] = data->pList[0]; data->bClosed = true; } // --------> 2005 Vector upgrade // Color fill ¼³Á¤ 20050225 shin if (VectorForm->cbFill->Visible && VectorForm->cbFill->Checked) { data->bFill = true; data->Brush = PenManagerForm->PenShape->Pen->Color; } else data->bFill = false; // ------------------------< NVector->step = 0; NVector->bFstLine = true; bJoinState = false; // stepÀÌ 0 À̸é ÃʱâÈ­ ÇØÁØ´Ù - by monkman (2009.11.26) NVector->bVectorMove = false; MainImageForm->iMainImage->Cursor = crDefault; MainImageForm->iMainImage->Repaint(); END_LOG; } // --------------------------------------------------------------------------- /** Vector dataÀÇ Line ¼Ó¼º¿¡ µû¶ó Dash ¶Ç´Â Dot PatternÀ» ¹è¿­(set)¿¡ ´ã´Â´Ù. 2005 Vector Upgrade shin 0315 */ void __fastcall TVecDraw::GetDashPattern(TVecData *data) { int style = data->PenStyle; double thick = data->PenThick; // if (style != 5) data->DashValues[6] = {0,0,0,0,0,0}; switch(style) { case 0: // solid break; case 1: // dash set[0] = data->PenThick * 3; set[1] = data->PenThick; break; case 2: // dot set[0] = data->PenThick; set[1] = data->PenThick; break; case 3: // dashdot set[0] = data->PenThick * 3; set[1] = data->PenThick; set[2] = data->PenThick; set[3] = data->PenThick; break; case 4: // dashdotdot set[0] = data->PenThick * 3; set[1] = data->PenThick; set[2] = data->PenThick; set[3] = data->PenThick; set[4] = data->PenThick; set[5] = data->PenThick; break; case 5: // custom set[0] = data->DashValues[1] * thick; set[1] = data->DashValues[2] * thick; set[2] = data->DashValues[3] * thick; set[3] = data->DashValues[4] * thick; set[4] = data->DashValues[5] * thick; set[5] = data->DashValues[6] * thick; break; } } // --------------------------------------------------------------------------- /** Dashed line ¼³Á¤ 2005 Vector Upgrade shin 0315 */ void __fastcall TVecDraw::SetUserDashStyle(int num) { TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; data->PenStyle = P_USERSTYLE; double thick = data->PenThick; float *dashVals; switch(num) { case 2: data->DashValues[0] = 2; data->DashValues[1] = set[0] / thick; data->DashValues[2] = set[1] / thick; break; case 4: data->DashValues[0] = 4; data->DashValues[1] = set[0] / thick; data->DashValues[2] = set[1] / thick; data->DashValues[3] = set[2] / thick; data->DashValues[4] = set[3] / thick; break; case 6: data->DashValues[0] = 6; data->DashValues[1] = set[0] / thick; data->DashValues[2] = set[1] / thick; data->DashValues[3] = set[2] / thick; data->DashValues[4] = set[3] / thick; data->DashValues[5] = set[4] / thick; data->DashValues[6] = set[5] / thick; break; } } MainImageForm->iMainImage->Repaint(); } // --------------------------------------------------------------------------- /** ¿µ¿ª¾È¿¡ Vector data°¡ ÀÖ´ÂÁö ¾ø´ÂÁö ÆÇº°. 2005 Vector Upgrade shin 0315 : Define -> function // 090811 Áߺ¹ ÁöÁ¤À» À§ÇØ ¼öÁ¤ by david // 00000000 00000000 00000000 00000001 Bit·Î ó¸® * -# Method 00000001(1) : Default * -# Method 00000010(2) : ÇÑ Á¡ÀÌ¶óµµ Area¾È¿¡ Àִ°æ¿ì ÀúÀå * -# Method 00000100(4) : ÇÑ Á¡ÀÌ¶óµµ Area¹Û¿¡ ÀÖÀ¸¸é ÀúÀåÇÏÁö ¾ÊÀ½ * -# Method 00001000(8) : ¼±ÅÃµÈ Object¸¸ ÀúÀåµÊ * -# Method 00010000(16) : Moptive Object ÀúÀåÀ¸·Î ÀÛ¾÷±¸¿ª°ú »ó°ü¾øÀÌ ÀúÀåÇÑ´Ù. * -# Method 00100000(32) : Style Data(Color´Â ºí·¢, ColorFill, Pattern, Gradient Á¦¿Ü Çϰí ÀúÀå) */ bool __fastcall TVecDraw::InRectMethod(TRect &Src, TVecData *data, int method, bool bRange) { BEGIN_LOG(""); int nMotiveLength = 0; double nDistance = 0; // if (method == 2 && bRange) { if (method & 2 && bRange) { bool bInRect = false; if (data->Kind == V_LINE || data->Kind == V_CURVE) { for (int k = 0; k < data->nCount * 3 + 1; k += 3) { if (PtInRect(&Src, data->pList[k].P())) bInRect = true; if (bInRect == false && data->bMotive) { // Motive ÀÏ °æ¿ì °è»ê - by monkman (2009.04.16) data->SetRect(); CalculateChild(data); nMotiveLength = data->childwidth > data->childheight ? data->childwidth : data->childheight; nDistance = PointOnCurvePath(data, Src.left + (Src.right - Src.left) / 2, Src.top + (Src.bottom - Src.top) / 2); if ((nDistance >= 0) && (nDistance < nMotiveLength)) bInRect = true; } } } else if (data->Kind == V_TEXTBOX && !(data->ListOfAllLine->CurveData)) { if (PtInRect(&Src, data->First) || PtInRect(&Src, data->Second) || PtInRect(&Src, Point(data->First.x, data->Second.y)) || PtInRect(&Src, Point(data->Second.x, data->First.y))) bInRect = true; } // ÀÛ¾÷±¸¿ªÀ» ¼³Á¤Çϰí ÀúÀå ½Ã CurvedTextµµ ÀúÀåµÇµµ·Ï ¼öÁ¤ - by monkman (2006.08.17) if (data->ListOfAllLine && data->ListOfAllLine->CurveData) { TVecData *CurveData = data->ListOfAllLine->CurveData; for (int k = 0; k < CurveData->nCount * 3 + 1; k += 3) { if (PtInRect(&Src, CurveData->pList[k].P())) bInRect = true; } } if (!bInRect) { END_LOG; return false; } } // if (method == 3 && bRange) { if (method & 4 && bRange) { bool bInRect = true; if (data->Kind == V_LINE || data->Kind == V_CURVE) { for (int k = 0; k < data->nCount * 3 + 1; k += 3) { if (!PtInRect(&Src, data->pList[k].P())) bInRect = false; } } else if (data->Kind == V_TEXTBOX && !(data->ListOfAllLine->CurveData)) { if (!(PtInRect(&Src, data->First) && PtInRect(&Src, data->Second) && PtInRect(&Src, Point(data->First.x, data->Second.y)) && PtInRect(&Src, Point(data->Second.x, data->First.y)))) bInRect = false; } // ÀÛ¾÷±¸¿ªÀ» ¼³Á¤Çϰí ÀúÀå ½Ã CurvedTextµµ ÀúÀåµÇµµ·Ï ¼öÁ¤ - by monkman (2006.08.17) if (data->ListOfAllLine && data->ListOfAllLine->CurveData) { TVecData *CurveData = data->ListOfAllLine->CurveData; for (int k = 0; k < CurveData->nCount * 3 + 1; k += 3) { if (!PtInRect(&Src, data->pList[k].P())) bInRect = false; } } if (!bInRect) { END_LOG; return false; } } END_LOG; return true; } // --------------------------------------------------------------------------- /** ÇöÀç ÁÂÇ¥¿¡¼­ÀÇ Vector data(Text, Curved text Data)ÀÇ Color¸¦ ¹ÝȯÇÑ´Ù 2005 Vector Upgrade shin 0315 */ TColor __fastcall TVecDraw::GetCharacterColor(TVecData *tData, int X, int Y) { BEGIN_LOG(""); TColor CharacterColor; int fontSize; TSWordData *tsWordData; int tLine = 0, line; RECT CharRect; TPoint point, Anglepoint; double StartX, StartY, CenterX, CenterY; double realCharX, realCharY, tempX, tempY; int ZoomIn = MainImageForm->iMainImage->ZoomIn; int ZoomOut = MainImageForm->iMainImage->ZoomOut; int PositionX = MainImageForm->sbHorz->Position; int PositionY = MainImageForm->sbVert->Position; double FontZoom = (double)ZoomIn / ZoomOut; // Curved text double angle; double OriginX, OriginY; double tempCenterX, tempCenterY; float cellascent, emHeight, ascent; float fontsize; float leftInterval; Char fname[100], wordBstr[100]; String tempString; /* HDC dcDst = (HDC) MainImageForm->iMainImage->Canvas->Handle; gdp::Graphics graphics(dcDst); // using GDI+ CharacterColor = (TColor)MainImageForm->iMainImage->uBitmap->GetPixelColor(X, Y); if (!tData->ListOfAllLine->CurveData) { StartX = (tData->StartPoint.x - PositionX) * ZoomIn / ZoomOut; StartY = (tData->StartPoint.y - PositionY) * ZoomIn / ZoomOut; CenterX = (tData->CenterPoint.x - PositionX) * ZoomIn / ZoomOut; CenterY = (tData->CenterPoint.y - PositionY) * ZoomIn / ZoomOut; realCharX = StartX; realCharY = StartY; point.x = (X - PositionX)* ZoomIn / ZoomOut; point.y = (Y - PositionY)* ZoomIn / ZoomOut; line = (tData->ListOfAllLine->GetLineTextBox(0))->lineHeight; tempY = ((line) * 0.8) * FontZoom; } else { point.x = X; point.y = Y; } for (int k = 0; k < tData->nCount; k++) { tsWordData = (TSWordData *)tData->ListOfAllLine->Items(k); if (tData->ListOfAllLine->CurveData) { fontSize = tsWordData->LFont.lfHeight; tsWordData->LFont.lfHeight = fontSize; if (!tsWordData->bNameChanged) tempString = tsWordData->LFont.lfFaceName; else tempString = DefaultFontName; ZeroMemory(fname, sizeof(fname)); MultiByteToWideChar(CP_ACP, 0, tempString.c_str(), tempString.Length(), fname, sizeof(fname) / sizeof(fname[0])); gdp::Font font(dcDst, &tsWordData->LFont); gdp::FontFamily fontFamily(fname); cellascent = fontFamily.GetCellAscent(gdp::FontStyleRegular); emHeight = fontFamily.GetEmHeight(gdp::FontStyleRegular); ZeroMemory(wordBstr, sizeof(wordBstr)); if (tsWordData->UsedByte == 1){ MultiByteToWideChar(CP_ACP, 0, tsWordData->Word, 1, wordBstr, sizeof(wordBstr) / sizeof(wordBstr[0])); } else { MultiByteToWideChar(CP_ACP, 0, tsWordData->Word, 2, wordBstr, sizeof(wordBstr) / sizeof(wordBstr[0])); } if (emHeight) ascent = font.GetSize()*cellascent/emHeight; else { font.GetFamily(&fontFamily); cellascent = fontFamily.GetCellAscent(gdp::FontStyleRegular); emHeight = fontFamily.GetEmHeight(gdp::FontStyleRegular); if (emHeight) ascent = font.GetSize()*cellascent/emHeight; else ascent = font.GetHeight(&graphics); } fontsize = font.GetSize(); leftInterval = fontsize*0.17; if(tsWordData->bVisible) { OriginX = tsWordData->px - tsWordData->Interval * tsWordData->WidthGap / 2; OriginY = tsWordData->py - ascent; tempCenterX = tsWordData->px; tempCenterY = tsWordData->py; angle = acos(tsWordData->tx); if(tsWordData->ty >= 0){ angle = 180*angle/M_PI; }else{ angle = 360 - 180*angle/M_PI; } CharRect = TRect((int)OriginX, (int)OriginY, (int)(OriginX + tsWordData->Interval * tsWordData->WidthGap), (int)(OriginY + ascent)); //ȸÀüÇßÀ» ¶§´Â RectÀÇ Point¸¦ º¯È¯Çϰųª point¸¦ º¯È¯ (point¸¦ º¯È¯ÇßÀ½) if (angle) { gdp::Matrix matrix; gdp::PointF sp((float)point.x, (float)point.y); gdp::PointF sp2((float)tempCenterX, (float)tempCenterY); gdp::PointF points[2] = {sp, sp2}; matrix.RotateAt(-angle, gdp::PointF(tempCenterX, tempCenterY), gdp::MatrixOrderAppend); matrix.TransformPoints(points, 2); Anglepoint.x = points[0].X; Anglepoint.y = points[0].Y; matrix.Reset(); if(PtInRect(&CharRect, Anglepoint)){ CharacterColor = tsWordData->Color; tsWordData->LFont.lfHeight = fontSize; break; } } else { if(PtInRect(&CharRect, point)){ CharacterColor = tsWordData->Color; tsWordData->LFont.lfHeight = fontSize; break; } } } } else { fontSize = tsWordData->LFont.lfHeight; tsWordData->LFont.lfHeight = fontSize * FontZoom; if (tsWordData->Word[0] == '\r') { tLine++; line = (tData->ListOfAllLine->GetLineTextBox(tLine))->lineHeight; realCharX = StartX; tempY = ((line) * 0.8 * tsWordData->HeightGap) * FontZoom; realCharY += tempY; } else { tempX = realCharX; realCharX += tsWordData->Interval * tsWordData->WidthGap * FontZoom; CharRect = Rect(tempX, realCharY - fontSize*FontZoom, tempX + tsWordData->Interval*FontZoom, realCharY); //ȸÀüÇßÀ» ¶§´Â RectÀÇ Point¸¦ º¯È¯Çϰųª point¸¦ º¯È¯ if (tData->TextAngle){ gdp::Graphics graphics(MainImageForm->iMainImage->Canvas->Handle); gdp::Matrix matrix; gdp::PointF sp(point.x, point.y); gdp::PointF sp2(CenterX, CenterY); gdp::PointF points[2] = {sp, sp2}; matrix.RotateAt(tData->TextAngle, gdp::PointF(CenterX, CenterY), gdp::MatrixOrderAppend); matrix.TransformPoints(points, 2); Anglepoint.x = points[0].X; Anglepoint.y = points[0].Y; matrix.Reset(); if(PtInRect(&CharRect, Anglepoint)){ CharacterColor = tsWordData->Color; tsWordData->LFont.lfHeight = fontSize; break; } } else { if(PtInRect(&CharRect, point)){ CharacterColor = tsWordData->Color; tsWordData->LFont.lfHeight = fontSize; break; } } } } tsWordData->LFont.lfHeight = fontSize; } END_LOG; */ return CharacterColor; } // --------------------------------------------------------------------------- /// User dashed lineÀÇ µ¥ÀÌÅÍ Ã¼Å© ¹× ¼³Á¤ void __fastcall TVecDraw::CheckUserDashedLine(TVecData *data, double *temp, int &tempcount) { int count = data->DashValues[0]; // double temp[6]; switch(count) { case 2: temp[0] = data->DashValues[1]; temp[1] = data->DashValues[2]; tempcount = 2; break; case 4: if (data->DashValues[1] != 0 && data->DashValues[2] != 0) { if (data->DashValues[3] != 0 && data->DashValues[4] != 0) { temp[0] = data->DashValues[1]; temp[1] = data->DashValues[2]; temp[2] = data->DashValues[3]; temp[3] = data->DashValues[4]; tempcount = 4; } else { temp[0] = data->DashValues[1] + data->DashValues[3]; temp[1] = data->DashValues[2] + data->DashValues[4]; tempcount = 2; } } else { temp[0] = data->DashValues[1] + data->DashValues[3]; temp[1] = data->DashValues[2] + data->DashValues[4]; tempcount = 2; } break; case 6: if (data->DashValues[1] != 0 && data->DashValues[2] != 0) { if (data->DashValues[3] != 0 && data->DashValues[4] != 0) { temp[0] = data->DashValues[1]; temp[1] = data->DashValues[2]; temp[2] = data->DashValues[3]; temp[3] = data->DashValues[4]; if (data->DashValues[5] != 0 && data->DashValues[6] != 0) { temp[4] = data->DashValues[5]; temp[5] = data->DashValues[6]; tempcount = 6; } else { temp[2] += data->DashValues[5]; temp[3] += data->DashValues[6]; tempcount = 4; } } else { temp[0] = data->DashValues[1]; temp[1] = data->DashValues[2]; if (data->DashValues[3] != 0) { temp[2] = data->DashValues[3]; temp[3] = data->DashValues[4]; if (data->DashValues[5] != 0 && data->DashValues[6] != 0) { temp[2] += data->DashValues[5]; temp[3] += data->DashValues[6]; tempcount = 4; } else { temp[0] = data->DashValues[1] + data->DashValues[3] + data->DashValues[6]; temp[1] = data->DashValues[2] + data->DashValues[4] + data->DashValues[5]; tempcount = 2; } } else { temp[1] += data->DashValues[4]; if (data->DashValues[5] != 0 && data->DashValues[6] != 0) { temp[2] = data->DashValues[5]; temp[3] = data->DashValues[6]; tempcount = 4; } else { temp[0] += data->DashValues[5]; temp[1] += data->DashValues[6]; tempcount = 2; } } } } else { if (data->DashValues[3] != 0 && data->DashValues[4] != 0) { temp[0] = data->DashValues[1] + data->DashValues[3]; temp[1] = data->DashValues[2] + data->DashValues[4]; if (data->DashValues[5] != 0 && data->DashValues[6] != 0) { temp[2] = data->DashValues[5]; temp[3] = data->DashValues[6]; tempcount = 4; } else { temp[0] += data->DashValues[5]; temp[1] += data->DashValues[6]; tempcount = 2; } } else { temp[0] = data->DashValues[1] + data->DashValues[3] + data->DashValues [5]; temp[1] = data->DashValues[2] + data->DashValues[4] + data->DashValues [6]; tempcount = 2; } } break; } } // --------------------------------------------------------------------------- /// Vista Font¿¡ ´ëÇØ SizeÁ¦´ë·Î ¸ø°¡Á®¿Í¼­ »ý±â´Â ¹®Á¦ ó¸® (2007. 06. 27 Annualring) String __fastcall TVecDraw::GetFamilyFontName(String currentFontName, HDC hdc) { /* °íÄ¥°Í BEGIN_LOG(""); Char fname[100]; ZeroMemory(fname, sizeof(fname)); String fontName = currentFontName; MultiByteToWideChar(CP_ACP, 0, fontName.c_str(), fontName.Length(), fname, sizeof(fname) / sizeof(fname[0])); gdp::FontFamily fontFamily(fname); float emHeight = fontFamily.GetEmHeight(gdp::FontStyleRegular); gdp::Font font(fname, 10); gdp::Graphics graphics(hdc); LOGFONTA logFont; if (emHeight == 0){ font.GetFamily(&fontFamily); gdp::Font familyFont(&fontFamily, 10); // Get attributes of myFont. familyFont.GetLogFontA(&graphics, &logFont); String newFontName = logFont.lfFaceName; END_LOG; return newFontName; } else { END_LOG; return currentFontName; } */ } // --------------------------------------------------------------------------- /// Vista Font¿¡ ´ëÇØ SizeÁ¦´ë·Î ¸ø°¡Á®¿Í¼­ »ý±â´Â ¹®Á¦ ó¸® (2007. 06. 27 Annualring) SIZE __fastcall TVecDraw::GetVectorTextExtent(TCanvas *canvas, TFont *font, TSWordData *tsWordData, int usedByte) { HDC hdc = canvas->Handle; SIZE size; int wdUsedByte; if (usedByte < 0) { wdUsedByte = tsWordData->UsedByte; } else { wdUsedByte = usedByte; } String newFontName = GetFamilyFontName(font->Name, hdc); if (newFontName == NULL || canvas->Font->Name == newFontName) { // ±âÁ¸ ¹æ½Ä if (wdUsedByte == 1) GetTextExtentPoint32W(hdc, tsWordData->Word, 1, &size); else GetTextExtentPoint32W(hdc, tsWordData->Word, 2, &size); } else { String fontName = canvas->Font->Name; canvas->Font->Name = newFontName; hdc = canvas->Handle; // familyFont.get if (wdUsedByte == 1) GetTextExtentPoint32W(hdc, tsWordData->Word, 1, &size); else GetTextExtentPoint32W(hdc, tsWordData->Word, 2, &size); canvas->Font->Name = fontName; hdc = canvas->Handle; } return size; } // --------------------------------------------------------------------------- // Test (2007. 12. 26 Annualring) void __fastcall TVecDraw::MakeOutlineByMargin(int margin) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data, *cdata; double x, y; int startX, startY; double hvRatio; RECT rc; // double ratiox = x / 100.0, ratioy = y / 100.0; int x1, x2, y1, y2, fontSize; bool sw = true; SIZE size; TFont *font = MainImageForm->iMainImage->Canvas->Font; HDC hdc; double zoom = 1; // ÇÔ¼ö Áö¿ª º¯¼ö¸¦ »ç¿ëÇÏ´Â °ÍÀ¸·Î º¯°æ (2008. 01. 07 Annualring) startX = sx; startY = sy; startX -= margin / 2; startY -= margin / 2; double ratiox, ratioy; int FirstX = 99999, FirstY = 99999, SecondX = 0, SecondY = 0; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->Kind == V_TEXTBOX) { for (int i = 0; i < 5; i++) { FirstX = min(FirstX, data->pList[i].x); FirstY = min(FirstY, data->pList[i].y); SecondX = max(SecondX, data->pList[i].x); SecondY = max(SecondY, data->pList[i].y); } } else { for (int i = 0; i < data->nCount * 3 + 1; i++) { FirstX = min(FirstX, data->pList[i].x); FirstY = min(FirstY, data->pList[i].y); SecondX = max(SecondX, data->pList[i].x); SecondY = max(SecondY, data->pList[i].y); /* if (i % 3 == 0 && i != data->nCount*3) { sumX += data->pList[i].x; sumY += data->pList[i].y; pointCount ++; } */ } } } x = margin + abs(SecondX - FirstX); y = margin + abs(SecondY - FirstY); switch(MainImageForm->CurrentUnit) { case uDot: break; case uInch: x = x * MainImageForm->CanvasInfor.DotsPerInch; y = y * MainImageForm->CanvasInfor.DotsPerInch; break; case uCm: x = x * MainImageForm->CanvasInfor.DotsPerInch / 2.54; y = y * MainImageForm->CanvasInfor.DotsPerInch / 2.54; break; } // ±¸ÇÑ ±æÀÌ : ÀÔ·ÂÇÑ ±æÀÌ ºñÀ² ±¸ÇÔ ratiox = (double)x / abs(SecondX - FirstX); ratioy = (double)y / abs(SecondY - FirstY); // -----------------------< zoom = min(fabs(ratiox), fabs(ratioy)); int dataListCount = DataList->Count; for (int i = 0; i < dataListCount; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; cdata = new TVecData(MainImageForm->Number); cdata->Copy(data); data->bSelected = false; cdata->bSelected = true; cdata->GroupIndex = 0; // GroupIndex´Â copy¾ÈµÇ°Ô.. // ¿©±â¸¦ ¼öÁ¤ (2008. 01. 04 Annualring) DataList->Add(cdata); UndoSave(VU_CREATE, DataList->Count - 1, sw); sw = false; data = cdata; switch(data->Kind) { case V_LINE: case V_CURVE: for (int i = 0; i < data->nCount * 3 + 1; i++) { if (VectorForm->isShiftKeyDownState()) { data->pList[i].x = (data->pList[i].x - sx) * zoom + startX; data->pList[i].y = (data->pList[i].y - sy) * zoom + startY; } else { data->pList[i].x = (data->pList[i].x - sx) * ratiox + startX; data->pList[i].y = (data->pList[i].y - sy) * ratioy + startY; } } SET_RECT; break; case V_RECT: case V_ELLIPSE: if (VectorForm->isShiftKeyDownState()) { data->First.x = (data->First.x - sx) * zoom + startX; data->First.y = (data->First.y - sy) * zoom + startY; data->Second.x = (data->Second.x - sx) * zoom + startX; data->Second.y = (data->Second.y - sy) * zoom + startY; } else { data->First.x = (data->First.x - sx) * ratiox + startX; data->First.y = (data->First.y - sy) * ratioy + startY; data->Second.x = (data->Second.x - sx) * ratiox + startX; data->Second.y = (data->Second.y - sy) * ratioy + startY; } x1 = min(data->First.x, data->Second.x); x2 = max(data->First.x, data->Second.x); y1 = min(data->First.y, data->Second.y); y2 = max(data->First.y, data->Second.y); data->First.x = x1; data->First.y = y1; data->Second.x = x2; data->Second.y = y2; break; case V_TEXT: // Text´Â ÀÛÀº ºñÀ²·Î¸¸ È®´ë Ãà¼Ò°¡ µÈ´Ù (ÇöÀç·Î¼­ °¡·Î, ¼¼·Î ´Ù¸¥ºñÀ² º¯È­´Â ºÒ°¡´É) data->First.x = (data->First.x - sx) * zoom + startX; data->First.y = (data->First.y - sy) * zoom + startY; data->Second.x = (data->Second.x - sx) * zoom + startX; data->Second.y = (data->Second.y - sy) * zoom + startY; data->Font.lfHeight *= zoom; if (data->Font.lfHeight < 1) data->Font.lfHeight = 1; break; case V_TEXTBOX: { double angle; TSWordData *tsWordData; int cx = (startX + ex) / 2, cy = (startY + ey) / 2; // rotation objectµéÀÇ centerÁ¡µé int lineHeight = 0, lineCount = 0; SIZE size; TFont *font = MainImageForm->iMainImage->Canvas->Font; HDC hdc; for (int k = 0; k < data->ListOfAllLine->Count; k++) { tsWordData = (TSWordData*)data->ListOfAllLine->Items(k); tsWordData->LFont.lfHeight *= zoom; if (tsWordData->LFont.lfHeight == 0) tsWordData->LFont.lfHeight = 1; font->Name = tsWordData->LFont.lfFaceName; font->Size = tsWordData->LFont.lfHeight; hdc = MainImageForm->iMainImage->Canvas->Handle; /* if (tsWordData->UsedByte == 1) GetTextExtentPoint32(hdc, tsWordData->Word, 1, &size); else GetTextExtentPoint32(hdc, tsWordData->Word, 2, &size); */ /////////////////////// Vista Font¿¡ ´ëÇØ SizeÁ¦´ë·Î ¸ø°¡Á®¿Í¼­ »ý±â´Â ¹®Á¦ ó¸® (2007. 06. 27 Annualring) size = GetVectorTextExtent(MainImageForm->iMainImage->Canvas, font, tsWordData); tsWordData->PPoint.x = size.cx; tsWordData->PPoint.y = size.cy; tsWordData->Interval = size.cx * 4 / 5; lineHeight = size.cy > lineHeight ? lineHeight = size.cy : lineHeight; if (tsWordData->Word[0] == '\r') { (data->ListOfAllLine->GetLineTextBox(lineCount)) ->lineHeight = lineHeight; lineCount++; lineHeight = 0; } } if (lineCount == 0) (data->ListOfAllLine->GetLineTextBox(0))->lineHeight = lineHeight; else { (data->ListOfAllLine->GetLineTextBox(lineCount)) ->lineHeight = lineHeight; } // Text´Â ÀÛÀº ºñÀ²·Î¸¸ È®´ë Ãà¼Ò°¡ µÈ´Ù (ÇöÀç·Î¼­ °¡·Î, ¼¼·Î ´Ù¸¥ºñÀ² º¯È­´Â ºÒ°¡´É) data->First.x = (data->First.x - startX) * zoom + startX; data->First.y = (data->First.y - startY) * zoom + startY; lineHeight = (data->ListOfAllLine->GetLineTextBox(0))->lineHeight; data->StartPoint.x = data->First.x; data->StartPoint.y = data->First.y + lineHeight; GetTextBoxRect(data); angle = data->TextAngle; angle = angle / 180 * M_PI; data->pList[0].x = data->First.x; data->pList[0].y = data->First.y; data->pList[1].x = data->First.x; data->pList[1].y = data->Second.y; data->pList[2].x = data->Second.x; data->pList[2].y = data->Second.y; data->pList[3].x = data->Second.x; data->pList[3].y = data->First.y; data->pList[4].x = data->First.x; data->pList[4].y = data->First.y; data->CenterPoint.x = (data->pList[0].x + data->pList[2].x) / 2; data->CenterPoint.y = (data->pList[0].y + data->pList[2].y) / 2; cx = data->CenterPoint.x; cy = data->CenterPoint.y; // todo: ij·ÔÀ» ó¸®Çϱâ À§Çؼ­ (¹Ú»óÈÆ) CenterPoint.x = data->CenterPoint.x; CenterPoint.y = data->CenterPoint.y; for (int i = 0; i < 5; i++) { double tx = data->pList[i].x - cx; double ty = cy - data->pList[i].y; data->pList[i].x = tx * cos(-angle) + ty * sin(-angle) + cx; data->pList[i].y = cy - (-tx * sin(-angle) + ty * cos(-angle)); } break; } } if (data->bPatternFill) MakePatternBitmap(data); // -->by linuxjun for CurvedVectorText if (data->ParentTextBox) { MakeTextBoxPointList(data->ParentTextBox); } // <--by linuxjun for CurvedVectorText } NVector->bProportion = false; // ÀÌÁ¦ È®´ëÃà¼Ò¸ðµå´Â ³¡~ rc.top = startY - thick; rc.bottom = startY + (ey - startY) * max(1.0, ratioy) + thick; rc.left = startX - thick; rc.right = startX + (ex - startX) * max(1.0, ratiox) + thick; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - ¹ÝÀü °Å¿ïÀÇ º¤ÅÍ ¿µ¿ªÀ» °°ÀÌ ±¸ÇÑ´Ù - by monkman(2005.03.16) if (NVector->bVectorReflectionMode) { GetRealAndReflectionRect(&rc); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- MainImageForm->iMainImage->RectPaint(rc); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::MakeOutlineByMarginFromCenter(int Count, int Margin) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data, *cdata; double x, y; double hvRatio; int startX, startY, endX, endY; int marginX, marginY; RECT rc; int x1, x2, y1, y2, fontSize; bool sw = true; SIZE size; TFont *font = MainImageForm->iMainImage->Canvas->Font; HDC hdc; double zoom = 1; // ÇÔ¼ö Áö¿ª º¯¼ö¸¦ »ç¿ëÇÏ´Â °ÍÀ¸·Î º¯°æ (2008. 01. 07 Annualring) int firstSelectedVetorIndex = -1; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->Kind == V_TEXT || data->Kind == V_TEXTBOX) continue; if (firstSelectedVetorIndex < 0) { firstSelectedVetorIndex = i; break; } } data = (TVecData*)DataList->Items[firstSelectedVetorIndex]; if (Margin < 0) { if (abs(data->Second.x - data->First.x) / 2 <= (-Margin) * Count || abs (data->Second.y - data->First.y) / 2 <= (-Margin) * Count) { Application->MessageBox(IDS_MESSAGE010.c_str(), L"Information", MB_OK); END_LOG; return; } } TList *resultList = new TList; for (int i = 0; i < Count; i++) { if (resultList->Count > 0) { data = (TVecData*)resultList->Last(); } else { data = (TVecData*)DataList->Items[firstSelectedVetorIndex]; } if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->Kind == V_TEXTBOX) continue; int pointCount = 0; int sumX = 0, sumY = 0; int FirstX = 99999, FirstY = 99999, SecondX = 0, SecondY = 0; for (int i = 0; i < data->nCount * 3 + 1; i++) { FirstX = min(FirstX, data->pList[i].x); FirstY = min(FirstY, data->pList[i].y); SecondX = max(SecondX, data->pList[i].x); SecondY = max(SecondY, data->pList[i].y); if (i % 3 == 0 && i != data->nCount * 3) { sumX += data->pList[i].x; sumY += data->pList[i].y; pointCount++; } } int centerX, centerY; centerX = sumX / pointCount; centerY = sumY / pointCount; double ratiox, ratioy; ratiox = (double)(Margin * 2 + abs(SecondX - FirstX)) / abs (SecondX - FirstX); ratioy = (double)(Margin * 2 + abs(SecondY - FirstY)) / abs (SecondY - FirstY); zoom = min(fabs(ratiox), fabs(ratioy)); cdata = new TVecData(MainImageForm->Number); cdata->Copy(data); data->bSelected = false; cdata->bSelected = true; cdata->GroupIndex = 0; // GroupIndex´Â copy¾ÈµÇ°Ô.. data = cdata; switch(data->Kind) { case V_LINE: case V_CURVE: for (int i = 0; i < data->nCount * 3 + 1; i++) { if (VectorForm->isShiftKeyDownState()) { data->pList[i].x = (data->pList[i].x - centerX) * zoom + centerX; data->pList[i].y = (data->pList[i].y - centerY) * zoom + centerY; } else { data->pList[i].x = (data->pList[i].x - centerX) * ratiox + centerX; data->pList[i].y = (data->pList[i].y - centerY) * ratioy + centerY; } } SET_RECT; break; case V_RECT: case V_ELLIPSE: if (VectorForm->isShiftKeyDownState()) { data->First.x = (data->First.x - centerX) * zoom + centerX; data->First.y = (data->First.y - centerY) * zoom + centerY; data->Second.x = (data->Second.x - centerX) * zoom + centerX; data->Second.y = (data->Second.y - centerY) * zoom + centerY; } else { data->First.x = (data->First.x - centerX) * ratiox + centerX; data->First.y = (data->First.y - centerY) * ratioy + centerY; data->Second.x = (data->Second.x - centerX) * ratiox + centerX; data->Second.y = (data->Second.y - centerY) * ratioy + centerY; } x1 = min(data->First.x, data->Second.x); x2 = max(data->First.x, data->Second.x); y1 = min(data->First.y, data->Second.y); y2 = max(data->First.y, data->Second.y); data->First.x = x1; data->First.y = y1; data->Second.x = x2; data->Second.y = y2; break; case V_TEXT: // Text´Â ÀÛÀº ºñÀ²·Î¸¸ È®´ë Ãà¼Ò°¡ µÈ´Ù (ÇöÀç·Î¼­ °¡·Î, ¼¼·Î ´Ù¸¥ºñÀ² º¯È­´Â ºÒ°¡´É) data->First.x = (data->First.x - centerX) * zoom + centerX; data->First.y = (data->First.y - centerY) * zoom + centerY; data->Second.x = (data->Second.x - centerX) * zoom + centerX; data->Second.y = (data->Second.y - centerY) * zoom + centerY; data->Font.lfHeight *= zoom; if (data->Font.lfHeight < 1) data->Font.lfHeight = 1; break; case V_TEXTBOX: { double angle; TSWordData *tsWordData; int cx = (sx + ex) / 2, cy = (sy + ey) / 2; // rotation objectµéÀÇ centerÁ¡µé int lineHeight = 0, lineCount = 0; SIZE size; TFont *font = MainImageForm->iMainImage->Canvas->Font; HDC hdc; for (int k = 0; k < data->ListOfAllLine->Count; k++) { tsWordData = (TSWordData*)data->ListOfAllLine->Items(k); tsWordData->LFont.lfHeight *= zoom; if (tsWordData->LFont.lfHeight == 0) tsWordData->LFont.lfHeight = 1; font->Name = tsWordData->LFont.lfFaceName; font->Size = tsWordData->LFont.lfHeight; hdc = MainImageForm->iMainImage->Canvas->Handle; /* if (tsWordData->UsedByte == 1) GetTextExtentPoint32(hdc, tsWordData->Word, 1, &size); else GetTextExtentPoint32(hdc, tsWordData->Word, 2, &size); */ /////////////////////// Vista Font¿¡ ´ëÇØ SizeÁ¦´ë·Î ¸ø°¡Á®¿Í¼­ »ý±â´Â ¹®Á¦ ó¸® (2007. 06. 27 Annualring) size = GetVectorTextExtent(MainImageForm->iMainImage->Canvas, font, tsWordData); tsWordData->PPoint.x = size.cx; tsWordData->PPoint.y = size.cy; tsWordData->Interval = size.cx * 4 / 5; lineHeight = size.cy > lineHeight ? lineHeight = size.cy : lineHeight; if (tsWordData->Word[0] == '\r') { (data->ListOfAllLine->GetLineTextBox(lineCount)) ->lineHeight = lineHeight; lineCount++; lineHeight = 0; } } if (lineCount == 0) (data->ListOfAllLine->GetLineTextBox(0))->lineHeight = lineHeight; else { (data->ListOfAllLine->GetLineTextBox(lineCount)) ->lineHeight = lineHeight; } // Text´Â ÀÛÀº ºñÀ²·Î¸¸ È®´ë Ãà¼Ò°¡ µÈ´Ù (ÇöÀç·Î¼­ °¡·Î, ¼¼·Î ´Ù¸¥ºñÀ² º¯È­´Â ºÒ°¡´É) data->First.x = (data->First.x - centerX) * zoom + centerX; data->First.y = (data->First.y - centerY) * zoom + centerY; lineHeight = (data->ListOfAllLine->GetLineTextBox(0))->lineHeight; data->StartPoint.x = data->First.x; data->StartPoint.y = data->First.y + lineHeight; GetTextBoxRect(data); angle = data->TextAngle; angle = angle / 180 * M_PI; data->pList[0].x = data->First.x; data->pList[0].y = data->First.y; data->pList[1].x = data->First.x; data->pList[1].y = data->Second.y; data->pList[2].x = data->Second.x; data->pList[2].y = data->Second.y; data->pList[3].x = data->Second.x; data->pList[3].y = data->First.y; data->pList[4].x = data->First.x; data->pList[4].y = data->First.y; data->CenterPoint.x = (data->pList[0].x + data->pList[2].x) / 2; data->CenterPoint.y = (data->pList[0].y + data->pList[2].y) / 2; cx = data->CenterPoint.x; cy = data->CenterPoint.y; // todo: ij·ÔÀ» ó¸®Çϱâ À§Çؼ­ (¹Ú»óÈÆ) CenterPoint.x = data->CenterPoint.x; CenterPoint.y = data->CenterPoint.y; for (int i = 0; i < 5; i++) { double tx = data->pList[i].x - cx; double ty = cy - data->pList[i].y; data->pList[i].x = tx * cos(-angle) + ty * sin(-angle) + cx; data->pList[i].y = cy - (-tx * sin(-angle) + ty * cos(-angle)); } break; } } if (data->bPatternFill) MakePatternBitmap(data); // -->by linuxjun for CurvedVectorText if (data->ParentTextBox) { MakeTextBoxPointList(data->ParentTextBox); } // <--by linuxjun for CurvedVectorText resultList->Add(data); } // »õ·Î »ý±ä °Í index¸Â°Ô ³Ö±â for (int i = 0; i < resultList->Count; i++) { TVecData *data = (TVecData*)resultList->Items[i]; DataList->Insert(firstSelectedVetorIndex, data); data->bSelected = true; UndoSave(VU_CREATE, firstSelectedVetorIndex); } delete resultList; MakeGroup(); END_LOG; } // --------------------------------------------------------------------------- /// º¤ÅͻѸ®±â¿¡ »ç¿ëÇÑ Á¡ list¸¦ ºñ¿öÁØ´Ù. void __fastcall TVecDraw::InitData() { POINT *p = NULL; if (pstore) { for (int i = 0; i < pstore->Count; i++) { p = (POINT*)pstore->Items[i]; if (p) delete p; p = NULL; } pstore->Clear(); } TPoint_Degv *pd = NULL; if (pdstore) { for (int i = 0; i < pdstore->Count; i++) { pd = (TPoint_Degv*)pdstore->Items[i]; if (pd) delete pd; pd = NULL; } pdstore->Clear(); } } // --------------------------------------------------------------------------- double __fastcall calculatelength(POINT sp, POINT ep) { int x, y; x = ep.x - sp.x; y = ep.y - sp.y; return sqrt(x * x + y * y); } // --------------------------------------------------------------------------- /* »Ñ¸®´Â °£°ÝÀ» dot´ÜÀ§·Î °è»êÇØÁÖ´Â ÇÔ¼ö */ double __fastcall TVecDraw::CalculateLength(TList * store) { double sumlength = 0; double len = 0; if (store->Count > 0) { POINT * sp; POINT * ep; for (int i = 1; i < store->Count; i++) { sp = (POINT*)store->Items[i - 1]; ep = (POINT*)store->Items[i]; len = calculatelength(*sp, *ep); sumlength += len; } } return sumlength; } // --------------------------------------------------------------------------- int __fastcall TVecDraw::GetLimitDot(TList * store) { LimitDot = 1; double sumlength1, sumlength2; Shape = (TSprayShape)VectorForm->ShapeComboBox->ItemIndex; if (VectorForm->rzcbUseCount->Checked == false) { UpdateLimitDot(); return LimitDot; } BEGIN_LOG(""); if (Shape == SS_ELLIPSE) { int a = abs(First.x - Second.x) / 2; int b = abs(First.y - Second.y) / 2; double x = (a - b) / (a + b); sumlength1 = M_PI * (3 * a + 3 * b - sqrt((a + 3 * b) * (3 * a + b))); // Ÿ¿øÀÇ µÑ·¹ ±Ù»ç½Ä sumlength1,sumlength2¸ðµÎ ±Ù»ç½ÄÀÌ´Ù. sumlength2 = M_PI * (a + b) * (1 + 3 * x * x / (10 + sqrt(4 - 3 * x * x))); } if (Shape == SS_CURVE || Shape == SS_CIRCLE) { LimitDot = 1; } else { if (store->Count > 0) { POINT * sp; POINT * ep; int sumlength = 0; int len = 0; for (int i = 1; i < store->Count; i++) { sp = (POINT*)store->Items[i - 1]; ep = (POINT*)store->Items[i]; len = calculatelength(*sp, *ep); sumlength += len; } if (Shape != SS_ELLIPSE) LimitDot = GetProperLimitDot(sumlength); else LimitDot = GetProperLimitDot(sumlength1); } } END_LOG; return LimitDot; } // --------------------------------------------------------------------------- int __fastcall TVecDraw::GetProperLimitDot(int sumLength) { int value = VectorForm->CountEdit->Value; double temp = ((double)sumLength) / value; int result = temp; return result; } // --------------------------------------------------------------------------- // by embakum // PatternRepeat.cpp ¿¡¼­ °¡Á®¿Â DrawCurveÇÔ¼ö. // Curve·Î VectorObject¸¦ »Ñ¸± ¶§, BezierCurve¸¦ ±×·ÁÁÖ°í, ±× Curve¸¦ µû¶ó¼­ ÀÏÁ¤ÇÑ °£°Ý(LimitDot)¸¶´Ù // pdstore¿¡ Á¡ÀÇ ÁÂÇ¥¿Í °¢µµ¸¦ ÀÔ·ÂÇØ ÁÖ¾î pdstore¸¦ ¾÷µ¥ÀÌÆ®ÇØ ÁÖ´Â ÇÔ¼ö. MouseMoveÀ̺¥Æ®¸¶´Ù pdstore¸¦ ¾÷µ¥ÀÌÆ®ÇÏ°Ô µÈ´Ù. void __fastcall TVecDraw::DrawCurve(POINT First, POINT Second, POINT Third) { static int oldp = 0, oldl = 0; if (VectorForm->checkboxContinue->Checked == false) { InitData(); oldp = 0; oldl = 0; } if (pstore->Count == 1 && mousedown == 1) { oldp = 1; oldl = 0; } if (pstore->Count == 0) MainImageForm->DrawFreeLineLocate(First, 0); MainImageForm->DrawFreeLineLocate(First, oldl); int x2, y2, mx, my, sx2, sy2, ex2, ey2; int sx = First.x, sy = First.y, ex = Second.x, ey = Second.y, tx = Third.x, ty = Third.y; int t; double Theta, c, s; double alphas, alphae, tangent; double m; double d1, d2, d3; int a, dx, dy, x1, y1; double rad, len, deg; bool first; d1 = sqrt((double)(sx - tx) * (sx - tx) + (sy - ty) * (sy - ty)); d2 = sqrt((double)(ex - tx) * (ex - tx) + (ey - ty) * (ey - ty)); d3 = sqrt((double)(ex - sx) * (ex - sx) + (ey - sy) * (ey - sy)); if (d1 + d2 == 0) { return; } if (d1 == d2 + d3 || d2 == d1 + d3 || d3 == d1 + d2) { POINT *p1 = new POINT; *p1 = Point(sx, sy); pstore->Add(p1); MainImageForm->DrawFreeLineLocate(Point(sx, sy), -2); POINT *p2 = new POINT; *p2 = Point(ex, ey); pstore->Add(p2); MainImageForm->DrawFreeLineLocate(Point(ex, ey)); // °¢µµ dx = ex - sx; dy = ey - sy; len = calculatelength(Point(ex, ey), Point(sx, sy)); sumlength = len; if (dx) { deg = atanl((double)dy / dx) + (ex > sx ? 0 : M_PI); } else { if (dy > 0) deg = M_PI_2; else deg = -M_PI_2; } deg = 180 * deg / M_PI * 100; if (deg < 0) deg += 36000; if (deg > 35999) deg -= 36000; first = true; while (sumlength > LimitDot) { if (first) { a = LimitDot - (sumlength - len); sumlength = len - a; } else { sumlength = sumlength - LimitDot; } dx = (sumlength * sx + (len - sumlength) * ex) / len; dy = (sumlength * sy + (len - sumlength) * ey) / len; TPoint_Degv *pd = new TPoint_Degv; pd->pt = Point(dx, dy); pd->deg = deg; pdstore->Add(pd); first = false; } // °¢µµ goto next; } m = d1 / (d1 + d2); mx = ex * m + sx * (1 - m); my = ey * m + sy * (1 - m); if ((tx - mx) == 0) { Theta = 0; } else { tangent = (double)(my - ty) / (mx - tx); Theta = M_PI / 2.0 - atan(tangent); // if(mx-tx<0)Theta+=M_PI; } c = cos(Theta); s = sin(Theta); sx2 = (sx - tx) * c - (sy - ty) * s + 0.5; sy2 = (sx - tx) * s + (sy - ty) * c + 0.5; ex2 = (ex - tx) * c - (ey - ty) * s + 0.5; ey2 = (ex - tx) * s + (ey - ty) * c + 0.5; if ((double)sx2 * (double)sx2 == 0) alphas = sy2 * 0xFFFFFFFF; else alphas = (double)sy2 / ((double)sx2 * (double)sx2); if ((double)ex2 * (double)ex2 == 0) alphae = ey2 * 0xFFFFFFFF; else alphae = (double)ey2 / ((double)ex2 * (double)ex2); if (alphas * alphae < 0) { POINT *p1 = new POINT; *p1 = Point(sx, sy); pstore->Add(p1); MainImageForm->DrawFreeLineLocate(Point(sx, sy), -2); POINT *p2 = new POINT; *p2 = Point(ex, ey); pstore->Add(p2); MainImageForm->DrawFreeLineLocate(Point(ex, ey), -2); // °¢µµ dx = ex - sx; dy = ey - sy; len = calculatelength(Point(ex, ey), Point(sx, sy)); sumlength = len; if (dx) { deg = atanl((double)dy / dx) + (ex > sx ? 0 : M_PI); } else { if (dy > 0) deg = M_PI_2; else deg = -M_PI_2; } deg = 180 * deg / M_PI * 100; if (deg < 0) deg += 36000; if (deg > 35999) deg -= 36000; first = true; while (sumlength > LimitDot) { if (first) { a = LimitDot - (sumlength - len); sumlength = len - a; } else { sumlength = sumlength - LimitDot; } dx = (sumlength * sx + (len - sumlength) * ex) / len; dy = (sumlength * sy + (len - sumlength) * ey) / len; TPoint_Degv *pd = new TPoint_Degv; pd->pt = Point(dx, dy); pd->deg = deg; pdstore->Add(pd); first = false; } // °¢µµ goto next; } t = 1; POINT *p1 = new POINT; *p1 = Point(sx, sy); pstore->Add(p1); MainImageForm->DrawFreeLineLocate(Point(sx, sy), -2); while (t >= 1 && t <= 20) { x2 = (double)sx2 * (double)(20 - t) / 20.0; y2 = alphas * ((double)x2 * (double)x2); POINT *p = new POINT; *p = Point(tx + c * x2 + s * y2, ty - s * x2 + c * y2); pstore->Add(p); MainImageForm->DrawFreeLineLocate(Point(tx + c * x2 + s * y2, ty - s * x2 + c * y2), -2); t++; // °¢µµ x1 = (double)sx2 * (double)(20 - t + 2) / 20.0; y1 = alphas * ((double)x1 * (double)x1); len = calculatelength(Point(x2, y2), Point(x1, y1)); sumlength += len; first = true; while (sumlength > LimitDot) { if (first) { a = LimitDot - (sumlength - len); sumlength = len - a; } else { sumlength = sumlength - LimitDot; } dx = (sumlength * x1 + (len - sumlength) * x2) / len; dy = (sumlength * y1 + (len - sumlength) * y2) / len; deg = atanl(2 * alphas * x1) + (x2 > x1 ? 0 : M_PI) - Theta; deg = 180 * deg / M_PI * 100; if (deg < 0) deg += 36000; if (deg > 35999) deg -= 36000; TPoint_Degv *pd = new TPoint_Degv; pd->pt = Point(tx + c * dx + s * dy, ty - s * dx + c * dy); pd->deg = deg; pdstore->Add(pd); first = false; } // °¢µµ } t = 1; MainImageForm->DrawFreeLineLocate(Point(tx, ty), -2); while (t >= 1 && t <= 19) { x2 = (double)ex2 * (double)t / 20.0; y2 = alphae * ((double)x2 * (double)x2); POINT *p = new POINT; *p = Point(tx + c * x2 + s * y2, ty - s * x2 + c * y2); pstore->Add(p); MainImageForm->DrawFreeLineLocate(Point(tx + c * x2 + s * y2, ty - s * x2 + c * y2), -2); t++; // °¢µµ x1 = (double)ex2 * (double)(t - 2) / 20.0; y1 = alphae * ((double)x1 * (double)x1); len = calculatelength(Point(x2, y2), Point(x1, y1)); sumlength += len; first = true; while (sumlength > LimitDot) { if (first) { a = LimitDot - (sumlength - len); sumlength = len - a; } else { sumlength = sumlength - LimitDot; } dx = (sumlength * x1 + (len - sumlength) * x2) / len; dy = (sumlength * y1 + (len - sumlength) * y2) / len; deg = atanl(2 * alphae * x1) + (x2 > x1 ? 0 : M_PI) - Theta; deg = 180 * deg / M_PI * 100; if (deg < 0) deg += 36000; if (deg > 35999) deg -= 36000; TPoint_Degv *pd = new TPoint_Degv; pd->pt = Point(tx + c * dx + s * dy, ty - s * dx + c * dy); pd->deg = deg; pdstore->Add(pd); first = false; } // °¢µµ } POINT *p2 = new POINT; *p2 = Point(ex, ey); pstore->Add(p2); MainImageForm->DrawFreeLineLocate(Point(ex, ey)); next: if (VectorForm->checkboxContinue->Checked == true) { if (mousedown != 3) { POINT *p = NULL; while (pdstore->Count > oldp - 1) { p = (POINT*)pdstore->Last(); pdstore->Remove(p); if (p) { delete p; p = NULL; } } } else { oldp = pdstore->Count; oldl = MainImageForm->GetLineListCount(); } } return; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::DrawLocate(POINT F, POINT S) { MainImageForm->DrawLineLocate(F, S); } // --------------------------------------------------------------------------- // by embakum // EllipseÀÇ Á¡À» pstore ¿¡ Ãß°¡. void __fastcall TVecDraw::PointAdd(int X, int Y) { POINT *p = new POINT; *p = Point(X, Y); pstore->Add(p); // prepoint = *p; } // ----------------------------------------------------------------------------- void __fastcall TVecDraw::AddRectanglePoints(int x, int y, int x2, int y2) { long int b; b = y2 - y; if (b < 0) { PointAdd(x, y2); PointAdd(x2, y2); PointAdd(x2, y); PointAdd(x, y); } else { PointAdd(x2, y); PointAdd(x2, y2); PointAdd(x, y2); PointAdd(x, y); } } // ----------------------------------------------------------------------------- // by embakum // EllipseÀÏ °æ¿ì¿¡ pstore¸¦ ÀÌ¿ëÇÏ¿© Á¡µéÀ» ÀúÀå½ÃÄÑÁØ´Ù. // Rect(x,y,x2,y2)¿¡ µé¾îÀִ Ÿ¿øÀÇ Á¡µéÀ» pstore¿¡ ³Ö´Â´Ù. void __fastcall TVecDraw::AddEllipsePoints(int x, int y, int x2, int y2) { double b, a, k, i, l, s; // k´Â y ÁÂÇ¥ a = x2 - x; // i´Â x ÁÂÇ¥ if (a == 0) a++; b = y2 - y; a = a / 2; b = b / 2; if (a > 0) { l = a + x; s = b + y; for (i = -a; i <= a; i += 2) { k = (b * b) - (b * b * i * i) / (a * a); k = sqrt(k); PointAdd((l + i), (s - k)); } for (i = a; i >= -a; i -= 2) { k = (b * b) - (b * b * i * i) / (a * a); k = sqrt(k); PointAdd((l + i), (s + k)); if (i == -a) PointAdd(x, y + b); } } else { l = a + x; s = b + y; for (i = -a; i >= a; i -= 2) { k = (b * b) - (b * b * i * i) / (a * a); k = sqrt(k); PointAdd((l + i), (s - k)); } for (i = a; i <= -a; i += 2) { k = (b * b) - (b * b * i * i) / (a * a); k = sqrt(k); PointAdd((l + i), (s + k)); if (i == -a) PointAdd(x, y + b); } } } // ----------------------------------------------------------------------------- void __fastcall TVecDraw::SprayPositionMouseDown(int X, int Y) { TList *DataList = NVector->DataList; TVecData *Child; mousedown++; Shape = (TSprayShape)VectorForm->ShapeComboBox->ItemIndex; if (mousedown == 1) { if (Shape == SS_FREE) MainImageForm->DrawFreeLineLocate(Point(X, Y)); if (Shape == SS_CURVE) MainImageForm->DrawFreeLineLocate(Point(X, Y), 0); InitData(); First.x = X; First.y = Y; Second.x = X; Second.y = Y; POINT *p = new POINT; *p = Point(X, Y); DrawLocate(*p, *p); mdown = true; if ((Shape == SS_CIRCLE) || (Shape == SS_ELLIPSE)) delete p; else { pstore->Add(p); } CurvePoint[0] = Point(X, Y); } else if (mousedown == 2) { if (!(Shape == SS_CURVE)) { if (Shape == SS_ELLIPSE) { AddEllipsePoints(First.x, First.y, X, Y); } else if (Shape == SS_RECT) { AddRectanglePoints(First.x, First.y, X, Y); } else if (Shape == SS_OBLIQUE) { POINT *p1 = new POINT; *p1 = Point(X, Y); pstore->Add(p1); } else if (Shape == SS_H_V) { POINT *p2 = new POINT; *p2 = Point(X, Y); int dx = First.x - X; int dy = First.y - Y; if (abs(dx) > abs(dy)) { p2->y = First.y; } else { p2->x = First.x; } pstore->Add(p2); } DrawShape(0, 0, 0, 0); VectorSpray(); } else if (Shape == SS_CURVE) CurvePoint[1] = Point(X, Y); } else if (mousedown == 3) { if (VectorForm->checkboxContinue->Checked == true) { DrawCurve(CurvePoint[0], CurvePoint[1], Point(X, Y)); mousedown = 1; CurvePoint[0] = CurvePoint[1]; } else { // LimitDotº¯°æ½ÃÄÑÁÜ // DrawCurve·Î pdstore¸¦ ´Ù½Ã ¸¸µé¾îÁÜ. 080314 if (VectorForm->rzcbUseCount->Checked == false) { UpdateLimitDot(); Third = Point(X, Y); DrawCurve(First, Second, Third); } VectorSpray(); mousedown = 0; } } } // --------------------------------------------------------------------------- /* LimitDot¸¦ ´Ù½Ã °è»êÇØÁÙ Çʿ䰡 ÀÖÀ» ¶§ */ void __fastcall TVecDraw::UpdateLimitDot() { Shape = (TSprayShape)VectorForm->ShapeComboBox->ItemIndex; float value = VectorForm->CmEdit->Value; if (VectorForm->CmEdit->Value > 0) { if (Shape != SS_CIRCLE) { if (MainImageForm->CurrentUnit == uCm) { LimitDot = 160 * value / 2.54; } else if (MainImageForm->CurrentUnit == uDot) { try { LimitDot = value; } catch(EConvertError & ec) { LimitDot = 80; EXCEPTION_MESSAGE_OK(EC_NOT_INTEGER); } } else if (MainImageForm->CurrentUnit == uInch) { LimitDot = 160 * value; } if (LimitDot <= 0) LimitDot = 1; // 0 À϶§ ÇÁ·Î±×·¥ ´Ù¿îµÇ¼­.. by celberus } } } // --------------------------------------------------------------------------- void __fastcall TVecDraw::SprayPositionMouseMove(int X, int Y) { Shape = (TSprayShape)VectorForm->ShapeComboBox->ItemIndex; if (pstore->Count > 1 && mousedown == 1) VectorForm->sbRun->Enabled = true; else VectorForm->sbRun->Enabled = false; if ((mousedown == 1) && (!(Shape == SS_CURVE))) { if (Shape == SS_FREE) { POINT *p = new POINT; *p = Point(X, Y); pstore->Add(p); static int x = X, y = Y; if (x != X || y != Y) { MainImageForm->DrawFreeLineLocate(Point(X, Y)); } x = X; y = Y; } else { Second = Point(X, Y); DrawShape(First.x, First.y, Second.x, Second.y); } } else if (Shape == SS_CURVE) { if (mousedown == 1) { Second = Point(X, Y); GetLimitDot(pstore); DrawCurve(CurvePoint[0], Point(X, Y), Point(X, Y)); } else if (mousedown == 2) { Third = Point(X, Y); CurvePoint[2] = Point(X, Y); GetLimitDot(pstore); DrawCurve(CurvePoint[0], CurvePoint[1], Point(X, Y)); } } } // --------------------------------------------------------------------------- void __fastcall TVecDraw::SprayPositionMouseUp(int X, int Y) { Shape = (TSprayShape)VectorForm->ShapeComboBox->ItemIndex; mdown = false; if (Shape == SS_FREE) { mousedown = 0; MainImageForm->DrawFreeLineLocate(Point(X, Y), 0); VectorSpray(); } else if (Shape == SS_CURVE) { } } // --------------------------------------------------------------------------- void __fastcall TVecDraw::DrawShape(int x1, int y1, int x2, int y2) { POINT pt, pt2; double r; int oldBrushStyle = MainImageForm->iMainImage->Canvas->Brush->Style; int oldPenMode = MainImageForm->iMainImage->Canvas->Pen->Mode; int oldPenStyle = MainImageForm->iMainImage->Canvas->Pen->Style; MainImageForm->iMainImage->Canvas->Brush->Style = bsClear; MainImageForm->iMainImage->Canvas->Pen->Mode = pmNotXor; MainImageForm->iMainImage->Canvas->Pen->Style = psSolid; int dx = x1 - x2; int dy = y1 - y2; switch(Shape) { case SS_FREE: // Free Line break; case SS_OBLIQUE: // Oblique Line MainImageForm->DrawLineLocate(Point(x1, y1), Point(x2, y2)); break; case SS_H_V: // HV Line if (abs(dx) > abs(dy)) { y2 = y1; } else { x2 = x1; } MainImageForm->DrawLineLocate(Point(x1, y1), Point(x2, y2)); break; case SS_RECT: // Rectangle MainImageForm->DrawRectangleLocate(Rect(x1, y1, x2, y2)); break; case SS_CIRCLE: // Circle r = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); x1 = x1 - r; y1 = y1 - r; x2 = x1 + 2 * r; y2 = y1 + 2 * r; MainImageForm->DrawEllipseLocate(Rect(x1, y1, x2, y2)); break; case SS_ELLIPSE: // Ellipse MainImageForm->DrawEllipseLocate(Rect(x1, y1, x2, y2)); break; case SS_CURVE: // Curve if (mousedown == 1) { MainImageForm->DrawLineLocate(Point(x1, y1), Point(x2, y2)); } else if (mousedown == 2) { } break; } } // --------------------------------------------------------------------------- double __fastcall TVecDraw::CalculateAngle(POINT First, POINT Second) { double dx, dy, deg; dx = Second.x - First.x; dy = First.y - Second.y; if (dx) deg = atanl((double)dy / dx); else { if (dy > 0) deg = M_PI_2; else deg = -M_PI_2; } deg = 180 * deg / M_PI; return deg; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::VectorSpray() { mousedown = 0; if (Shape == SS_CURVE) MainImageForm->DrawFreeLineLocate(Point(0, 0), 0); TList *DataList = NVector->DataList; TVecData *data1, *data2; int nCount = DataList->Count; RECT bound_rect; bound_rect = Rect(10000, 10000, 0, 0); sx = 0; sy = 0; ex = 0; ey = 0; thick = 0; // sxy: x,yÀÇ ÃÖ¼ÒÁ¡ exy: ÃÖ´ëÁ¡ if (nCount == 0 || !(NVector->bSelected)) return; for (int i = 0; i < nCount; i++) { data1 = (TVecData*)DataList->Items[i]; if (data1->bSelected) { bound_rect = Rect(min(bound_rect.left, data1->First.x), min(bound_rect.top, data1->First.y), max(bound_rect.right, data1->Second.x), max(bound_rect.bottom, data1->Second.y)); } } int tx = (bound_rect.right - bound_rect.left) / 2; int ty = (bound_rect.bottom - bound_rect.top) / 2; int dev = sqrt(tx * tx + ty * ty); POINT *sp, *ep, pre, drawpoint, temp; double rad, len, dx, dy; int a; bool first; Shape = (TSprayShape)VectorForm->ShapeComboBox->ItemIndex; PosState = (TSprayPosState)VectorForm->PositionComboBox->ItemIndex; // 080326 both ¼öÁ¤ ¹× sprayÈÄ¿¡µµ ¿ø·¡ selectedµÈ°É·Î µ¹·Á³õ±â int number = SelectedObjectCount(); int *selected = new int[number]; int *copied = NULL; TVecData *data; int j = 0; for (int i = 0; i < nCount; i++) { // ¼±ÅõǾîÀÖ´Â ¿ÀºêÁ§Æ®ÀÇ index¸¦ ÀúÀåÇÑ´Ù data = (TVecData*)DataList->Items[i]; // »Ñ¸®±â°¡ ¿Ï·áµÈ ¼ö µÇµ¹·Á ÁÙ¶§ ÇÊ¿äÇÔ if (data->bSelected) { selected[j] = i; j++; } } if (PosState == SPOS_BOTH) { // both¸ðµåÀϰæ¿ì ¼±ÅõǾîÀÖ´Â ¿ÀºêÁ§Æ®¸¦ »óÇϹÝÀü½ÃÄÑ MoveCopyVectorObject(false, 2); // º¹»çÇÑÈÄ, ¿ø·¡¼±ÅõǾîÀִ¿ÀºêÁ§Æ®µé°ú ÇÔ²² bSelected=true·Î ¼³Á¤ÇØÁØ´Ù. VectorForm->MergePosition(bound_rect.left + tx, bound_rect.bottom + ty, false, true); for (int i = 0; i < number; i++) { data = (TVecData*)DataList->Items[selected[i]]; data->bSelected = true; } copied = new int[number]; for (int i = 0; i < number; i++) { copied[i] = DataList->Count - i - 1; // Àӽ÷Π¸¸µé¾îÁø º¤ÅÍ ¿ÀºêÁ§Æ® } } if (Shape == SS_CIRCLE) { if (VectorForm->rzcbUseCount->Checked == true) { // »Ñ¸®´Â °³¼ö¼³Á¤½Ã int a = VectorForm->CountEdit->Value - 1; double r = calculatelength(First, Second); double deg = CalculateAngle(First, Second); for (int i = 0; i < a + 1; i++) { MoveCopyVectorObject(false, 0); int cx = (sx + ex) / 2, cy = (sy + ey) / 2; int dx = First.x + r * cos(i * (2 * M_PI) / (a + 1) - M_PI / 2) - cx, dy = First.y + r * sin(i * (2 * M_PI) / (a + 1) - M_PI / 2) - cy; sx += dx; ex += dx; sy += dy; ey += dy; VectorForm->MergePosition (First.x + r * cos(i * (2 * M_PI) / (a + 1) - M_PI / 2), First.y + r * sin(i * (2 * M_PI) / (a + 1) - M_PI / 2), false, true); if (!(i == 0)) ObjectRotation(true, -360 / (a + 1), false); double t_rad = (double)(36000 - i * (360) / (a + 1)) / 18000 * M_PI; switch(PosState) { case SPOS_CENTER: // center break; case SPOS_LEFT: // left MoveCopyVectorObject(true, 0); VectorForm->MergePosition (First.x + r * cos(i * (2 * M_PI) / (a + 1) - M_PI / 2) - dev * sin(t_rad) / 2, First.y + r * sin(i * (2 * M_PI) / (a + 1) - M_PI / 2) - dev * cos (t_rad) / 2, false, true); break; case SPOS_RIGHT: // right MoveCopyVectorObject(true, 0); VectorForm->MergePosition (First.x + r * cos(i * (2 * M_PI) / (a + 1) - M_PI / 2) + dev * sin(t_rad) / 2, First.y + r * sin(i * (2 * M_PI) / (a + 1) - M_PI / 2) + dev * cos (t_rad) / 2, false, true); break; case SPOS_BOTH: // both break; } sx -= dx; ex -= dx; sy -= dy; ey -= dy; } } else { // »Ñ¸®´Â °Å¸®or°¢µµ ¼³Á¤½Ã int rot_deg = VectorForm->CmEdit->Value; double r = calculatelength(First, Second); for (int deg = 0; deg < 360; deg += rot_deg) { MoveCopyVectorObject(false, 0); int cx = (sx + ex) / 2, cy = (sy + ey) / 2; int dx = First.x + r * cos(deg * (M_PI / 180) - M_PI / 2) - cx, dy = First.y + r * sin(deg * (M_PI / 180) - M_PI / 2) - cy; sx += dx; ex += dx; sy += dy; ey += dy; VectorForm->MergePosition (First.x + r * cos(deg * (M_PI / 180) - M_PI / 2), First.y + r * sin(deg * (M_PI / 180) - M_PI / 2), false, true); if (!(deg == 0)) ObjectRotation(true, -rot_deg, false); double t_rad = (double)(36000 - 100 * deg) / 18000 * M_PI; switch(PosState) { case SPOS_CENTER: // center break; case SPOS_LEFT: // left MoveCopyVectorObject(true, 0); VectorForm->MergePosition (First.x + r * cos(deg * (M_PI / 180) - M_PI / 2) - dev * sin (t_rad) / 2, First.y + r * sin(deg * (M_PI / 180) - M_PI / 2) - dev * cos(t_rad) / 2, false, true); break; case SPOS_RIGHT: // right MoveCopyVectorObject(true, 0); VectorForm->MergePosition (First.x + r * cos(deg * (M_PI / 180) - M_PI / 2) + dev * sin (t_rad) / 2, First.y + r * sin(deg * (M_PI / 180) - M_PI / 2) + dev * cos(t_rad) / 2, false, true); break; case SPOS_BOTH: // both break; } sx -= dx; ex -= dx; sy -= dy; ey -= dy; } } } else if (Shape == SS_CURVE) { if (VectorForm->rzcbUseCount->Checked == true) { // »Ñ¸®´Â °³¼ö¼³Á¤½Ã int a = VectorForm->CountEdit->Value - 1; int dpointnum = pdstore->Count; int dinterval = dpointnum / (a + 1); int deg1 = 0, deg2; for (int i = 0; i < a + 1; i++) { TPoint_Degv *pd = NULL; pd = (TPoint_Degv*)pdstore->Items[dinterval * i]; MoveCopyVectorObject(false, 0); int cx = (sx + ex) / 2, cy = (sy + ey) / 2; int dx = pd->pt.x - cx, dy = pd->pt.y - cy; deg2 = pd->deg; sx += dx; ex += dx; sy += dy; ey += dy; VectorForm->MergePosition(pd->pt.x, pd->pt.y, false, true); ObjectRotation(true, -(deg2 - deg1) / 100, false); double t_rad = (double)(36000 - deg2) / 18000 * M_PI; switch(PosState) { case SPOS_CENTER: // center break; case SPOS_LEFT: // left MoveCopyVectorObject(true, 0); VectorForm->MergePosition(pd->pt.x - dev * sin(t_rad) / 2, pd->pt.y - dev * cos(t_rad) / 2, false, true); break; case SPOS_RIGHT: // right MoveCopyVectorObject(true, 0); VectorForm->MergePosition(pd->pt.x + dev * sin(t_rad) / 2, pd->pt.y + dev * cos(t_rad) / 2, false, true); break; case SPOS_BOTH: // both break; } deg1 = deg2; sx -= dx; ex -= dx; sy -= dy; ey -= dy; } } else { // »Ñ¸®´Â °Å¸®or°¢µµ ¼³Á¤½Ã int deg1 = 0, deg2; for (int i = 0; i < pdstore->Count; i++) { TPoint_Degv *pd = NULL; pd = (TPoint_Degv*)pdstore->Items[i]; MoveCopyVectorObject(false, 0); int cx = (sx + ex) / 2, cy = (sy + ey) / 2; int dx = pd->pt.x - cx, dy = pd->pt.y - cy; deg2 = pd->deg; sx += dx; ex += dx; sy += dy; ey += dy; VectorForm->MergePosition(pd->pt.x, pd->pt.y, false, true); ObjectRotation(true, -(deg2 - deg1) / 100, false); double t_rad = (double)(36000 - deg2) / 18000 * M_PI; switch(PosState) { case SPOS_CENTER: // center break; case SPOS_LEFT: // left MoveCopyVectorObject(true, 0); VectorForm->MergePosition(pd->pt.x - dev * sin(t_rad) / 2, pd->pt.y - dev * cos(t_rad) / 2, false, true); break; case SPOS_RIGHT: // right MoveCopyVectorObject(true, 0); VectorForm->MergePosition(pd->pt.x + dev * sin(t_rad) / 2, pd->pt.y + dev * cos(t_rad) / 2, false, true); break; case SPOS_BOTH: // both break; } deg1 = deg2; sx -= dx; ex -= dx; sy -= dy; ey -= dy; } } } // by embakum 080401 °¢µµ°¡ ¹Ì¼¼ÇÏ°Ô º¯°æµÇ´ø°Í ¼öÁ¤. else if (Shape == SS_OBLIQUE) { if (VectorForm->rzcbUseCount->Checked == true) { // »Ñ¸®´Â °³¼ö¼³Á¤½Ã int i = pstore->Count; int a = VectorForm->CountEdit->Value; double deg = CalculateAngle(First, Second); for (int i = 0; i < a; i++) { MoveCopyVectorObject(false, 0); if (i == 0) { int cx = (sx + ex) / 2, cy = (sy + ey) / 2; int dx = First.x - cx, dy = First.y - cy; sx += dx; ex += dx; sy += dy; ey += dy; VectorForm->MergePosition(First.x, First.y, false, true); ObjectRotation(true, deg, false); sx -= dx; ex -= dx; sy -= dy; ey -= dy; } else { VectorForm->MergePosition(First.x + (Second.x - First.x) * i / a, First.y + (Second.y - First.y) * i / a, false, true); } } } else { if (pstore->Count > 0) { GetLimitDot(pstore); double dist = calculatelength(First, Second); double deg = CalculateAngle(First, Second); int delta_x = (Second.x - First.x) * LimitDot / dist; int delta_y = (Second.y - First.y) * LimitDot / dist; int numspray = dist / LimitDot; for (int i = 0; i < numspray; i++) { MoveCopyVectorObject(false, 0); if (i == 0) { int cx = (sx + ex) / 2, cy = (sy + ey) / 2; int dx = First.x - cx, dy = First.y - cy; sx += dx; ex += dx; sy += dy; ey += dy; VectorForm->MergePosition(First.x, First.y, false, true); ObjectRotation(true, deg, false); sx -= dx; ex -= dx; sy -= dy; ey -= dy; } else { VectorForm->MergePosition(First.x + delta_x * i, First.y + delta_y * i, false, true); } } } } } else { // FreeLine, HV Line, Rectangle, Ellipse if (pstore->Count > 0) { sumlength = 0; a = 0; len = 0; rad = 0; sp = (POINT*)pstore->Items[0]; pre = *sp; drawpoint = pre; GetLimitDot(pstore); int PatternCount = 0; tempdeg1 = 0; for (int i = 1; i < pstore->Count; i++) { StatusProgress->Position = i; ep = (POINT*)pstore->Items[i]; len = calculatelength(pre, *ep); sumlength += len; first = true; while (sumlength >= LimitDot) { dx = ep->x - pre.x; dy = ep->y - pre.y; if (dx || dy) rad = atan2(dy, dx); else rad = 0; if (first) { a = LimitDot - (sumlength - len); } else { a = LimitDot; } temp.x = a * cos(rad) + pre.x; temp.y = a * sin(rad) + pre.y; if (VectorForm->rzcbUseCount->Checked) { if (PatternCount >= VectorForm->CountEdit->Value) { goto next; } } VectorObjectPut(temp, drawpoint); PatternCount++; if (first) { sumlength = len - a; } else { sumlength = sumlength - LimitDot; } pre = temp; drawpoint = temp; first = false; } pre = *ep; } isFirst = true; /* by embakum °Å¸® ÀÔ·ÂÇϰí double totallength = CalculateLength(pstore); int numberofitems = totallength/LimitDot; if (VectorForm->rzcbUseCount->Checked == false && PatternCount != numberofitems) { ep = (POINT *) pstore->Last(); dx = ep->x - pre.x; dy = ep->y - pre.y; if (dx || dy) rad = atan2(dy, dx); else rad = 0; temp.x = a * cos(rad) + pre.x; temp.y = a * sin(rad) + pre.y; VectorObjectPut(temp, drawpoint); } */ // by embakum Ellipse·Î »Ñ·ÈÀ» ¶§, pstore¿¡ ÀÖ´Â Á¡ÀÌ ÀÏÁ¤ÇÏ°Ô ¼³Á¤µÇ¾îÀÖÁö ¾ÊÀº °ü°è·Î, ¸¶Áö¸·¿¡ »Ñ¸®´Â °ÍÀÌ ´©¶ôµÇ´Â °æ¿ì°¡ ÀÖ´Ù. // ÀÌ °æ¿ì¿¡ pstoreÀÇ ¸¶Áö¸· Á¡À¸·Î temp¸¦ °è»êÇØ¼­ »Ñ·ÁÁØ´Ù. int a = VectorForm->CountEdit->Value; if (VectorForm->rzcbUseCount->Checked == true && PatternCount != a) { ep = (POINT*)pstore->Last(); dx = ep->x - pre.x; dy = ep->y - pre.y; if (dx || dy) rad = atan2(dy, dx); else rad = 0; temp.x = a * cos(rad) + pre.x; temp.y = a * sin(rad) + pre.y; VectorObjectPut(temp, drawpoint); } } } int nCount_after; nCount_after = DataList->Count; for (int i = nCount; i < nCount_after; i++) { data = (TVecData*)DataList->Items[i]; data->bSelected = true; } MakeGroup(); // by embakum 080331 Grouping: À̹øÈ¸ÀÇ »Ñ¸®±â·Î »Ñ·ÁÁø ¿ÀºêÁ§Æ®µéÀ» ¼±ÅÃÇÏ¿© groupingÇØÁØ´Ù for (int i = nCount; i < nCount_after; i++) { // ¼±ÅõǾîÀÖ´Â ¿ÀºêÁ§Æ®ÀÇ ¼±ÅÃÀ» false·Î ¹Ù²ãÁØ´Ù. data = (TVecData*)DataList->Items[i]; data->bSelected = false; } for (int i = 0; i < number; i++) { // ¿ø·¡ ¼±ÅõǾîÀÖ¾ú´ø ¿ÀºêÁ§Æ®(»Ñ¸®´Â ¸ðƼºê)¸¦ ¼±ÅÃÇØÁØ´Ù. data = (TVecData*)DataList->Items[selected[i]]; data->bSelected = true; } // bothÀÇ °æ¿ì, ¿ø·¡ ¼±ÅõǾîÀÖ´ø ¿ÀºêÁ§Æ®¸¦ óÀ½¿¡ if (PosState == SPOS_BOTH) { // »óÇϹÝÀü½ÃÄÑÁØ ¿ÀºêÁ§Æ®µéÀº Áö¿ö¹ö¸°´Ù for (int i = 0; i < number; i++) { data = (TVecData*)DataList->Items[copied[i]]; DataList->Remove(data); UndoSave(VU_DELETE, copied[i]); } } InitData(); MainImageForm->iMainImage->Repaint(); if (selected) delete[]selected; selected = NULL; if (copied) delete[]copied; copied = NULL; return; next: // int nCount_after; nCount_after = DataList->Count; for (int i = nCount; i < nCount_after; i++) { data = (TVecData*)DataList->Items[i]; data->bSelected = true; } MakeGroup(); // by embakum 080331 Grouping: À̹øÈ¸ÀÇ »Ñ¸®±â·Î »Ñ·ÁÁø ¿ÀºêÁ§Æ®µéÀ» ¼±ÅÃÇÏ¿© groupingÇØÁØ´Ù for (int i = nCount; i < nCount_after; i++) { // ¼±ÅõǾîÀÖ´Â ¿ÀºêÁ§Æ®ÀÇ ¼±ÅÃÀ» false·Î ¹Ù²ãÁØ´Ù. data = (TVecData*)DataList->Items[i]; data->bSelected = false; } for (int i = 0; i < number; i++) { // ¿ø·¡ ¼±ÅõǾîÀÖ¾ú´ø ¿ÀºêÁ§Æ®(»Ñ¸®´Â ¸ðƼºê)¸¦ ¼±ÅÃÇØÁØ´Ù. data = (TVecData*)DataList->Items[selected[i]]; data->bSelected = true; } // bothÀÇ °æ¿ì, ¿ø·¡ ¼±ÅõǾîÀÖ´ø ¿ÀºêÁ§Æ®¸¦ óÀ½¿¡ if (PosState == SPOS_BOTH) { // »óÇϹÝÀü½ÃÄÑÁØ ¿ÀºêÁ§Æ®µéÀº Áö¿ö¹ö¸°´Ù for (int i = 0; i < number; i++) { data = (TVecData*)DataList->Items[nCount]; DataList->Remove(data); UndoSave(VU_DELETE, i); } } InitData(); if (selected) delete[]selected; selected = NULL; return; } // --------------------------------------------------------------------------- // by embakum // Circle, Curve¸¦ Á¦¿ÜÇÑ FreeLine, Oblique Line, HV Line, Ellipse, Rectangle·Î ±×¸± °æ¿ì VectorObjectÃß°¡ÇØÁÖ´Â ÇÔ¼ö void __fastcall TVecDraw::VectorObjectPut(POINT sp, POINT ep) { BEGIN_LOG(""); // by embakum ¼±ÅÃµÈ vector objectµéÀÇ bounding rect¸¦ ±¸ÇÑ´Ù. »Ñ¸®±â ¸ðµå¿¡ µû¶ó¼­ bounding rectÀÇ ´ë°¢¼±/2 ¸¸Å­ À̵¿ÇØ ÁÙ °ÍÀÌ´Ù. TList *DataList = NVector->DataList; TVecData *data1, *data2; int nCount = DataList->Count; RECT bound_rect; bound_rect = Rect(10000, 10000, 0, 0); for (int i = 0; i < nCount; i++) { data1 = (TVecData*)DataList->Items[i]; if (data1->bSelected) { bound_rect = Rect(min(bound_rect.left, data1->First.x), min(bound_rect.top, data1->First.y), max(bound_rect.right, data1->Second.x), max(bound_rect.bottom, data1->Second.y)); } } int tx = (bound_rect.right - bound_rect.left) / 2; int ty = (bound_rect.bottom - bound_rect.top) / 2; int dev = sqrt(tx * tx + ty * ty); int deg, CenterX, CenterY, RelativeX, RelativeY; double dx, dy, rad, Tangent, eA, eB; dx = sp.x - ep.x; dy = sp.y - ep.y; Shape = (TSprayShape)VectorForm->ShapeComboBox->ItemIndex; PosState = (TSprayPosState)VectorForm->PositionComboBox->ItemIndex; if (dx || dy || (Shape == SS_ELLIPSE)) { if (Shape != SS_ELLIPSE) rad = atan2(dy, dx); if (Shape == SS_RECT) { if ((First.x - Second.x) > 0) { // °¢µµ¸¦ ´ÙÀ½ÀÇ 4°³·Î ÇÑÁ¤ÇÏ¿´´Ù. if (rad > -M_PI && rad < -M_PI_2) rad = -M_PI_2; if (rad > -M_PI_2 && rad < 0) rad = 0; if (rad > 0 && rad < M_PI_2) rad = M_PI_2; if (rad > M_PI_2 && rad < M_PI) rad = M_PI; } else { if (rad > -M_PI && rad < -M_PI_2) rad = M_PI; if (rad > -M_PI_2 && rad < 0) rad = -M_PI_2; if (rad > 0 && rad < M_PI_2) rad = 0; if (rad > M_PI_2 && rad < M_PI) rad = M_PI_2; } } else if (Shape == SS_ELLIPSE) { // Ÿ¿øÀ϶§´Â À̹ÌÁö°¡ ³õ¿©Áö´Â °¢µµ¸¦ CenterX = (First.x + Second.x) / 2; // Á¢¼±ÀÇ ±â¿ï±â¸¦ ÅëÇØ Á¤ÇÏ¿´´Ù. CenterY = (First.y + Second.y) / 2; RelativeX = ep.x - CenterX; RelativeY = ep.y - CenterY; eA = (First.x - Second.x) / 2; eB = (First.y - Second.y) / 2; if (RelativeY == 0) { if (RelativeX > 0) rad = M_PI_2; else rad = -M_PI_2; } else { // Á¢¼±ÀÇ ±â¿ï±â : -(eB*eB)*(RelativeX)/(eA*eA)/(RelativeY) rad = atan2((eB * eB) * (RelativeX), -(eA * eA) * (RelativeY)); } } deg = 18000 * rad / M_PI; // for RotateBitmapFine (pai / 180000) if (deg < 0) deg = 36000 + deg; } else { deg = 0; } MoveCopyVectorObject(false, 0); VectorForm->MergePosition(ep.x, ep.y, false, true); int cx = (sx + ex) / 2, cy = (sy + ey) / 2; int dx_ = ep.x - cx, dy_ = ep.y - cy; sx += dx_; ex += dx_; sy += dy_; ey += dy_; tempdeg2 = deg; double t_rad = (double)(36000 - tempdeg2) / 18000 * M_PI; if (isFirst || Shape == SS_ELLIPSE || Shape == SS_FREE || Shape == SS_RECT) ObjectRotation(true, (double) - (tempdeg2 - tempdeg1) / 100, false); isFirst = false; switch(PosState) { case SPOS_CENTER: // center break; case SPOS_LEFT: // left MoveCopyVectorObject(true, 0); VectorForm->MergePosition(ep.x - dev * sin(t_rad) / 2, ep.y - dev * cos(t_rad) / 2, false, true); break; case SPOS_RIGHT: // right MoveCopyVectorObject(true, 0); VectorForm->MergePosition(ep.x + dev * sin(t_rad) / 2, ep.y + dev * cos(t_rad) / 2, false, true); break; case SPOS_BOTH: // both break; } tempdeg1 = tempdeg2; sx -= dx_; ex -= dx_; sy -= dy_; ey -= dy_; END_LOG; } // --------------------------------------------------------------------------- /** Vector dataÀÇ First, Second¸¦ ¼³Á¤ÇØÁØ´Ù. * Line°ú Curve¿¡¼­ First, Second´Â °¢°¢ÀÇ ÃÖ´ë, ÃÖ¼Ò Á¡ÀÌ µé¾î°£´Ù. */ void __fastcall TVecDraw::SetRect(TVecData *data) { data->First.x = MaxInt; data->First.y = MaxInt; data->Second.x = 0; data->Second.y = 0; if (data->Kind == V_LINE || data->Kind == V_CURVE) { for (int i = 0; i < data->nCount * 3 + 1; i++) { if (data->pList == NULL) continue; 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; } } else if (data->Kind == V_TEXTBOX && !(data->ListOfAllLine->CurveData)) { for (int i = 0; i < 5; i++) { data->First.x = min(data->First.x, data->pList[i].x); data->First.y = min(data->First.y, data->pList[i].y); data->Second.x = max(data->Second.x, data->pList[i].x); data->Second.y = max(data->Second.y, data->pList[i].y); } } if (data->ParentTextBox) { int Margin; try { Margin = data->ParentTextBox->ListOfAllLine->GetLineTextBox(0) ->lineHeight * 3; } catch(...) { Margin = 0; } data->First.x -= Margin; data->First.y -= Margin; data->Second.x += Margin; data->Second.y += Margin; } } // --------------------------------------------------------------------------- // Vector Cutting Functions // --------------------------------------------------------------------------- /// µÎ object°£¿¡ °ãÄ¡´Â ºÎºÐÀÌ ÀÖ´ÂÁö üũÇÑ´Ù. bool __fastcall TVecDraw::TestIntersection(TVecData *firstData, TVecData *secondData) { BEGIN_LOG(""); HDC dcDst = MainImageForm->iMainImage->Canvas->Handle; int nFillMode; HRGN rgnFst = NULL, rgnSec = NULL, rgnCombine = NULL; bool rtn = true; nFillMode = GetPolyFillMode(dcDst); SetPolyFillMode(dcDst, WINDING); GetRegion(firstData, &rgnFst); GetRegion(secondData, &rgnSec); rgnCombine = CreateRectRgn(0, 0, 1, 1); CombineRgn(rgnCombine, rgnFst, rgnSec, RGN_AND); RECT r; GetRgnBox(rgnCombine, &r); if (r.left == 0 && r.right == 0 && r.top == 0 && r.bottom == 0) rtn = false; SetPolyFillMode(dcDst, nFillMode); if (rgnFst) { DeleteObject(rgnFst); rgnFst = NULL; } if (rgnSec) { DeleteObject(rgnSec); rgnSec = NULL; } if (rgnCombine) { DeleteObject(rgnCombine); rgnCombine = NULL; } END_LOG; return rtn; } // --------------------------------------------------------------------------- /** µÎ Vector object°£ÀÇ ±³Á¡À» ±¸ÇØÁØ´Ù * ÇÑ objectÀÇ regionÀ» ±¸Çؼ­ ±× region¾È¿¡ µé¾î°¡´Â ´Ù¸¥ objectÀÇ ÁÂÇ¥¸¦ ±¸ÇÑ´Ù. */ void __fastcall TVecDraw::FindBezierIntersection(TVecData *firstData, TVecData *secondData, TList *resultList) { // ¿ì¼± °ãÄ¡´Â ºÎºÐÀÌ ÀÖ´ÂÁö ¾ø´ÂÁö üũÇÑ´Ù bool hasIntersection = TestIntersection(firstData, secondData); if (!hasIntersection) return; BEGIN_LOG(""); HRGN rgn = NULL, lineRgn = NULL, insideRgn = NULL; HPEN hPen, hOldPen; HDC dcDst = MainImageForm->iMainImage->Canvas->Handle; int nFillMode; DPOINT pt[4]; DPOINT a3, a2, a1, a0; int division = 512; int length; DPOINT bezierPt; TVecData *dt = NULL, *st = NULL; dt = firstData; st = secondData; nFillMode = GetPolyFillMode(dcDst); SetPolyFillMode(dcDst, WINDING); GetRegion(dt, &lineRgn, 1); GetRegion(dt, &insideRgn, 2); GetRegion(dt, &rgn, 3); ////////////////////////////////// int nPenThick = 1; int inCount = 0; for (int i = 1; i <= nPenThick; i++) { DPOINT prev; prev.x = 0.0; prev.y = 0.0; bool instart = false; // ¿¬¼ÓµÇ¾î ã¾ÆÁö°í ÀÖ´Â °ÍÀÎÁö üũ bool bline = true; // ½ÃÀÛÀº ¶óÀο¡¼­ üũÇϵµ·Ï bool prevline = true; // ÀÌÀü¿¡ ¶óÀο¡¼­ üũÇÑ °ÍÀÎÁö bool nowline = false; // ÇöÀç ¶óÀο¡¼­ üũµÈ °ÍÀÎÁö for (int j = 0; j < (st->nCount) * 3; j += 3) { pt[0] = st->pList[j]; pt[1] = st->pList[j + 1]; pt[2] = st->pList[j + 2]; pt[3] = st->pList[j + 3]; length = sqrt((pt[1].x - pt[0].x) * (pt[1].x - pt[0].x) + (pt[1].y - pt[0].y) * (pt[1].y - pt[0].y)) + sqrt ((pt[2].x - pt[1].x) * (pt[2].x - pt[1].x) + (pt[2].y - pt[1].y) * (pt[2].y - pt[1].y)) + sqrt((pt[3].x - pt[2].x) * (pt[3].x - pt[2].x) + (pt[3].y - pt[2].y) * (pt[3].y - pt[2].y)); division = length * 4; // °¢°¢ÀÇ Á¡µéÀ» °¡Á®¿À´Â ºÎºÐ a3.x = pt[3].x - 3 * pt[2].x + 3 * pt[1].x - pt[0].x; a3.y = pt[3].y - 3 * pt[2].y + 3 * pt[1].y - pt[0].y; a2.x = 3 * pt[2].x - 6 * pt[1].x + 3 * pt[0].x; a2.y = 3 * pt[2].y - 6 * pt[1].y + 3 * pt[0].y; a1.x = 3 * pt[1].x - 3 * pt[0].x; a1.y = 3 * pt[1].y - 3 * pt[0].y; a0.x = pt[0].x; a0.y = pt[0].y; ////////////////// if (rgn) { for (int k = 0; k < division; k++) { bezierPt.x = a3.x * k * k * k / division / division / division + a2.x * k * k / division / division + a1.x * k / division + a0.x; bezierPt.y = a3.y * k * k * k / division / division / division + a2.y * k * k / division / division + a1.y * k / division + a0.y; bool blineRegion = false; // ¼±¿¡ ÇöÀç Á¡(bezierPt)ÀÌ µé¾î°¬´ÂÁö bool bInsideRegion = false; // ¼±À» »« ObjectÀÇ ¾ÈÂÊ ¿µ¿ª¿¡ Á¡ÀÌ µé¾î°¬´ÂÁö bool bAllRegion = false; // ¼±°ú ObjectÀÇ ¾ÈÂÊ¿µ¿ª ¸ðµÎ¸¦ Æ÷ÇÔÇÑ ¿µ¿ª¿¡ Á¡ÀÌ µé¾î°¬´ÂÁö bool inRegion = false; blineRegion = PtInRegion(lineRgn, bezierPt.x, bezierPt.y); // ¼±¿¡ ÇöÀç Á¡(bezierPt)ÀÌ µé¾î°¬³ª bInsideRegion = PtInRegion(insideRgn, bezierPt.x, bezierPt.y); // ¼±À» »« ¿ÀºêÁ§Æ®ÀÇ ¾ÈÂÊ ¿µ¿ª¿¡ Á¡ÀÌ µé¾î°¬³ª bAllRegion = PtInRegion(rgn, bezierPt.x, bezierPt.y); // ¼±°ú ¿ÀºêÁ§Æ® ¾ÈÂÊ¿µ¿ª ¸ðµÎ¸¦ Æ÷ÇÔÇÑ ¿µ¿ª¿¡ Á¡ÀÌ µé¾î°¬³ª if (j == 0 && k == 0) { if (!blineRegion && bInsideRegion) { // BÀÇ Á¡ÀÌ AÀÇ ¾ÈÂÊ ¿µ¿ª¿¡¼­ ½ÃÀÛ bline = true; // BÀÇ Á¡ÀÌ AÀÇ lineÀ§¿¡ ÀÖ´Ù } else { bline = false; } } if (bline) { inRegion = blineRegion; // ¿µ¿ªÀº lineÀÇ ¿µ¿ªÀÌ´Ù nowline = true; // ÇöÀç lineÀ» üũÇϰí ÀÖ´Ù } else { inRegion = bAllRegion; // ¿µ¿ªÀº Àüü ¿µ¿ª(¼±°ú ¾ÈÂÊÀ» Æ÷ÇÔÇÑ)ÀÌ´Ù nowline = false; // ÇöÀç lineÀ» üũÇÏÁö ¾Ê°í ÀÖ´Ù } if (!bline && blineRegion && !bInsideRegion) { // ¼±ÀÌ °ãÄ£(ÀÏÄ¡ÇÏ´Â) °ÍÀ¸·Î »ý°¢ÇÒ ¼ö ÀÖÀ½ if (!prevline) { // ÀÌÀü¿¡´Â ¼±ÀÌ ¾Æ´Ï¾úÀ½. ¿µ¿ª¿¡¼­ ¼±À¸·Î µé¾î¿Ô´Ù. inRegion = false; instart = true; // °ãħÀÌ ½ÃÀ۵Ǿú´Ù } else { inRegion = blineRegion; // ¼± °è¼Ó ÀÏÄ¡ } nowline = true; } else if (!bline && !blineRegion && bInsideRegion) { // ¿µ¿ª ¾È¿¡ µé¾î¿Í ÀÖÀ½ if (prevline) { // ÀÌÀü¿¡´Â ¼±À̾úÀ½. ¼±¿¡¼­ ¿µ¿ªÀ¸·Î µé¾î¿Ô´Ù. inRegion = false; } else { inRegion = bAllRegion; nowline = false; } nowline = false; } if (inRegion) { // µÎ object°¡ ¸¸³­´Ù°í º¼ ¼ö ÀÖÀ½. // ±×·¯³ª A Object¸¦ RegionÈ­ ½ÃÄ×À¸¹Ç·Î(Çȼ¿´ÜÀ§·Î Ç¥ÇöµÊ) ½ÇÁ¦·Î´Â ÇÑ Á¡ÀÌ ¸¸³ªÁö¸¸ // B Object À§ÀÇ ¼±ÀÌ Çѹø ÀÌ»ó ¿µ¿ª ¾È¿¡ µé¾î°¥ ¼öµµ ÀÖ°í // µÎ ObjectÀÇ ¼±ÀÌ °ãÄ¡´Â °æ¿ìµµ ÀÖÀ» ¼ö ÀÖÀ¸¹Ç·Î // ÀÌÀü¿¡ ¿µ¿ª¿¡ µé¾î°£ Á¡(prev)°ú ºñ±³Çؼ­ Â÷À̰¡ 1º¸´Ù Ä¿¾ß Ãß°¡Çϵµ·Ï ÇÑ´Ù. // ÀÌ¹Ì Ãß°¡µÇ¾îÀÖ´Â Á¡(inpt)°úµµ ºñ±³Çؼ­ Â÷À̰¡ 1º¸´Ù ÀÛÀ¸¸é ÀÌ¹Ì Ãß°¡µÈ °ÍÀ¸·Î Ä£´Ù. // Ãß°¡µÇÁö ¾Ê´Â °æ¿ì inCount¸¦ Áõ°¡½ÃÄѼ­ ¾ó¸¶³ª °è¼Ó ¿µ¿ªÀÌ °ãÄ¡´ÂÁö¸¦ üũÇÑ´Ù. int diff = 100; int index = -1; if (resultList->Count > 0) { diff = sqrt((prev.x - bezierPt.x) * (prev.x - bezierPt.x) + (prev.y - bezierPt.y) * (prev.y - bezierPt.y)); if (diff > 1) { bool find = false; int indiff = 0; for (int i = 0; i < resultList->Count; i++) { DPOINT *inpt = (DPOINT*)resultList->Items[i]; indiff = sqrt((inpt->x - bezierPt.x) * (inpt->x - bezierPt.x) + (inpt->y - bezierPt.y) * (inpt->y - bezierPt.y)); if (indiff <= 1) { find = true; break; } } if (!find) { DPOINT *pt = new DPOINT; pt->x = bezierPt.x; pt->y = bezierPt.y; resultList->Add(pt); // Á¡ Ãß°¡ instart = true; // °ãħÀÌ ½ÃÀ۵Ǿú´Ù bline = false; inCount = 0; } else { inCount++; } } else { inCount++; } prev.x = bezierPt.x; prev.y = bezierPt.y; } else { DPOINT *pt = new DPOINT; pt->x = bezierPt.x; pt->y = bezierPt.y; resultList->Add(pt); // Á¡ Ãß°¡ instart = true; // °ãħÀÌ ½ÃÀ۵Ǿú´Ù bline = false; prev.x = bezierPt.x; prev.y = bezierPt.y; } } // --------- else { // °è¼ÓµÇ´Â region³¡ºÎºÐ ã±â if (inCount > 2 && instart) { // instart°¡ trueÀÌ¸é ¼±ÀÌ ±³Â÷µÇ¾î¼­ ¸¸³ªÀÖ´Ù´Â °ÍÀ̰í // inCount°¡ 2º¸´Ù Å« °æ¿ì´Â °ãÄ¡´Â ºÎºÐÀÌ °è¼ÓµÇ¾úÀ½À» ¸»Çϴµ¥ // inRegionÀÌ falseÀ̱⠶§¹®¿¡ °ãÄ¡´Â ºÎºÐÀÌ ³¡³ª´Â ºÎºÐÀÓ. // ¶Ç´Â ¿µ¿ª¿¡¼­ ¼±À¸·Î µé¾î°¥ ¶§µµ ¿©±â ÇØ´çÇÏ°Ô µÈ´Ù. // (¿µ¿ª°ú °è¼Ó ¸¸³ªÀÖ¾úÀ» °ÍÀ̹ǷΠinCount>2, instart´Â true·Î À§¿¡¼­ Á÷Á¢ ³Ö¾îÁØ´Ù.) DPOINT *inpt = (DPOINT*)resultList->Last(); int indiff = sqrt((prev.x - inpt->x) * (prev.x - inpt->x) + (prev.y - inpt->y) * (prev.y - inpt->y)); inCount = 0; instart = false; if (indiff > 1) { DPOINT *pt = new DPOINT; if (PtInRegion(lineRgn, bezierPt.x, bezierPt.y)) { pt->x = bezierPt.x; pt->y = bezierPt.y; if (!prevline && nowline) instart = true; } else { pt->x = prev.x; pt->y = prev.y; } resultList->Add(pt); } } else { inCount = 0; instart = false; } } prevline = nowline; // ---------- } } ///////////////////////// } } SetPolyFillMode(dcDst, nFillMode); if (rgn) { DeleteObject(rgn); rgn = NULL; } if (lineRgn) { DeleteObject(lineRgn); lineRgn = NULL; } if (insideRgn) { DeleteObject(insideRgn); insideRgn = NULL; } DeleteObject(SelectObject(dcDst, hOldPen)); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::FindBezierIntersectionUpgraded(TVecData *firstData, TVecData *secondData, HDC hdc, TList *resultList) { // ¿ì¼± °ãÄ¡´Â ºÎºÐÀÌ ÀÖ´ÂÁö ¾ø´ÂÁö üũÇÑ´Ù // bool _hasIntersection = c(firstData, secondData); // // if (!_hasIntersection) return; DPOINT _ptFirst[4], _ptSecond[4]; DPOINT _f3, _f2, _f1, _f0, _s3, _s2, _s1, _s0; DPOINT _bezierPtFirst, _bezierPtSecond; DPOINT _nearestPt = DPOINT(0, 0); int _divisionFirst = 512, _divisionSecond = 512; int _lengthFirst, _lengthSecond; float _smallestValue = 100; bool _isDirectNearPt = false; // bool _existCrossPoint = false; for (int i = 0; i < (firstData->nCount) * 3; i += 3) { _ptFirst[0] = firstData->pList[i]; _ptFirst[1] = firstData->pList[i + 1]; _ptFirst[2] = firstData->pList[i + 2]; _ptFirst[3] = firstData->pList[i + 3]; for (int j = 0; j < (secondData->nCount) * 3; j += 3) { _ptSecond[0] = secondData->pList[j]; _ptSecond[1] = secondData->pList[j + 1]; _ptSecond[2] = secondData->pList[j + 2]; _ptSecond[3] = secondData->pList[j + 3]; bool _existCrossPoint = false; // °¢ VecDataÀÇ ³× point¸¦ ±âÁØÀ¸·Î »ç°¢Çü ¿µ¿ªÀ» ¸¸µé°í First¿Í SecondÀÇ ÀÌ µÎ ¿µ¿ªÀÌ °ãÄ¡´ÂÁö °Ë»ç // °ãÃÄ¾ß ½ÇÁ¦ Bezier CurveÁß °ãÄ¡´Â°Ô ÀÖ´Ù°í ÆÇ´Ü try { if (isTwoRangeCrossed(hdc, _ptFirst, _ptSecond)) { _existCrossPoint = true; } } catch(...) { _existCrossPoint = false; } if (_existCrossPoint) { _lengthFirst = sqrt((_ptFirst[1].x - _ptFirst[0].x) * (_ptFirst[1].x - _ptFirst[0].x) + (_ptFirst[1].y - _ptFirst[0].y) * (_ptFirst[1].y - _ptFirst[0].y)) + sqrt ((_ptFirst[2].x - _ptFirst[1].x) * (_ptFirst[2].x - _ptFirst[1].x) + (_ptFirst[2].y - _ptFirst[1].y) * (_ptFirst[2].y - _ptFirst[1].y)) + sqrt((_ptFirst[3].x - _ptFirst[2].x) * (_ptFirst[3].x - _ptFirst[2].x) + (_ptFirst[3].y - _ptFirst[2].y) * (_ptFirst[3].y - _ptFirst[2].y)); _divisionFirst = _lengthFirst * 4; // °¢°¢ÀÇ Á¡µéÀ» °¡Á®¿À´Â ºÎºÐ _f3.x = _ptFirst[3].x - 3 * _ptFirst[2].x + 3 * _ptFirst[1].x - _ptFirst [0].x; _f3.y = _ptFirst[3].y - 3 * _ptFirst[2].y + 3 * _ptFirst[1].y - _ptFirst [0].y; _f2.x = 3 * _ptFirst[2].x - 6 * _ptFirst[1].x + 3 * _ptFirst[0].x; _f2.y = 3 * _ptFirst[2].y - 6 * _ptFirst[1].y + 3 * _ptFirst[0].y; _f1.x = 3 * _ptFirst[1].x - 3 * _ptFirst[0].x; _f1.y = 3 * _ptFirst[1].y - 3 * _ptFirst[0].y; _f0.x = _ptFirst[0].x; _f0.y = _ptFirst[0].y; for (int _i = 0; _i < _divisionFirst; _i++) { _bezierPtFirst.x = _f3.x * _i * _i * _i / _divisionFirst / _divisionFirst / _divisionFirst + _f2.x * _i * _i / _divisionFirst / _divisionFirst + _f1.x * _i / _divisionFirst + _f0.x; _bezierPtFirst.y = _f3.y * _i * _i * _i / _divisionFirst / _divisionFirst / _divisionFirst + _f2.y * _i * _i / _divisionFirst / _divisionFirst + _f1.y * _i / _divisionFirst + _f0.y; _lengthSecond = sqrt((_ptSecond[1].x - _ptSecond[0].x) * (_ptSecond[1].x - _ptSecond[0].x) + (_ptSecond[1].y - _ptSecond[0].y) * (_ptSecond[1].y - _ptSecond[0].y)) + sqrt ((_ptSecond[2].x - _ptSecond[1].x) * (_ptSecond[2].x - _ptSecond[1].x) + (_ptSecond[2].y - _ptSecond[1].y) * (_ptSecond[2].y - _ptSecond[1].y)) + sqrt ((_ptSecond[3].x - _ptSecond[2].x) * (_ptSecond[3].x - _ptSecond[2].x) + (_ptSecond[3].y - _ptSecond[2].y) * (_ptSecond[3].y - _ptSecond[2].y)); _divisionSecond = _lengthSecond * 4; // °¢°¢ÀÇ Á¡µéÀ» °¡Á®¿À´Â ºÎºÐ _s3.x = _ptSecond[3].x - 3 * _ptSecond[2].x + 3 * _ptSecond[1] .x - _ptSecond[0].x; _s3.y = _ptSecond[3].y - 3 * _ptSecond[2].y + 3 * _ptSecond[1] .y - _ptSecond[0].y; _s2.x = 3 * _ptSecond[2].x - 6 * _ptSecond[1].x + 3 * _ptSecond[0].x; _s2.y = 3 * _ptSecond[2].y - 6 * _ptSecond[1].y + 3 * _ptSecond[0].y; _s1.x = 3 * _ptSecond[1].x - 3 * _ptSecond[0].x; _s1.y = 3 * _ptSecond[1].y - 3 * _ptSecond[0].y; _s0.x = _ptSecond[0].x; _s0.y = _ptSecond[0].y; for (int _j = 0; _j < _divisionSecond; _j++) { _bezierPtSecond.x = _s3.x * _j * _j * _j / _divisionSecond / _divisionSecond / _divisionSecond + _s2.x * _j * _j / _divisionSecond / _divisionSecond + _s1.x * _j / _divisionSecond + _s0.x; _bezierPtSecond.y = _s3.y * _j * _j * _j / _divisionSecond / _divisionSecond / _divisionSecond + _s2.y * _j * _j / _divisionSecond / _divisionSecond + _s1.y * _j / _divisionSecond + _s0.y; float _length = sqrt(SQR(_bezierPtFirst.x - _bezierPtSecond.x) + SQR (_bezierPtFirst.y - _bezierPtSecond.y)); if (_length < 1) { if (_smallestValue != 100 && sqrt (SQR(_bezierPtFirst.x - _nearestPt.x) + SQR (_bezierPtFirst.y - _nearestPt.y)) > 5) { _smallestValue = 100; if (_bezierPtFirst.x != 0 && _bezierPtFirst.y != 0) { DPOINT *pt = new DPOINT; pt->x = _nearestPt.x; pt->y = _nearestPt.y; if (isStartOrEndPoint(_nearestPt, secondData) == false) { resultList->Add(pt); } else { delete pt; } } } if (_smallestValue > _length) { _smallestValue = _length; _nearestPt = _bezierPtFirst; } } } } } } } DPOINT *pt = new DPOINT; pt->x = _nearestPt.x; pt->y = _nearestPt.y; if (_nearestPt.x != 0 && _nearestPt.y != 0 && isStartOrEndPoint(_nearestPt, secondData) == false) { resultList->Add(pt); } else { delete pt; } } // --------------------------------------------------------------------------- // º¤ÅÍ ¼öµ¿¹Ýº¹¿¡¼­ °ãÄ¡´Â Á¡µéÀ» Ãß°¡Çϰí Index¸¦ ¾Ë·ÁÁÖ´Â ÇÔ¼ö void __fastcall TVecDraw::VecManualRepeatAddPoints(TVecData *RectVecData, TVecData *SelectedVecData, HDC hdc, TList *AddedIndexArray) { // µÎ º¤Å͵éÀÇ Bezier PointµéÀ» ¾Ë±â À§ÇÑ º¯¼ö DPOINT _ptFirst[4], _ptSecond[4]; DPOINT _f3, _f2, _f1, _f0, _s3, _s2, _s1, _s0; DPOINT _bezierPtFirst, _bezierPtSecond; DPOINT _nearestPt = DPOINT(0, 0); DPOINT startControlPt, endControlPt; int _divisionFirst = 512, _divisionSecond = 512; int _lengthFirst, _lengthSecond; int _addCnt = 0; // AddÇÒ¶§ ³Ñ°ÜÁÙ Bezier parameter float t = -1; int CurveNumber = -1; float _smallestValue = 100; bool _isDirectNearPt = false; // Á÷¼±¿¡¼­ ÀÌ Threshold¸¸Å­ ¶³¾îÁ® ÀÖÀ»¶§ °ãÃÆ´Ù°í ÆÇ´Ü float _Threshold = 0.5; // ÇöÀç º¸°í ÀÖ´Â Rect¿¡¼­ ¼öÁ÷/¼öÆò ¾î´À VecÀ» º¸°í ÀÖ´ÂÁö ÆÇ´Ü enum { VERTICAL, HORIZONTAL }_lineType; // ù¹øÂ° º¤ÅÍÀÇ °¢ Bezier Curveº°·Î µ·´Ù for (int i = 0; i < (RectVecData->nCount) * 3; i += 3) { _ptFirst[0] = RectVecData->pList[i]; _ptFirst[1] = RectVecData->pList[i + 1]; _ptFirst[2] = RectVecData->pList[i + 2]; _ptFirst[3] = RectVecData->pList[i + 3]; _addCnt = 0; _smallestValue = 100; _nearestPt = DPOINT(0, 0); // µÎ¹øÂ° º¤ÅÍÀÇ Bezier Curve¸¦ °¡Á®¿Â´Ù // _addCnt¸¸Å­ À̹ø¿¡ ´õÇß´Ù¸é ´ÙÀ½¹ø Bezier Curveµ¹¶§´Â ±× CurveNumber°¡ ´õÇØÁø °¹¼ö¸¸Å­ // CurveNumber¸¦ ¹Ý¿µ½ÃÄÑÁØ´Ù. for (int j = 0; j < (SelectedVecData->nCount) * 3; j += (3 + 3 * _addCnt)) { // ¸î¹ø ´õÇØÁö´ÂÁö üũ -> Çò°¥¸®Áö ¸»°Í : ¿©±â¼­ ´õÇÏ´Â °ÍÀº ÇöÀç Bezier°¡ ¾Æ´Ï¶ó // ±× ÀÌÀü¿¡ °¡Àå °¡±õ´Ù°í ÀúÀåµÇ¾îÀÖ´ø °ªÀÓ _addCnt = 0; _ptSecond[0] = SelectedVecData->pList[j]; _ptSecond[1] = SelectedVecData->pList[j + 1]; _ptSecond[2] = SelectedVecData->pList[j + 2]; _ptSecond[3] = SelectedVecData->pList[j + 3]; // ¸Ç ù¹øÂ° Bezier Curve¸¦ °Ë»çÇÑ´Ù¸é ÀÚ¸£´Â ŸÀÔÀ» ¿©±â¼­ °áÁ¤ÇØÁØ´Ù. if (j == 0) { bool XinRect = (_ptSecond[0].x > RectVecData->First.x && _ptSecond[0] .x < RectVecData->Second.x); bool YinRect = (_ptSecond[0].y > RectVecData->First.y && _ptSecond[0] .y < RectVecData->Second.y); } // ¿µ¿ª¸¸ RegionÀ¸·Î roughÇÏ°Ô °Ë»çÇØ¼­ °ãÄ¡´Â°Ô ÀÖ´ÂÁö 1Â÷ ÆÇ´Ü bool _existCrossPoint = false; // °¢ VecDataÀÇ ³× point¸¦ ±âÁØÀ¸·Î »ç°¢Çü ¿µ¿ªÀ» ¸¸µé°í First¿Í SecondÀÇ ÀÌ µÎ ¿µ¿ªÀÌ °ãÄ¡´ÂÁö °Ë»ç // °ãÃÄ¾ß ½ÇÁ¦ Bezier CurveÁß °ãÄ¡´Â°Ô ÀÖ´Ù°í ÆÇ´Ü if (isTwoRangeCrossed(hdc, _ptFirst, _ptSecond)) { _existCrossPoint = true; } // °ãÃÆ´Ù°í ÆÇ´ÜµÇ¸é, if (_existCrossPoint) { // ¼öÁ÷ Á÷¼± if (_ptFirst[0].x == _ptFirst[2].x && _ptFirst[0].y != _ptFirst[2].y) { _lineType = VERTICAL; if (_ptFirst[0].y > _ptFirst[2].y) { // ÀÛÀº index°¡ topÀÌ µÇ°Ô float temp = _ptFirst[0].y; _ptFirst[0].y = _ptFirst[2].y; _ptFirst[1].y = _ptFirst[2].y; _ptFirst[2].y = temp; _ptFirst[3].y = temp; } } // ¼öÆò Á÷¼± else if (_ptFirst[0].y == _ptFirst[2].y && _ptFirst[0].x != _ptFirst[2] .x) { _lineType = HORIZONTAL; if (_ptFirst[0].x > _ptFirst[2].x) { // ÀÛÀº index°¡ left°¡ µÇ°Ô float temp = _ptFirst[0].x; _ptFirst[0].x = _ptFirst[2].x; _ptFirst[1].x = _ptFirst[2].x; _ptFirst[2].x = temp; _ptFirst[3].x = temp; } } // Bezier CurveÀÇ Àüü ±æÀ̸¦ roughÇÏ°Ô ±¸ÇØÁØ´Ù _lengthSecond = sqrt((_ptSecond[1].x - _ptSecond[0].x) * (_ptSecond[1].x - _ptSecond[0].x) + (_ptSecond[1].y - _ptSecond[0].y) * (_ptSecond[1].y - _ptSecond[0].y) ) + sqrt((_ptSecond[2].x - _ptSecond[1].x) * (_ptSecond[2].x - _ptSecond[1].x) + (_ptSecond[2].y - _ptSecond[1].y) * (_ptSecond[2].y - _ptSecond[1].y) ) + sqrt((_ptSecond[3].x - _ptSecond[2].x) * (_ptSecond[3].x - _ptSecond[2].x) + (_ptSecond[3].y - _ptSecond[2].y) * (_ptSecond[3].y - _ptSecond[2].y) ); // ±× ±æÀÌÀÇ 4¹è ¸¸Å­À» division½ÃÄÑ Bezier PointµéÀ» ±¸Çϰڴ٠(ÀÌ °ªÀº user define value Å©¸é Ŭ¼ö·Ï // Á¤±³ÇÏ°Ô Bezier Point±¸ÇÒ ¼ö ÀÖÀ½) _divisionSecond = _lengthSecond * 4; // °¢°¢ÀÇ Á¡µéÀ» °¡Á®¿À´Â ºÎºÐ _s3.x = _ptSecond[3].x - 3 * _ptSecond[2].x + 3 * _ptSecond[1] .x - _ptSecond[0].x; _s3.y = _ptSecond[3].y - 3 * _ptSecond[2].y + 3 * _ptSecond[1] .y - _ptSecond[0].y; _s2.x = 3 * _ptSecond[2].x - 6 * _ptSecond[1].x + 3 * _ptSecond[0].x; _s2.y = 3 * _ptSecond[2].y - 6 * _ptSecond[1].y + 3 * _ptSecond[0].y; _s1.x = 3 * _ptSecond[1].x - 3 * _ptSecond[0].x; _s1.y = 3 * _ptSecond[1].y - 3 * _ptSecond[0].y; _s0.x = _ptSecond[0].x; _s0.y = _ptSecond[0].y; for (int _i = 0; _i < _divisionSecond; _i++) { // Bezier curve Point¸¦ °¢°¢ ±¸Çϰí _bezierPtSecond.x = _s3.x * _i * _i * _i / _divisionSecond / _divisionSecond / _divisionSecond + _s2.x * _i * _i / _divisionSecond / _divisionSecond + _s1.x * _i / _divisionSecond + _s0.x; _bezierPtSecond.y = _s3.y * _i * _i * _i / _divisionSecond / _divisionSecond / _divisionSecond + _s2.y * _i * _i / _divisionSecond / _divisionSecond + _s1.y * _i / _divisionSecond + _s0.y; // °ãÃÆ´Ù°í ÆÇ´ÜÇØµµ °¡Àå °¡±î¿î °Å¸®¿¡ ÀÖ´Â Á¡¸¸ Add½Ã۱â À§ÇØ ±æÀ̸¦ ÀúÀå float _length; // °ãÃÆ´ÂÁö ÆÇ´Ü bool _isCrossed = false; // ¼öÁ÷, ¼öÆò °æ¿ì¸¦ ³ª´² point°¡ Á÷¼±°ú ¸¸³ª´ÂÁö ÆÇ´ÜÇÑ´Ù. if (_lineType == VERTICAL) { if ((_bezierPtSecond.x >= _ptFirst[0].x - _Threshold) && (_bezierPtSecond.x < _ptFirst[0].x + _Threshold) && (_bezierPtSecond.y >= _ptFirst[0].y) && (_bezierPtSecond.y <= _ptFirst[2].y)) { _isCrossed = true; _length = (_bezierPtSecond.x - _ptFirst[0].x) > 0 ? (_bezierPtSecond.x - _ptFirst[0].x) : - (_bezierPtSecond.x - _ptFirst[0].x); } } else if (_lineType == HORIZONTAL) { if ((_bezierPtSecond.x >= _ptFirst[0].x) && (_bezierPtSecond.x <= _ptFirst[2].x) && (_bezierPtSecond.y >= _ptFirst[0].y - _Threshold) && (_bezierPtSecond.y < _ptFirst[0].y + _Threshold)) { _isCrossed = true; _length = (_bezierPtSecond.y - _ptFirst[0].y) > 0 ? (_bezierPtSecond.y - _ptFirst[0].y) : - (_bezierPtSecond.y - _ptFirst[0].y); } } // °ãÃÆ´Ù¸é if (_isCrossed) { // Á¡Ãß°¡ÇÏ´Â ½ÃÁ¡Àº ÀÌ¹Ì °¡Àå °¡±î¿î Á¡ÀÌ _nearestPt¿¡ ÀúÀåÀÌ µÇ¾îÀÖ°í // ±× ÁÖº¯ÀÇ ¿µ¿ªÀ» ¹þ¾î³ª ´Ù¸¥ °ãÄ¡´Â ¿µ¿ª¿¡ Á¢¾îµé¾úÀ» ¶§ÀÌ´Ù. // _smallestValue°¡ 100ÀÌ ¾Æ´Ï¿©¾ß ±âÁ¸¿¡ °¡±î¿î Á¡À» °®°í ÀÖ´Ù // ±× Á¡°ú ÇöÀç Á¡°úÀÇ °Å¸®°¡ 5ÀÌ»óÀÌ¸é ´Ù¸¥ ¿µ¿ª¿¡ Á¢¾îµé¾ú´Ù°í ÆÇ´Ü // _isDirectNeatPt -> ¸¸¾à, ´Ù¸¥ ¿µ¿ª¿¡¼­ Á¢±ÙÇߴµ¥µµ ±× ÀÌÀü°ú ºñ½ÁÇÑ À§Ä¡ÀÇ Á¡À» Ãß°¡ÇÏ·Á°í ÇÒ¶§µµ Çã¿ë if (_smallestValue != 100 && (sqrt(SQR(_bezierPtSecond.x - _nearestPt.x) + SQR (_bezierPtSecond.y - _nearestPt.y)) > 5 || _isDirectNearPt == false)) { // _smallestValue ÃʱâÈ­ _smallestValue = 100; // 0,0ÀÇ trash value°¡ ¾Æ´Ï¶ó¸é if (_bezierPtSecond.x != 0 && _bezierPtSecond.y != 0) { // Àüü VecDataÀÇ ½ÃÁ¡°ú Á¾Á¡ÀÌ¸é ´õÇØÁÖÁö ¾Ê´Â´Ù. if (isStartOrEndPoint(_nearestPt, SelectedVecData) == false) { int *ptCurveNumber = new int; // CurverNumber¸¦ Çϳª ¿Ã·Á¼­ ´õÇØÁØ´Ù. *ptCurveNumber = CurveNumber + 1; // Control Æ÷ÀÎÆ®À§¿¡ ÀÖ´ÂÁö ¹Þ¾Æ¿Â´Ù // 0 : À§¿¡ ¾ø´Ù 1 : ½ÃÀÛÁ¡¿¡ °¡±õ´Ù 2 : ³¡Á¡¿¡ °¡±õ´Ù int LocatedCase = isLocatedOnControlPoint(startControlPt, endControlPt, _nearestPt); if (LocatedCase == 0) { // _iÀ§Ä¡¿¡ ÀÖ´Â Á¡À» Ãß°¡ÇØÁØ´Ù. VecManualRepeatAddPoint(SelectedVecData, CurveNumber, t); _addCnt++; } else if (LocatedCase == 1) { // ½ÃÀÛÁ¡¿¡ °¡±î¿ì¸é index°¡ Çϳª ¶³¾îÁ®¾ß ÇÑ´Ù. (*ptCurveNumber)--; } bool _enableAdd = true; if (AddedIndexArray->Count > 0) { for (int i = 0; i < AddedIndexArray->Count; i++) { int *index = static_cast(AddedIndexArray->Items[i]); if (LocatedCase != 0 && *index == *ptCurveNumber) { _enableAdd = false; } else if (LocatedCase == 0 && *index >= *ptCurveNumber) { (*index)++; } } } if (_enableAdd) { AddedIndexArray->Add(ptCurveNumber); } else { delete ptCurveNumber; } } } } // »õ·Î µé¾î¿Â Á¡ÀÌ ±âÁ¸¿¡ °¡Àå °¡±î¿ü´ø Á¡º¸´Ù ´õ °¡±õ´Ù¸é ÀÌ Á¡ Á¤º¸·Î ¾÷µ¥ÀÌÆ® if (_smallestValue > _length) { _smallestValue = _length; _nearestPt = _bezierPtSecond; // ±× ´ç½ÃÀÇ VecDataÀÇ Control Point¸¦ ÀúÀåÇØ µÐ´Ù startControlPt = _ptSecond[0]; endControlPt = _ptSecond[3]; // _i´Â Bezier Curve¿¡¼­ ¾î´À Á¡À» ¸»ÇØÁÖ´ÂÁö ¾Ë·ÁÁØ´Ù. t = (float)_i / _divisionSecond; CurveNumber = j / 3 + _addCnt; } // °è¼Ó °°Àº ¿µ¿ªÀ» µ¹°í ÀÖ´Ù. _isDirectNearPt = true; } else { // ´Ù¸¥ ¿µ¿ªÀ¸·Î ºüÁ® ³ª¿Ô´Ù. _isDirectNearPt = false; } } } } // ´Ù µ¹°í ¸¶Áö¸·À̶ó¸é ±× ÀÌÀü¿¡ ÃÖÁ¾ÀûÀ¸·Î °¡Áö°í ÀÖ´ø Á¡À» Add ÇØÁØ´Ù. if (_nearestPt.x != 0 && _nearestPt.y != 0 && isStartOrEndPoint(_nearestPt, SelectedVecData) == false) { int *ptCurveNumber = new int; // CurverNumber¸¦ Çϳª ¿Ã·Á¼­ ´õÇØÁØ´Ù. *ptCurveNumber = CurveNumber + 1; // Control Æ÷ÀÎÆ®À§¿¡ ÀÖ´ÂÁö ¹Þ¾Æ¿Â´Ù // 0 : À§¿¡ ¾ø´Ù 1 : ½ÃÀÛÁ¡¿¡ °¡±õ´Ù 2 : ³¡Á¡¿¡ °¡±õ´Ù int LocatedCase = isLocatedOnControlPoint(startControlPt, endControlPt, _nearestPt); if (LocatedCase == 0) { // _iÀ§Ä¡¿¡ ÀÖ´Â Á¡À» Ãß°¡ÇØÁØ´Ù. VecManualRepeatAddPoint(SelectedVecData, CurveNumber, t); } else if (LocatedCase == 1) { // ½ÃÀÛÁ¡¿¡ °¡±î¿ì¸é index°¡ Çϳª ¶³¾îÁ®¾ß ÇÑ´Ù. (*ptCurveNumber)--; } bool _enableAdd = true; if (AddedIndexArray->Count > 0) { for (int i = 0; i < AddedIndexArray->Count; i++) { int *index = static_cast(AddedIndexArray->Items[i]); if (LocatedCase != 0 && *index == *ptCurveNumber) { _enableAdd = false; } else if (LocatedCase == 0 && *index >= *ptCurveNumber) { (*index)++; } } } if (_enableAdd) { AddedIndexArray->Add(ptCurveNumber); } else { delete ptCurveNumber; } } } } // --------------------------------------------------------------------------- int __fastcall TVecDraw::isLocatedOnControlPoint(DPOINT startCtlPt, DPOINT endCtlPt, DPOINT insertedPt) { float _distance = sqrt(SQR(insertedPt.x - startCtlPt.x) + SQR (insertedPt.y - startCtlPt.y)); if (_distance < 3) { return 1; } _distance = sqrt(SQR(insertedPt.x - endCtlPt.x) + SQR (insertedPt.y - endCtlPt.y)); if (_distance < 3) { return 2; } return 0; } // --------------------------------------------------------------------------- bool __fastcall TVecDraw::isStartOrEndPoint(DPOINT newPoint, TVecData *VecData) { if (VecData->bClosed == true) return false; int VecCount = VecData->nCount; DPOINT ptStart = VecData->pList[0]; DPOINT ptEnd = VecData->pList[(VecCount - 1) * 3 + 3]; float _distance = sqrt(SQR(newPoint.x - ptStart.x) + SQR (newPoint.y - ptStart.y)); if (_distance < 0.5) { return true; } _distance = sqrt(SQR(newPoint.x - ptEnd.x) + SQR(newPoint.y - ptEnd.y)); if (_distance < 0.5) { return true; } return false; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::VecManualRepeatAddPoint(TVecData *vecData, int CurveNumber, float t) { // CurveNumber¿¡ ¼ÓÇÏ´Â Control Point POINT ctrlPoint[4]; // °ª °¡Á®¿À±â ctrlPoint[0] = vecData->pList[CurveNumber * 3].P(); ctrlPoint[1] = vecData->pList[CurveNumber * 3 + 1].P(); ctrlPoint[2] = vecData->pList[CurveNumber * 3 + 2].P(); ctrlPoint[3] = vecData->pList[CurveNumber * 3 + 3].P(); // Add ½ÃÄÑ¾ß ÇÏ´Ï nCount Áõ°¡ vecData->nCount++; // ¸Þ¸ð¸® ÇÒ´ç vecData->pList = (DPOINT*)HeapReAlloc(GetProcessHeap(), 0, vecData->pList, sizeof(DPOINT) * (vecData->nCount * 3 + 1)); vecData->pMask = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, vecData->pMask, (vecData->nCount * 3 + 1) % 8 == 0 ? (vecData->nCount * 3 + 1) / 8 : (vecData->nCount * 3 + 1) / 8 + 1); // if (vecData->pList == NULL) goto fail; HeapCompact(GetProcessHeap(), 0); // AddÇÒ Á¡ ÀÌÈÄ·Î Çϳª¾¿ ¹Ì·ïÁØ´Ù for (int l = vecData->nCount * 3 - 3; l > CurveNumber * 3 + 1; l--) { vecData->pList[l + 3] = vecData->pList[l]; } // ÀâÈù ¼±ÀÌ Á÷¼±ÀÎ °æ¿ì if (ctrlPoint[0].x == ctrlPoint[1].x && ctrlPoint[0].y == ctrlPoint[1] .y && ctrlPoint[2].x == ctrlPoint[3].x && ctrlPoint[2].y == ctrlPoint[3] .y) { vecData->pList[CurveNumber * 3 + 3].x = (1 - t) * (1 - t) * (1 - t) * ctrlPoint[0].x + 3 * (1 - t) * (1 - t) * t * ctrlPoint[1].x + 3 * (1 - t) * t * t * ctrlPoint[2].x + t * t * t * ctrlPoint[3].x; vecData->pList[CurveNumber * 3 + 3].y = (1 - t) * (1 - t) * (1 - t) * ctrlPoint[0].y + 3 * (1 - t) * (1 - t) * t * ctrlPoint[1].y + 3 * (1 - t) * t * t * ctrlPoint[2].y + t * t * t * ctrlPoint[3].y; vecData->pList[CurveNumber * 3 + 2].x = vecData->pList[CurveNumber * 3 + 3] .x; vecData->pList[CurveNumber * 3 + 2].y = vecData->pList[CurveNumber * 3 + 3] .y; vecData->pList[CurveNumber * 3 + 4].x = vecData->pList[CurveNumber * 3 + 3] .x; vecData->pList[CurveNumber * 3 + 4].y = vecData->pList[CurveNumber * 3 + 3] .y; } // °î¼±ÀÎ °æ¿ì else { // »õ·Î »ý±â´Â Á¡ vecData->pList[CurveNumber * 3 + 3].x = (1 - t) * (1 - t) * (1 - t) * ctrlPoint[0].x + 3 * (1 - t) * (1 - t) * t * ctrlPoint[1].x + 3 * (1 - t) * t * t * ctrlPoint[2].x + t * t * t * ctrlPoint[3].x; vecData->pList[CurveNumber * 3 + 3].y = (1 - t) * (1 - t) * (1 - t) * ctrlPoint[0].y + 3 * (1 - t) * (1 - t) * t * ctrlPoint[1].y + 3 * (1 - t) * t * t * ctrlPoint[2].y + t * t * t * ctrlPoint[3].y; // »õ·Î »ý±â´Â Á¡ÀÇ Á¶ÀýÁ¡ 2°³ vecData->pList[CurveNumber * 3 + 2].x = (1 - t) * (1 - t) * ctrlPoint[0].x + 2 * t * (1 - t) * ctrlPoint[1].x + t * t * ctrlPoint [2].x; vecData->pList[CurveNumber * 3 + 2].y = (1 - t) * (1 - t) * ctrlPoint[0].y + 2 * t * (1 - t) * ctrlPoint[1].y + t * t * ctrlPoint [2].y; vecData->pList[CurveNumber * 3 + 4].x = (1 - t) * (1 - t) * ctrlPoint[1].x + 2 * t * (1 - t) * ctrlPoint[2].x + t * t * ctrlPoint [3].x; vecData->pList[CurveNumber * 3 + 4].y = (1 - t) * (1 - t) * ctrlPoint[1].y + 2 * t * (1 - t) * ctrlPoint[2].y + t * t * ctrlPoint [3].y; // ¾ç¿·ÀÇ Á¶ÀýÁ¡ÀÇ º¯È­ vecData->pList[CurveNumber * 3 + 1].x = (1 - t) * ctrlPoint[0].x + t * ctrlPoint[1].x; vecData->pList[CurveNumber * 3 + 1].y = (1 - t) * ctrlPoint[0].y + t * ctrlPoint[1].y; vecData->pList[CurveNumber * 3 + 5].x = (1 - t) * ctrlPoint[2].x + t * ctrlPoint[3].x; vecData->pList[CurveNumber * 3 + 5].y = (1 - t) * ctrlPoint[2].y + t * ctrlPoint[3].y; } } // --------------------------------------------------------------------------- bool __fastcall TVecDraw::isTwoRangeCrossed(HDC hdc, DPOINT* element1, DPOINT* element2) { using namespace gdp; using gdp::Point; Point tempFirst[4], tempSecond[4]; Point First[4], Second[4]; for (int i = 0; i < 4; i++) { tempFirst[i].X = element1[i].x; tempFirst[i].Y = element1[i].y; tempSecond[i].X = element2[i].x; tempSecond[i].Y = element2[i].y; } /* for (int i = 0; i < 4; i++) { First[i].X = element1[i].x; First[i].Y = element1[i].y; Second[i].X = element2[i].x; Second[i].Y = element2[i].y; } */ if ((tempFirst[0].X == tempFirst[1].X && tempFirst[0].Y == tempFirst[1].Y) && (tempFirst[2].X == tempFirst[3].X && tempFirst[2].Y == tempFirst[3].Y)) { if (abs(tempFirst[0].X - tempFirst[2].X) < 2) { First[0].X = tempFirst[0].X - 5; First[1].X = tempFirst[1].X + 5; First[2].X = tempFirst[2].X + 5; First[3].X = tempFirst[3].X - 5; First[0].Y = tempFirst[0].Y; First[1].Y = tempFirst[1].Y; First[2].Y = tempFirst[2].Y; First[3].Y = tempFirst[3].Y; } else { First[0].X = tempFirst[0].X; First[1].X = tempFirst[1].X; First[2].X = tempFirst[2].X; First[3].X = tempFirst[3].X; First[0].Y = tempFirst[0].Y - 5; First[1].Y = tempFirst[1].Y + 5; First[2].Y = tempFirst[2].Y + 5; First[3].Y = tempFirst[3].Y - 5; } } else if ((tempFirst[0].X == tempFirst[1].X) && (tempFirst[2].X == tempFirst[3].X) && (tempFirst[0].X == tempFirst[2].X) ) { First[0].X = tempFirst[0].X - 5; First[1].X = tempFirst[1].X + 5; First[2].X = tempFirst[2].X + 5; First[3].X = tempFirst[3].X - 5; First[0].Y = tempFirst[0].Y; First[1].Y = tempFirst[1].Y; First[2].Y = tempFirst[2].Y; First[3].Y = tempFirst[3].Y; } else if ((tempFirst[0].Y == tempFirst[1].Y) && (tempFirst[2].Y == tempFirst[3].Y) && (tempFirst[0].Y == tempFirst[2].Y) ) { First[0].X = tempFirst[0].X; First[1].X = tempFirst[1].X; First[2].X = tempFirst[2].X; First[3].X = tempFirst[3].X; First[0].Y = tempFirst[0].Y - 5; First[1].Y = tempFirst[1].Y + 5; First[2].Y = tempFirst[2].Y + 5; First[3].Y = tempFirst[3].Y - 5; } else { First[0].X = MIN(MIN(tempFirst[0].X, tempFirst[1].X), MIN(tempFirst[2].X, tempFirst[3].X)); First[0].Y = MIN(MIN(tempFirst[0].Y, tempFirst[1].Y), MIN(tempFirst[2].Y, tempFirst[3].Y)); First[1].X = First[0].X; First[1].Y = MAX(MAX(tempFirst[0].Y, tempFirst[1].Y), MAX(tempFirst[2].Y, tempFirst[3].Y)); First[2].X = MAX(MAX(tempFirst[0].X, tempFirst[1].X), MAX(tempFirst[2].X, tempFirst[3].X)); First[2].Y = MAX(MAX(tempFirst[0].Y, tempFirst[1].Y), MAX(tempFirst[2].Y, tempFirst[3].Y)); First[3].X = MAX(MAX(tempFirst[0].X, tempFirst[1].X), MAX(tempFirst[2].X, tempFirst[3].X)); First[3].Y = First[0].Y; } if ((tempSecond[0].X == tempSecond[1].X && tempSecond[0].Y == tempSecond[1] .Y) && (tempSecond[2].X == tempSecond[3].X && tempSecond[2] .Y == tempSecond[3].Y)) { if (abs(tempSecond[0].X - tempSecond[2].X) < 2) { Second[0].X = tempSecond[0].X - 5; Second[1].X = tempSecond[1].X + 5; Second[2].X = tempSecond[2].X + 5; Second[3].X = tempSecond[3].X - 5; Second[0].Y = tempSecond[0].Y; Second[1].Y = tempSecond[1].Y; Second[2].Y = tempSecond[2].Y; Second[3].Y = tempSecond[3].Y; } else { Second[0].X = tempSecond[0].X; Second[1].X = tempSecond[1].X; Second[2].X = tempSecond[2].X; Second[3].X = tempSecond[3].X; Second[0].Y = tempSecond[0].Y - 5; Second[1].Y = tempSecond[1].Y + 5; Second[2].Y = tempSecond[2].Y + 5; Second[3].Y = tempSecond[3].Y - 5; } } else if ((tempSecond[0].X == tempSecond[1].X) && (tempSecond[2].X == tempSecond[3].X) && (tempSecond[0].X == tempSecond[2].X) ) { Second[0].X = tempSecond[0].X - 5; Second[1].X = tempSecond[1].X + 5; Second[2].X = tempSecond[2].X + 5; Second[3].X = tempSecond[3].X - 5; Second[0].Y = tempSecond[0].Y; Second[1].Y = tempSecond[1].Y; Second[2].Y = tempSecond[2].Y; Second[3].Y = tempSecond[3].Y; } else if ((tempSecond[0].Y == tempSecond[1].Y) && (tempSecond[2].Y == tempSecond[3].Y) && (tempSecond[0].Y == tempSecond[2].Y) ) { Second[0].X = tempSecond[0].X; Second[1].X = tempSecond[1].X; Second[2].X = tempSecond[2].X; Second[3].X = tempSecond[3].X; Second[0].Y = tempSecond[0].Y - 5; Second[1].Y = tempSecond[1].Y + 5; Second[2].Y = tempSecond[2].Y + 5; Second[3].Y = tempSecond[3].Y - 5; } else { Second[0].X = MIN(MIN(tempSecond[0].X, tempSecond[1].X), MIN(tempSecond[2].X, tempSecond[3].X)); Second[0].Y = MIN(MIN(tempSecond[0].Y, tempSecond[1].Y), MIN(tempSecond[2].Y, tempSecond[3].Y)); Second[1].X = Second[0].X; Second[1].Y = MAX(MAX(tempSecond[0].Y, tempSecond[1].Y), MAX(tempSecond[2].Y, tempSecond[3].Y)); Second[2].X = MAX(MAX(tempSecond[0].X, tempSecond[1].X), MAX(tempSecond[2].X, tempSecond[3].X)); Second[2].Y = MAX(MAX(tempSecond[0].Y, tempSecond[1].Y), MAX(tempSecond[2].Y, tempSecond[3].Y)); Second[3].X = MAX(MAX(tempSecond[0].X, tempSecond[1].X), MAX(tempSecond[2].X, tempSecond[3].X)); Second[3].Y = Second[0].Y; } gdp::Graphics graphics(hdc); Point points1[] = { First[0], First[1], First[2], First[3] }; Point points2[] = { Second[0], Second[1], Second[2], Second[3] }; GraphicsPath path1, path2; path1.AddClosedCurve(points1, 4); path2.AddClosedCurve(points2, 4); SolidBrush solidBrush(Color(0, 0, 0, 0)); Region region1(&path1); Region region2(&path2); graphics.FillRegion(&solidBrush, ®ion1); graphics.FillRegion(&solidBrush, ®ion2); region1.Intersect(&path2); if (region1.IsEmpty(&graphics)) { return false; } return true; /* float _MinX1 = MIN(start1.x, end1.x); float _MaxX1 = MAX(start1.x, end1.x); float _MinY1 = MIN(start1.y, end1.y); float _MaxY1 = MAX(start1.y, end1.y); float _MinX2 = MIN(start2.x, end2.x); float _MaxX2 = MAX(start2.x, end2.x); float _MinY2 = MIN(start2.y, end2.y); float _MaxY2 = MAX(start2.y, end2.y); if ((_MinX2 >= _MinX1 && _MinX2 <= _MaxX1 && _MinY2 >= _MinY1 && _MinY2 <= _MaxY1) || (_MaxX2 >= _MinX1 && _MaxX2 <= _MaxX1 && _MaxY2 >= _MinY1 && _MaxY2 <= _MaxY1)) { return true; } else { return false; } float _MinX1 = First[0].X; float _MaxX1 = First[2].X; float _MinY1 = First[0].Y; float _MaxY1 = First[2].Y; float _MinX2 = Second[0].X; float _MaxX2 = Second[2].X; float _MinY2 = Second[0].Y; float _MaxY2 = Second[2].Y; POINT temp[4]; temp[0].x = _MinX2; temp[0].y = _MinY2; temp[1].x = _MinX2; temp[1].y = _MaxY2; temp[2].x = _MaxX2; temp[2].y = _MinY2; temp[3].x = _MaxX2; temp[3].y = _MaxY2; for (int i = 0; i < 4; i++) { if (temp[i].x >= _MinX1 && temp[i].x <= _MaxX1 && temp[i].y >= _MinY1 && temp[i].y <= _MaxY1 ) { return true; } } return false; */ } // --------------------------------------------------------------------------- bool __fastcall TVecDraw::isTwoLineCrossed(DPOINT start1, DPOINT end1, DPOINT start2, DPOINT end2) { int _Gap = 10; if (start1.x == end1.x && start1.y == end1.y || start2.x == end2.x && start2.y == end2.y) { return false; } if (start1.x == end1.x) { if (start2.x == end2.x) { if (start1.x == start2.x) { if ((start2.y >= MIN(start1.y, end1.y) - _Gap && start2.y <= MAX (start1.y, end1.y) + _Gap) || (end2.y >= MIN(start1.y, end1.y) - _Gap && end2.y <= MAX(start1.y, end1.y) + _Gap)) { return true; } } else { return false; } } else { if (start1.x >= MIN(start2.x, end2.x) - _Gap && start1.x <= MAX(start2.x, end2.x) + _Gap) { float _B = (end2.y - start2.y) / (end2.x - start2.x); float _y = _B * (start1.x - start2.x) + start2.y; if (_y >= MIN(start1.y, end1.y) - _Gap && _y <= MAX(start1.y, end1.y) + _Gap) { return true; } else { return false; } } else { return false; } } } else if (start2.x == end2.x) { if (start2.x >= MIN(start1.x, end1.x) - _Gap && start2.x <= MAX(start1.x, end1.x) + _Gap) { float _B = (end1.y - start1.y) / (end1.x - start1.x); float _y = _B * (start2.x - start1.x) + start1.y; if (_y >= MIN(start2.y, end2.y) - _Gap && _y <= MAX(start2.y, end2.y) + _Gap) { return true; } else { return false; } } else { return false; } } float _A = (end1.y - start1.y) / (end1.x - start1.x); float _B = (end2.y - start2.y) / (end2.x - start2.x); if (_A - _B < 0.01 && _A - _B > -0.01) { return false; } float _interX = (_A * start1.x - _B * start2.x - start1.y + start2.y) / (_A - _B); if (_interX >= start1.x - _Gap && _interX <= end1.x + _Gap) { return true; } else { return false; } } // --------------------------------------------------------------------------- bool __fastcall TVecDraw::isVecDataCrossedWithLine(DPOINT Point1, DPOINT Point2, TVecData *vecData) { // ÇöÀç ÀÌ ÇÔ¼ö´Â ¼öÁ÷°ú ¼öÆò Á÷¼±ÀÇ °æ¿ì¸¸ ´Ù·ç°Ú´Ù. ÀÓÀÇÀÇ Á÷¼±¿¡ ´ëÇØ¼­ ÇÏ·Á¸é À§ÀÇ ÇÔ¼ö // ÂüÁ¶ÇÏ¿© ³ª¿­ÀÚ, ÄÚµå Ãß°¡ ÇÏ¸é µÈ´Ù. enum { VERTICAL, HORIZONTAL }_lineType; float _Threshold = 0.5; // Line °ªµéÀ» VecData ÆûÀ¸·Î º¯°æÇϱâ À§ÇØ DPOINT _ptLine[4], fstPoint, secPoint; // fstPoint´Â Left TopÀ¸·Î, secPoint¸¦ Right DownÀ¸·Î fstPoint.x = MIN(Point1.x, Point2.x); fstPoint.y = MIN(Point1.y, Point2.y); secPoint.x = MAX(Point1.x, Point2.x); secPoint.y = MAX(Point1.y, Point2.y); _ptLine[0] = fstPoint; _ptLine[1] = fstPoint; _ptLine[2] = secPoint; _ptLine[3] = secPoint; // ½ÇÁ¦ º¤ÅÍ µ¥ÀÌÅ͵éÀ» °¡Á®¿À±â À§ÇØ DPOINT _ptVec[4]; // ½ÇÁ¦ º¤ÅÍ µ¥ÀÌÅ͵éÀÇ Bezier Point¸¦ °¡Á®¿À±â À§ÇÑ º¯¼öµé float _length, _divisionFirst; DPOINT _f3, _f2, _f1, _f0; DPOINT _bezierPt; // isTwoRangeCrossed È£ÃâÇϱâ À§ÇÑ ºñÆ®¸Ê »ý¼º ::Graphics::TBitmap *bitmap = new ::Graphics::TBitmap; HDC hdc = bitmap->Canvas->Handle; // ¼öÁ÷ Á÷¼± if (fstPoint.x == secPoint.x && fstPoint.y != secPoint.y) { _lineType = VERTICAL; } // ¼öÆò Á÷¼± else if (fstPoint.y == secPoint.y && fstPoint.x != secPoint.x) { _lineType = HORIZONTAL; } // VecDataÀÇ °¢ Bezier Curve Control Point¸¦ µ¹¸é¼­ for (int i = 0; i < (vecData->nCount) * 3; i += 3) { _ptVec[0] = vecData->pList[i]; _ptVec[1] = vecData->pList[i + 1]; _ptVec[2] = vecData->pList[i + 2]; _ptVec[3] = vecData->pList[i + 3]; if (isTwoRangeCrossed(hdc, _ptLine, _ptVec)) { _length = sqrt((_ptVec[1].x - _ptVec[0].x) * (_ptVec[1].x - _ptVec[0].x) + (_ptVec[1].y - _ptVec[0].y) * (_ptVec[1].y - _ptVec[0].y)) + sqrt ((_ptVec[2].x - _ptVec[1].x) * (_ptVec[2].x - _ptVec[1].x) + (_ptVec[2].y - _ptVec[1].y) * (_ptVec[2].y - _ptVec[1].y)) + sqrt ((_ptVec[3].x - _ptVec[2].x) * (_ptVec[3].x - _ptVec[2].x) + (_ptVec[3].y - _ptVec[2].y) * (_ptVec[3].y - _ptVec[2].y)); _divisionFirst = _length * 4; // °¢°¢ÀÇ Á¡µéÀ» °¡Á®¿À´Â ºÎºÐ _f3.x = _ptVec[3].x - 3 * _ptVec[2].x + 3 * _ptVec[1].x - _ptVec[0].x; _f3.y = _ptVec[3].y - 3 * _ptVec[2].y + 3 * _ptVec[1].y - _ptVec[0].y; _f2.x = 3 * _ptVec[2].x - 6 * _ptVec[1].x + 3 * _ptVec[0].x; _f2.y = 3 * _ptVec[2].y - 6 * _ptVec[1].y + 3 * _ptVec[0].y; _f1.x = 3 * _ptVec[1].x - 3 * _ptVec[0].x; _f1.y = 3 * _ptVec[1].y - 3 * _ptVec[0].y; _f0.x = _ptVec[0].x; _f0.y = _ptVec[0].y; for (int _i = 0; _i < _divisionFirst; _i++) { // Bezier curve Point¸¦ °¢°¢ ±¸Çϰí _bezierPt.x = _f3.x * _i * _i * _i / _divisionFirst / _divisionFirst / _divisionFirst + _f2.x * _i * _i / _divisionFirst / _divisionFirst + _f1.x * _i / _divisionFirst + _f0.x; _bezierPt.y = _f3.y * _i * _i * _i / _divisionFirst / _divisionFirst / _divisionFirst + _f2.y * _i * _i / _divisionFirst / _divisionFirst + _f1.y * _i / _divisionFirst + _f0.y; // ¼öÁ÷, ¼öÆò °æ¿ì¸¦ ³ª´² point°¡ Á÷¼±°ú ¸¸³ª´ÂÁö ÆÇ´ÜÇÑ´Ù. if (_lineType == VERTICAL) { if ((_bezierPt.x >= fstPoint.x - _Threshold) && (_bezierPt.x < fstPoint.x + _Threshold) && (_bezierPt.y >= fstPoint.y) && (_bezierPt.y <= secPoint.y)) { // °ãÄ£´Ù DEL(bitmap)return true; } } else if (_lineType == HORIZONTAL) { if ((_bezierPt.x >= fstPoint.x) && (_bezierPt.x <= secPoint.x) && (_bezierPt.y >= fstPoint.y - _Threshold) && (_bezierPt.y < fstPoint.y + _Threshold)) { // °ãÄ£´Ù DEL(bitmap)return true; } } } } } // À§¿¡¼­ return trueµÇÁö ¾Ê¾Ò´Ù¸é °ãÄ¡´Â Á¡ÀÌ ¾ø´Ù DEL(bitmap)return false; } // --------------------------------------------------------------------------- /** ùÁ¡°ú ³¡Á¡ÀÌ °°À» °æ¿ì bClosed¸¸ true·Î ÇØÁÖ°í * ´Ù¸¦ °æ¿ì µÎ Á¡ »çÀ̸¦ À̾îÁØ´Ù. */ // --------------------------------------------------------------------------- void __fastcall TVecDraw::JoinItself(TVecData *data) { BEGIN_LOG(""); data->bClosed = true; if (!pEqual(data->pList[0].P(), data->pList[data->nCount * 3].P())) { 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] = data->pList[data->nCount * 3 - 3]; data->pList[data->nCount * 3 - 1] = data->pList[0]; data->pList[data->nCount * 3] = data->pList[0]; } END_LOG; } // --------------------------------------------------------------------------- /** µÎ ¿ÀºêÁ§Æ®¸¦ ¿¬°á½ÃŲ´Ù. ³¡ Á¡ÀÌ °°¾Æ¾ß ÇÔ. */ bool __fastcall TVecDraw::JoinObjects(TVecData *dstData, TVecData *addData, double X, double Y) { if (dstData->bClosed || addData->bClosed) return false; if (dstData->nCount < 1 || addData->nCount < 1) return false; bool equal = false; bool first1 = false, first2 = false; int tempcount; DPOINT *pPoints1 = NULL, *pPoints2 = NULL; // pPoints1[1024], pPoints2[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) if (dstData->bClosed && dstData->PenStyle == P_SOLID) { pPoints1 = new DPOINT[(dstData->nCount + 1) * 3 + 1]; } else { pPoints1 = new DPOINT[dstData->nCount * 3 + 1]; } if (addData->bClosed && addData->PenStyle == P_SOLID) { pPoints2 = new DPOINT[(addData->nCount + 1) * 3 + 1]; } else { pPoints2 = new DPOINT[addData->nCount * 3 + 1]; } for (int j = 0; j < dstData->nCount * 3 + 1; j++) { pPoints1[j] = dstData->pList[j]; } if (addData->Kind == V_TEXTBOX) { pPoints2 = new DPOINT[5]; } else { if (addData->bClosed && addData->PenStyle == P_SOLID) { pPoints2 = new DPOINT[(addData->nCount + 1) * 3 + 1]; } else { pPoints2 = new DPOINT[addData->nCount * 3 + 1]; } } for (int j = 0; j < addData->nCount * 3 + 1; j++) { pPoints2[j] = addData->pList[j]; } tempcount = dstData->nCount; // dstData->pList = (DPOINT*)HeapReAlloc(GetProcessHeap(), 0, dstData->pList, // sizeof(DPOINT) * ((addData->nCount + tempcount + 1) * 3 + 1)); // dstData->pMask = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, dstData->pMask, // (dstData->nCount * 3 + 1) % 8 == 0 ? (dstData->nCount * 3 + 1) / 8 : // (dstData->nCount * 3 + 1) / 8 + 1); // HeapCompact(GetProcessHeap(), 0); double len01 = sqrt((pPoints1[0].x - X) * (pPoints1[0].x - X) + (pPoints1[0].y - Y) * (pPoints1[0].y - Y)); double len02 = sqrt((pPoints2[0].x - X) * (pPoints2[0].x - X) + (pPoints2[0].y - Y) * (pPoints2[0].y - Y)); if (len01 < 2) { first1 = true; pPoints1[0].x = X; pPoints1[0].y = Y; } if (len02 < 2) { first2 = true; pPoints2[0].x = X; pPoints2[0].y = Y; } if (first1) { if (first2) { // µÑ´Ù ùÁ¡ÀÎ °æ¿ì for (int j = 0; j < tempcount * 3 + 1; j++) { dstData->pList[j] = pPoints1[tempcount * 3 - j]; } // equal = pEqual(temp1[0].P(),temp2[0].P()); if ((pPoints1[0].x - pPoints2[0].x < 1 && pPoints1[0].x - pPoints2[0] .x > -1) && (pPoints1[0].y - pPoints2[0].y < 1 && pPoints1[0] .y - pPoints2[0].y > -1)) { equal = true; } else { equal = false; } if (equal) { dstData->pList = (DPOINT*)HeapReAlloc(GetProcessHeap(), 0, dstData->pList, sizeof(DPOINT) * ((addData->nCount + tempcount) * 3 + 1)); dstData->pMask = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, dstData->pMask, ((addData->nCount + tempcount) * 3 + 1) % 8 == 0 ? ((addData->nCount + tempcount) * 3 + 1) / 8 :((addData->nCount + tempcount) * 3 + 1) / 8 + 1); HeapCompact(GetProcessHeap(), 0); dstData->pList[tempcount * 3 + 1] = pPoints2[1]; dstData->pList[tempcount * 3 + 2] = pPoints2[2]; } else { dstData->pList = (DPOINT*)HeapReAlloc(GetProcessHeap(), 0, dstData->pList, sizeof(DPOINT) * ((addData->nCount + tempcount + 1) * 3 + 1)); dstData->pMask = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, dstData->pMask, ((addData->nCount + tempcount + 1) * 3 + 1) % 8 == 0 ? ((addData->nCount + tempcount + 1) * 3 + 1) / 8 :((addData->nCount + tempcount + 1) * 3 + 1) / 8 + 1); HeapCompact(GetProcessHeap(), 0); dstData->pList[tempcount * 3 + 1] = pPoints1[0]; dstData->pList[tempcount * 3 + 2] = pPoints2[0]; } for (int j = 0; j < (addData->nCount - equal) * 3 + 1; j++) { // µÎ Á¢ÇÕÁ¡ÀÌ °°À¸¸é Á¡Àº Çϳª »ý·« dstData->pList[j + (tempcount + 1) * 3] = pPoints2[j + 3 * equal]; } } else { for (int j = 0; j < tempcount * 3 + 1; j++) { dstData->pList[j] = pPoints1[tempcount * 3 - j]; } if ((pPoints1[0].x - pPoints2[addData->nCount * 3].x < 1 && pPoints1[0] .x - pPoints2[addData->nCount * 3].x > -1) && (pPoints1[0].y - pPoints2[addData->nCount * 3].y < 1 && pPoints1[0] .y - pPoints2[addData->nCount * 3].y > -1)) { equal = true; } else { equal = false; } if (equal) { dstData->pList = (DPOINT*)HeapReAlloc(GetProcessHeap(), 0, dstData->pList, sizeof(DPOINT) * ((addData->nCount + tempcount) * 3 + 1)); dstData->pMask = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, dstData->pMask, ((addData->nCount + tempcount) * 3 + 1) % 8 == 0 ? ((addData->nCount + tempcount) * 3 + 1) / 8 :((addData->nCount + tempcount) * 3 + 1) / 8 + 1); HeapCompact(GetProcessHeap(), 0); dstData->pList[tempcount * 3 + 1] = pPoints2[addData->nCount * 3 - 1]; dstData->pList[tempcount * 3 + 2] = pPoints2[addData->nCount * 3 - 2]; } else { dstData->pList = (DPOINT*)HeapReAlloc(GetProcessHeap(), 0, dstData->pList, sizeof(DPOINT) * ((addData->nCount + tempcount + 1) * 3 + 1)); dstData->pMask = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, dstData->pMask, ((addData->nCount + tempcount + 1) * 3 + 1) % 8 == 0 ? ((addData->nCount + tempcount + 1) * 3 + 1) / 8 :((addData->nCount + tempcount + 1) * 3 + 1) / 8 + 1); HeapCompact(GetProcessHeap(), 0); dstData->pList[tempcount * 3 + 1] = pPoints1[0]; dstData->pList[tempcount * 3 + 2] = pPoints2[addData->nCount * 3]; } for (int j = 0; j < (addData->nCount - equal) * 3 + 1; j++) { if (addData->nCount * 3 - j - 3 * equal < 0) break; // Access ¿¡·¯ ¶§¹®¿¡ ¼öÁ¤ - by monkman (2005.03.29) dstData->pList[j + (tempcount + 1) * 3] = pPoints2 [addData->nCount * 3 - j - 3 * equal]; } } } else { if (first2) { for (int j = 0; j < tempcount * 3 + 1; j++) { dstData->pList[j] = pPoints1[j]; } if ((pPoints1[tempcount * 3].x - pPoints2[0].x < 1 && pPoints1 [tempcount * 3].x - pPoints2[0].x > -1) && (pPoints1[tempcount * 3].y - pPoints2[0].y < 1 && pPoints1 [tempcount * 3].y - pPoints2[0].y > -1)) { equal = true; } else { equal = false; } if (equal) { dstData->pList = (DPOINT*)HeapReAlloc(GetProcessHeap(), 0, dstData->pList, sizeof(DPOINT) * ((addData->nCount + tempcount) * 3 + 1)); dstData->pMask = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, dstData->pMask, ((addData->nCount + tempcount) * 3 + 1) % 8 == 0 ? ((addData->nCount + tempcount) * 3 + 1) / 8 :((addData->nCount + tempcount) * 3 + 1) / 8 + 1); HeapCompact(GetProcessHeap(), 0); dstData->pList[tempcount * 3 + 1] = pPoints2[1]; dstData->pList[tempcount * 3 + 2] = pPoints2[2]; } else { dstData->pList = (DPOINT*)HeapReAlloc(GetProcessHeap(), 0, dstData->pList, sizeof(DPOINT) * ((addData->nCount + tempcount + 1) * 3 + 1)); dstData->pMask = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, dstData->pMask, ((addData->nCount + tempcount + 1) * 3 + 1) % 8 == 0 ? ((addData->nCount + tempcount + 1) * 3 + 1) / 8 :((addData->nCount + tempcount + 1) * 3 + 1) / 8 + 1); HeapCompact(GetProcessHeap(), 0); dstData->pList[tempcount * 3 + 1] = pPoints1[tempcount * 3]; dstData->pList[tempcount * 3 + 2] = pPoints2[0]; } for (int j = 0; j < (addData->nCount - equal) * 3 + 1; j++) { dstData->pList[j + (tempcount + 1) * 3] = pPoints2[j + 3 * equal]; } } else { // µÑ´Ù ³¡Á¡ for (int j = 0; j < tempcount * 3 + 1; j++) { dstData->pList[j] = pPoints1[j]; } if ((pPoints1[tempcount * 3].x - pPoints2[addData->nCount * 3] .x < 1 && pPoints1[tempcount * 3].x - pPoints2[addData->nCount * 3] .x > -1) && (pPoints1[tempcount * 3].y - pPoints2 [addData->nCount * 3].y < 1 && pPoints1[tempcount * 3].y - pPoints2 [addData->nCount * 3].y > -1)) { equal = true; } else { equal = false; } if (equal) { dstData->pList = (DPOINT*)HeapReAlloc(GetProcessHeap(), 0, dstData->pList, sizeof(DPOINT) * ((addData->nCount + tempcount) * 3 + 1)); dstData->pMask = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, dstData->pMask, ((addData->nCount + tempcount) * 3 + 1) % 8 == 0 ? ((addData->nCount + tempcount) * 3 + 1) / 8 :((addData->nCount + tempcount) * 3 + 1) / 8 + 1); HeapCompact(GetProcessHeap(), 0); dstData->pList[tempcount * 3 + 1] = pPoints2[addData->nCount * 3 - 1]; dstData->pList[tempcount * 3 + 2] = pPoints2[addData->nCount * 3 - 2]; } else { dstData->pList = (DPOINT*)HeapReAlloc(GetProcessHeap(), 0, dstData->pList, sizeof(DPOINT) * ((addData->nCount + tempcount + 1) * 3 + 1)); dstData->pMask = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, dstData->pMask, ((addData->nCount + tempcount + 1) * 3 + 1) % 8 == 0 ? ((addData->nCount + tempcount + 1) * 3 + 1) / 8 :((addData->nCount + tempcount + 1) * 3 + 1) / 8 + 1); HeapCompact(GetProcessHeap(), 0); dstData->pList[tempcount * 3 + 1] = pPoints1[tempcount * 3]; dstData->pList[tempcount * 3 + 2] = pPoints2[addData->nCount * 3]; } for (int j = 0; j < (addData->nCount - equal) * 3 + 1; j++) { if (addData->nCount * 3 - j - 3 * equal < 0) break; // Access ¿¡·¯ ¶§¹®¿¡ ¼öÁ¤ - by monkman (2005.03.29) dstData->pList[j + (tempcount + 1) * 3] = pPoints2 [addData->nCount * 3 - j - 3 * equal]; } } } dstData->nCount += (addData->nCount + 1 - equal); if (dstData->pList[0].x - dstData->pList[dstData->nCount * 3] .x < 1 && dstData->pList[0].x - dstData->pList[dstData->nCount * 3] .x > -1 && dstData->pList[0].y - dstData->pList[dstData->nCount * 3] .y < 1 && dstData->pList[0].y - dstData->pList[dstData->nCount * 3] .y > -1) { // if ((int)dstData->pList[0].x == (int)dstData->pList[dstData->nCount*3].x // && (int)dstData->pList[0].y == (int)dstData->pList[dstData->nCount*3].y){ dstData->bClosed = true; dstData->pList[dstData->nCount * 3].x = dstData->pList[0].x; dstData->pList[dstData->nCount * 3].y = dstData->pList[0].y; } SetRect(dstData); if (pPoints1) delete[]pPoints1; pPoints1 = NULL; if (pPoints2) delete[]pPoints2; pPoints2 = NULL; return true; } // --------------------------------------------------------------------------- /** ¼±ÅÃµÈ µÎ object°£¿¡ ¸¸³ª´Â Á¡ÀÌ ÀÖ´ÂÁö¸¦ ÆÇ´ÜÇϰí Àִ°æ¿ì ¼öÇà. 1. µÎ object°¡ ¼±ÅõǾú´ÂÁö È®ÀÎ. 2. °ãħÁ¡ÀÌ ÀÖ´ÂÁö È®ÀÎ. 3. °ãħÁ¡À¸·Î ¼±ÅÃµÈ ¿ÀºêÁ§Æ®µéÀ» ÀÚ¸£°í ¿¬°á½ÃŲ °á°ú¹°µéÀ» ¹Þ¾Æ¿Â´Ù. 4. °á°ú¹°µéÀ» °¢ Item¿¡ µû¶ó ó¸®ÇÑ´Ù. */ void __fastcall TVecDraw::CuttingObjects(int Item, bool Option) { BEGIN_LOG(""); TVecData *firstData, *secondData; TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) int count = 0; int fstIndex = -1, secIndex = -1; RECT rc; // CuttingObject¿¡ hdc¸¦ ³Ñ°ÜÁÖ±â À§ÇØ ::Graphics::TBitmap *bitmap = new ::Graphics::TBitmap; HDC hdc = bitmap->Canvas->Handle; rc.top = MaxInt; rc.bottom = 0; rc.left = MaxInt; rc.right = 0; if (Item == 4) { for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->Kind == V_TEXT || data->Kind == V_TEXTBOX || data->ParentTextBox) continue; if (count == 0) { count++; firstData = data; fstIndex = i; rc.top = min(rc.top, min(data->First.y, data->Second.y)) - data->PenThick * 2; rc.bottom = max(rc.bottom, max(data->First.y, data->Second.y)) + data->PenThick * 2; rc.left = min(rc.left, min(data->First.x, data->Second.x)) - data->PenThick * 2; rc.right = max(rc.right, max(data->First.x, data->Second.x)) + data->PenThick * 2; } else { count++; secondData = data; secIndex = i; rc.top = min(rc.top, min(data->First.y, data->Second.y)) - data->PenThick * 2; rc.bottom = max(rc.bottom, max(data->First.y, data->Second.y)) + data->PenThick * 2; rc.left = min(rc.left, min(data->First.x, data->Second.x)) - data->PenThick * 2; rc.right = max(rc.right, max(data->First.x, data->Second.x)) + data->PenThick * 2; } if (count > 1) { // && firstData->bClosed && secondData->bClosed) { CuttingTwoObjects(Item, firstData, secondData, fstIndex, secIndex, hdc); MainImageForm->iMainImage->RectPaint(rc); } // else { // // ´ÝÈù ¿ÀºêÁ§Æ®¸¦ ¼±ÅÃÇØ ÁֽʽÿÀ. // Application->MessageBox(IDS_MESSAGE008.c_str(), L"Information", MB_OK); // } } } else { // µü µÎ°³ÀÇ °´Ã¼¸¸ ¼±ÅõǾî ÀÖ¾î¾ß ÇÔ. for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->Kind == V_TEXT || data->Kind == V_TEXTBOX || data->ParentTextBox) continue; if (count == 0) { firstData = data; fstIndex = i; rc.top = min(rc.top, min(data->First.y, data->Second.y)) - data->PenThick * 2; rc.bottom = max(rc.bottom, max(data->First.y, data->Second.y)) + data->PenThick * 2; rc.left = min(rc.left, min(data->First.x, data->Second.x)) - data->PenThick * 2; rc.right = max(rc.right, max(data->First.x, data->Second.x)) + data->PenThick * 2; } else if (count == 1) { secondData = data; secIndex = i; rc.top = min(rc.top, min(data->First.y, data->Second.y)) - data->PenThick * 2; rc.bottom = max(rc.bottom, max(data->First.y, data->Second.y)) + data->PenThick * 2; rc.left = min(rc.left, min(data->First.x, data->Second.x)) - data->PenThick * 2; rc.right = max(rc.right, max(data->First.x, data->Second.x)) + data->PenThick * 2; } count++; } if (count == 2 && firstData->bClosed && secondData->bClosed) { CuttingTwoObjects(Item, firstData, secondData, fstIndex, secIndex, hdc); MainImageForm->iMainImage->RectPaint(rc); } else { // ´ÝÈù ¿ÀºêÁ§Æ®¸¦ ¼±ÅÃÇØ ÁֽʽÿÀ. Application->MessageBox(IDS_MESSAGE008.c_str(), L"Information", MB_OK); } } DEL(bitmap)END_LOG; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::ManualRepeatCuttingObjects(TList *DataList) { BEGIN_LOG(""); TVecData *firstData, *secondData; int count = 0; int fstIndex = -1, secIndex = -1; StatusProgress->InitPosition(); StatusProgress->Maximum = 100; TList *AddedIndexArray = new TList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) ::Graphics::TBitmap *bitmap = new ::Graphics::TBitmap; HDC hdc = bitmap->Canvas->Handle; int dataCnt = DataList->Count; for (int i = 0; i < dataCnt; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (!data->bSelected) continue; if (data->Kind == V_TEXT || data->Kind == V_TEXTBOX || data->ParentTextBox) continue; // DataListÀÇ Ã¹ DataÀº ¹üÀ§¸¦ ¾Ë·ÁÁÖ´Â Rect µ¥ÀÌÅÍÀÓÀ» °¡Á¤ if (count == 0) { count++; firstData = data; fstIndex = i; } // ±× ÀÌÈÄÀÇ Vec DataµéÀ» ù µ¥ÀÌÅÍÀÎ ¹üÀ§ Rect°ú ºñ±³ÇØÁØ´Ù. else { count++; secondData = data; secIndex = i; } if (count > 1) { while (AddedIndexArray->Count > 0) { int *_index = (int*)AddedIndexArray->Last(); AddedIndexArray->Remove(_index); delete _index; } VecManualRepeatAddPoints(firstData, secondData, hdc, AddedIndexArray); if (AddedIndexArray->Count > 0) SegmentVecData(DataList, i, AddedIndexArray, 0); else { TVecData *tmpData = new TVecData(data->GetInstNum()); tmpData->Copy(data); tmpData->bClosed = data->bClosed; DataList->Add(tmpData); delete data; data = NULL; DataList->Items[i] = NULL; } } StatusProgress->Position = 100 * ((float)(i + 1) / (float)dataCnt); } StatusProgress->End(); DEL(bitmap) while (AddedIndexArray->Count > 0) { int *_index = (int*)AddedIndexArray->Last(); AddedIndexArray->Remove(_index); delete _index; } DEL(AddedIndexArray); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::CuttingTwoObjects(int Item, TVecData *firstData, TVecData *secondData, int fstIndex, int secIndex, HDC hdc) { TList *IntersectionPtList, *IntersectionPtList1, *IntersectionPtList2; IntersectionPtList = new TList; FindBezierIntersectionUpgraded(firstData, secondData, hdc, IntersectionPtList); if (IntersectionPtList->Count > 1) { TList *resultList = new TList; // 2. °ãħÁ¡À¸·Î ¼±ÅÃµÈ ¿ÀºêÁ§Æ®µéÀ» ÀÚ¸£°í ¿¬°á½ÃŲ °á°ú¹°µéÀ» ¹Þ¾Æ¿Â´Ù. bool cutted = Cutting(resultList, IntersectionPtList, firstData, secondData, Item); // 3. °á°ú¹°µéÀ» °¢ Item¿¡ µû¶ó ó¸®ÇÑ´Ù. if (cutted && resultList->Count > 0) { MakeResult(resultList, firstData, secondData, fstIndex, secIndex, Item, true); } DeleteVecList(resultList); delete resultList; } else { // °ãÄ¡´Â Á¡À» ãÀ» ¼ö ¾ø½À´Ï´Ù. Application->MessageBox(IDS_MESSAGE009.c_str(), L"Information", MB_OK); } while (IntersectionPtList->Count > 0) { DPOINT *pt = (DPOINT*)IntersectionPtList->Last(); IntersectionPtList->Remove(pt); delete pt; } delete IntersectionPtList; } // --------------------------------------------------------------------------- bool __fastcall TVecDraw::isVecinRect(TVecData *RectData, TVecData *VecData) { // // RectÀÎ °æ¿ì¸¸ ó¸®ÇϹǷΠ4°³ // DPOINT _ptRect[4]; // // // RectÀÇ ¾ç³¡Á¡µéÀ» ¹Þ¾Æ¿Â´Ù. // for (int i = 0; i < RectData->Count; i++) { // _ptRect[i] = RectData->pList[3*i]; // } // ¹«°Ô Á᫐ Á¡ ÁÂÇ¥ DPOINT _CenterOfMass = DPOINT(0, 0); // °¢ º¤ÅÍÀÇ Ã¹Á¡°ú ³¡Á¡µéÀ» µ¹¸é¼­ ¸ðµÎ ´õÇØÁØ´Ù for (int i = 0; i < VecData->nCount; i++) { _CenterOfMass.x = _CenterOfMass.x + (VecData->pList[3 * i]).x; _CenterOfMass.y = _CenterOfMass.y + (VecData->pList[3 * i]).y; } // ¹«°ÔÁß½ÉÀ» ±¸ÇÑ´Ù _CenterOfMass.x = _CenterOfMass.x / (double)VecData->nCount; _CenterOfMass.y = _CenterOfMass.y / (double)VecData->nCount; // ¹«°ÔÁß½ÉÀÌ ¹Ù¿î´õ¸® ¾È¿¡ ÀÖ´ÂÁö °Ë»ç bool XinRect = (_CenterOfMass.x > RectData->First.x && _CenterOfMass.x < RectData->Second.x); bool YinRect = (_CenterOfMass.y > RectData->First.y && _CenterOfMass.y < RectData->Second.y); // °á°ú ¸®ÅÏ if (XinRect && YinRect) return true; else return false; } // --------------------------------------------------------------------------- /** ½ÇÁ¦·Î ÀÚ¸£°í ºÙ¿©¼­ ResultList¿¡ ´ã¾Æ ¹ÝÈ¯ÇØ ÁÖ´Â ÀÏÀ» ÇÑ´Ù. 1. °¢ object°¡ ¸¸³ª´Â À§Ä¡¿¡ Á¡ Ãß°¡ 2. µÎ objectÀÇ regionÀ» ±¸ÇÑ´Ù. (°¢ »ó´ëÆí object¿¡ ¼ÓÇÏ´Â ºÎºÐ°ú ¾Æ´Ñ ºÎºÐÀÇ ±¸ºÐÀ» À§ÇØ ÇÊ¿ä) 3. Ãß°¡ÇÑ Á¡À» ¼ø¼­´ë·Î Àß¶ó¼­ ºÐ¸®ÇصдÙ. 4. °¢ modeº°·Î segmentµéÀ» ¿¬°áÇØÁØ´Ù. */ bool __fastcall TVecDraw::Cutting(TList *ResultList, TList *IntersectionPtList, TVecData *FstData, TVecData *SecData, int CuttingItem) { BEGIN_LOG(""); TList *fstSegmentIn = NULL, *fstSegmentOut = NULL, *secSegmentIn = NULL, *secSegmentOut = NULL; TList *sameSegments = NULL; bool rtn = true; HRGN fstRgn = NULL, secRgn = NULL, rgnCombine = NULL; TVecData *tempFst, *tempSec; tempFst = new TVecData(MainImageForm->Number); tempSec = new TVecData(MainImageForm->Number); tempFst->Copy(FstData); tempSec->Copy(SecData); int findPointCount = IntersectionPtList->Count; int *fpt = new int[findPointCount]; int *spt = new int[findPointCount]; // 1. Á¡ Ãß°¡ // ÆíÀǸ¦ À§ÇØ Ãß°¡µÈ Á¡µéÀ» ¼ø¼­´ë·Î ³ª¿­. fpt, spt¿¡ Ãß°¡µÈ Á¡ÀÇ index¸¦ °¡Áö°íÀִ´Ù. // ±×·¸°Ô ÇÏÁö ¾ÊÀ¸¸é ÀÚ¸¦ ¶§ ¿ø·¡ÀÇ object°¡ ¾Æ´Ñ Àß·ÁÁø object¿¡¼­ Á¡À» ã¾Æ¾ß ÇÏ´Â ¹®Á¦°¡ »ý±è. bool bAddPoints = AddPointObjects(tempFst, tempSec, IntersectionPtList, fpt, spt); if (bAddPoints) { HRGN fRgn = NULL, sRgn = NULL; // GetRegion(tempFst, &fRgn, 2); // test // GetRegion(tempSec, &sRgn, 2); GetRegion(tempFst, &fRgn); GetRegion(tempSec, &sRgn); rgnCombine = CreateRectRgn(0, 0, 0, 0); CombineRgn(rgnCombine, fRgn, sRgn, RGN_AND); if (fRgn) { DeleteObject(fRgn); fRgn = NULL; } if (sRgn) { DeleteObject(sRgn); sRgn = NULL; } // 2. µÎ objectÀÇ regionÀ» ±¸ÇÑ´Ù. °¢ »ó´ëÆí object¿¡ ¼ÓÇÏ´Â ºÎºÐ°ú ¾Æ´Ñ ºÎºÐÀÇ ±¸ºÐÀ» À§ÇØ ÇÊ¿ä. // GetRegion(tempFst, &fstRgn, 2); //test // GetRegion(tempSec, &secRgn, 2); GetRegion(tempFst, &fstRgn); GetRegion(tempSec, &secRgn); // 3. Ãß°¡ÇÑ Á¡À» ¼ø¼­´ë·Î Àß¶ó¼­ ºÐ¸®. fstSegmentIn = new TList; fstSegmentOut = new TList; secSegmentIn = new TList; secSegmentOut = new TList; sameSegments = new TList; bool bMakeSegments = MakeSegments(tempFst, tempSec, findPointCount, fpt, spt, fstRgn, secRgn, rgnCombine, fstSegmentIn, fstSegmentOut, secSegmentIn, secSegmentOut, sameSegments, FstData->bClosed, SecData->bClosed); if (fstRgn) { DeleteObject(fstRgn); fstRgn = NULL; } if (secRgn) { DeleteObject(secRgn); secRgn = NULL; } if (rgnCombine) { DeleteObject(rgnCombine); rgnCombine = NULL; } if (bMakeSegments) { // 4. °¢ modeº°·Î segmentµéÀ» ¿¬°áÇØÁØ´Ù. /* bool run = false; switch (CuttingItem){ case C_MERGE: // merge objects // ÀÌ °æ¿ì »ó´ë¹æ ¿ÀºêÁ§Æ®¿¡ ¼ÓÇÏÁö ¾Ê´Â segmentµé(out)¸¸ ã¾Æ °°Àº Æ÷ÀÎÆ®¸¦ °¡Áø ¿ÀºêÁ§Æ®³¢¸® ¿¬°á½ÃÄÑÁØ´Ù. if (fstSegmentOut->Count == secSegmentOut->Count) run = true; if (fstSegmentOut->Count > secSegmentOut->Count){ if (secSegmentOut->Count + sameSegments->Count > fstSegmentOut->Count) run = true; } if (fstSegmentOut->Count < secSegmentOut->Count){ if (fstSegmentOut->Count + sameSegments->Count > secSegmentOut->Count) run = true; } if (run) JoinSegments(ResultList, IntersectionPtList, fstSegmentOut, secSegmentOut, sameSegments, CuttingItem); break; case C_CUT_BOTTOM: // À§ ÂÊ ¿ÀºêÁ§Æ®(SecData)·Î ¾Æ·¡ ¿ÀºêÁ§Æ®(FstData)¸¦ Àß¶ó³¿. (¾ÕÂÊ À妽º°¡ ¾Æ·¡ÂÊ) if (fstSegmentOut->Count == secSegmentIn->Count) run = true; if (fstSegmentOut->Count > secSegmentIn->Count){ if (secSegmentIn->Count + sameSegments->Count > fstSegmentOut->Count) run = true; } if (fstSegmentOut->Count < secSegmentIn->Count){ if (fstSegmentOut->Count + sameSegments->Count > secSegmentIn->Count) run = true; } if (run) JoinSegments(ResultList, IntersectionPtList, fstSegmentOut, secSegmentIn, sameSegments, CuttingItem); break; case C_CUT_FRONT: // ¾Æ·¡ ÂÊ ¿ÀºêÁ§Æ®(FstData)·Î À§ ¿ÀºêÁ§Æ®(SecData)¸¦ Àß¶ó³¿. (¾ÕÂÊ À妽º°¡ ¾Æ·¡ÂÊ) if (secSegmentOut->Count == fstSegmentIn->Count) run = true; if (secSegmentOut->Count > fstSegmentIn->Count){ if (fstSegmentIn->Count + sameSegments->Count > secSegmentOut->Count) run = true; } if (secSegmentOut->Count < fstSegmentIn->Count){ if (secSegmentOut->Count + sameSegments->Count > fstSegmentIn->Count) run = true; } if (run) JoinSegments(ResultList, IntersectionPtList, secSegmentOut, fstSegmentIn, sameSegments, CuttingItem); break; case C_MAKE_INTERSECTION: // óÀ½ µÎ ¿ÀºêÁ§Æ®ÀÇ ¼ø¼­¸¦ ¹Ù²ãÁÖ¾î¾ß »ý¼ºµÈ ¿ÀºêÁ§Æ®¸¦ ±¸ºÐÇÒ ¼ö ÀÖ´Ù. if (secSegmentIn->Count == fstSegmentIn->Count) run = true; if (secSegmentIn->Count > fstSegmentIn->Count){ if (fstSegmentIn->Count + sameSegments->Count > secSegmentIn->Count) run = true; } if (secSegmentIn->Count < fstSegmentIn->Count){ if (secSegmentIn->Count + sameSegments->Count > fstSegmentIn->Count) run = true; } if (run) JoinSegments(ResultList, IntersectionPtList, secSegmentIn, fstSegmentIn, sameSegments, CuttingItem); break; } */ ///* if ((fstSegmentIn->Count == fstSegmentOut->Count && secSegmentIn->Count == secSegmentOut->Count) || (fstSegmentIn->Count + secSegmentIn->Count == fstSegmentOut->Count + secSegmentOut->Count) || (fstSegmentIn->Count == secSegmentIn->Count && fstSegmentOut->Count == secSegmentOut->Count) || 1) { // 4. °¢ modeº°·Î segmentµéÀ» ¿¬°áÇØÁØ´Ù. switch(CuttingItem) { case C_MERGE: // merge objects // ÀÌ °æ¿ì »ó´ë¹æ ¿ÀºêÁ§Æ®¿¡ ¼ÓÇÏÁö ¾Ê´Â segmentµé(out)¸¸ ã¾Æ °°Àº Æ÷ÀÎÆ®¸¦ °¡Áø ¿ÀºêÁ§Æ®³¢¸® ¿¬°á½ÃÄÑÁØ´Ù. JoinSegments(ResultList, IntersectionPtList, fstSegmentOut, secSegmentOut, sameSegments, CuttingItem); break; case C_CUT_BOTTOM: // À§ ÂÊ ¿ÀºêÁ§Æ®(SecData)·Î ¾Æ·¡ ¿ÀºêÁ§Æ®(FstData)¸¦ Àß¶ó³¿. (¾ÕÂÊ À妽º°¡ ¾Æ·¡ÂÊ) JoinSegments(ResultList, IntersectionPtList, fstSegmentOut, secSegmentIn, sameSegments, CuttingItem); break; case C_CUT_FRONT: // ¾Æ·¡ ÂÊ ¿ÀºêÁ§Æ®(FstData)·Î À§ ¿ÀºêÁ§Æ®(SecData)¸¦ Àß¶ó³¿. (¾ÕÂÊ À妽º°¡ ¾Æ·¡ÂÊ) JoinSegments(ResultList, IntersectionPtList, secSegmentOut, fstSegmentIn, sameSegments, CuttingItem); break; case C_MAKE_INTERSECTION: // óÀ½ µÎ ¿ÀºêÁ§Æ®ÀÇ ¼ø¼­¸¦ ¹Ù²ãÁÖ¾î¾ß »ý¼ºµÈ ¿ÀºêÁ§Æ®¸¦ ±¸ºÐÇÒ ¼ö ÀÖ´Ù. JoinSegments(ResultList, IntersectionPtList, secSegmentIn, fstSegmentIn, sameSegments, CuttingItem); break; case C_EACH_CUT: JoinSegments(ResultList, IntersectionPtList, secSegmentIn, fstSegmentIn, sameSegments, CuttingItem); break; } } // */ } else { if (tempFst) delete tempFst; if (tempSec) delete tempSec; rtn = false; } } else { if (tempFst) delete tempFst; if (tempSec) delete tempSec; rtn = false; } if (fpt) delete[]fpt; fpt = NULL; if (spt) delete[]spt; spt = NULL; if (fstSegmentIn) { DeleteVecList(fstSegmentIn); delete fstSegmentIn; } if (fstSegmentOut) { DeleteVecList(fstSegmentOut); delete fstSegmentOut; } if (secSegmentIn) { DeleteVecList(secSegmentIn); delete secSegmentIn; } if (secSegmentOut) { DeleteVecList(secSegmentOut); delete secSegmentOut; } if (sameSegments) { DeleteVecList(sameSegments); delete sameSegments; } END_LOG; return rtn; } // --------------------------------------------------------------------------- /// Vector data°¡ µé¾îÀÖ´Â ListÀÇ Vector dataµéÀ» Áö¿öÁØ´Ù. void __fastcall TVecDraw::DeleteVecList(TList *list) { while (list->Count > 0) { TVecData *data = (TVecData*)list->Last(); list->Remove(data); if (data) delete data; } } // --------------------------------------------------------------------------- double __fastcall TVecDraw::GetRoughLength(TVecData *data, int seg) { TVecData *tempData = new TVecData(MainImageForm->Number); tempData->Copy(data); bool makeSegment = true; if (data->nCount == 1 && ((data->pList[0].x == data->pList[1].x) && (data->pList[0].y == data->pList[1].y)) && ((data->pList[2].x == data->pList[3].x) && (data->pList[2].y == data->pList[3].y))){ makeSegment = false; } if (makeSegment) ConvertZigZag(tempData, 0, seg); double len = 0; for (int i = 0; i < tempData->nCount * 3 + 1; i += 3) { int x1 = tempData->pList[i].x; int x2 = tempData->pList[i + 3].x; int y1 = tempData->pList[i].y; int y2 = tempData->pList[i + 3].y; len += sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); } delete tempData; return len; } // --------------------------------------------------------------------------- /** vector object¿¡ Á¡À» Ãß°¡ÇÑ´Ù. ¸Ç ù Á¡À» Ãß°¡ÇÑ ÈÄ Àß¶ó³õ°í ½ÃÀÛÇÑ´Ù. ±×·¸Áö ¾ÊÀ» °æ¿ì Á¡ ¼ø¼­°¡ ¹Ù²ð ¼ö ÀÖ´Ù. */ bool __fastcall TVecDraw::AddPointObjects(TVecData *tempFst, TVecData *tempSec, TList *PtList, int *fpt, int *spt) { BEGIN_LOG(""); DPOINT *pt = (DPOINT*)PtList->Items[0]; fpt[0] = AddPointInVecData(tempFst, pt->x, pt->y); spt[0] = AddPointInVecData(tempSec, pt->x, pt->y); if (fpt[0] < 0 || spt[0] < 0) { END_LOG; return false; } if (tempFst->bClosed) { KnifeInVecData(tempFst, fpt[0] * 3); } if (tempSec->bClosed) { KnifeInVecData(tempSec, spt[0] * 3); } for (int i = 1; i < PtList->Count; i++) { DPOINT *pt = (DPOINT*)PtList->Items[i]; fpt[i] = AddPointInVecData(tempFst, pt->x, pt->y); spt[i] = AddPointInVecData(tempSec, pt->x, pt->y); if (fpt[i] < 0 || spt[i] < 0) { END_LOG; return false; } // °°Àº À§Ä¡¿¡ Ãß°¡ÇÑ Á¡µµ ´Þ¶óÁú ¼ö ÀÖÀ¸¹Ç·Î Ãß°¡ÇÑ À§Ä¡¸¦ ´Ù½Ã ³Ö¾îÁØ´Ù. if (tempFst->pList[fpt[i] * 3 - 1].x == tempFst->pList[fpt[i] * 3 + 1] .x && tempFst->pList[fpt[i] * 3 - 1].y == tempFst->pList[fpt[i] * 3 + 1] .y) { tempFst->pList[fpt[i] * 3 - 1].x = pt->x; tempFst->pList[fpt[i] * 3].x = pt->x; tempFst->pList[fpt[i] * 3 + 1].x = pt->x; tempFst->pList[fpt[i] * 3 - 1].y = pt->y; tempFst->pList[fpt[i] * 3].y = pt->y; tempFst->pList[fpt[i] * 3 + 1].y = pt->y; } else { tempFst->pList[fpt[i] * 3].x = pt->x; tempFst->pList[fpt[i] * 3].y = pt->y; } if (tempSec->pList[spt[i] * 3 - 1].x == tempSec->pList[spt[i] * 3 + 1] .x && tempSec->pList[spt[i] * 3 - 1].y == tempSec->pList[spt[i] * 3 + 1] .y) { tempSec->pList[spt[i] * 3 - 1].x = pt->x; tempSec->pList[spt[i] * 3].x = pt->x; tempSec->pList[spt[i] * 3 + 1].x = pt->x; tempSec->pList[spt[i] * 3 - 1].y = pt->y; tempSec->pList[spt[i] * 3].y = pt->y; tempSec->pList[spt[i] * 3 + 1].y = pt->y; } else { tempSec->pList[spt[i] * 3].x = pt->x; tempSec->pList[spt[i] * 3].y = pt->y; } for (int j = 0; j < i; j++) { if (fpt[i] <= fpt[j]) { fpt[j] = fpt[j] + 1; } if (spt[i] <= spt[j]) { spt[j] = spt[j] + 1; } } } END_LOG; return true; } // --------------------------------------------------------------------------- /// vector objectÀÇ regionÀ» ±¸ÇØÁØ´Ù. void __fastcall TVecDraw::GetRegion(TVecData *data, HRGN *rgn, bool SelectPen) { BEGIN_LOG(""); HDC dcDst = MainImageForm->iMainImage->Canvas->Handle; HPEN hPen = NULL, hOldPen = NULL; HBRUSH hBrush = NULL, hOldBrush = NULL; int nFillMode; POINT *pPoints = NULL; // pPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) nFillMode = GetPolyFillMode(dcDst); SetPolyFillMode(dcDst, ALTERNATE); if (data->Kind == V_TEXTBOX) { pPoints = new POINT[5]; } else { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new POINT[(data->nCount + 1) * 3 + 1]; } else { pPoints = new POINT[data->nCount * 3 + 1]; } } if (SelectPen) { hPen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0)); hOldPen = (HPEN)SelectObject(dcDst, hPen); for (int i = 0; i < data->nCount * 3 + 1; i++) pPoints[i] = data->pList[i].P(); if (data->bClosed) pPoints[data->nCount * 3] = pPoints[0]; BeginPath(dcDst); MoveToEx(dcDst, pPoints[0].x, pPoints[0].y, NULL); PolyBezierTo(dcDst, pPoints + 1, data->nCount * 3); FillPath(dcDst); StrokePath(dcDst); EndPath(dcDst); WidenPath(dcDst); *rgn = PathToRegion(dcDst); SetPolyFillMode(dcDst, nFillMode); DeleteObject(SelectObject(dcDst, hOldPen)); } else { hPen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0)); hOldPen = (HPEN)SelectObject(dcDst, hPen); hBrush = CreateSolidBrush(RGB(0, 0, 0)); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); for (int i = 0; i < data->nCount * 3 + 1; i++) pPoints[i] = data->pList[i].P(); if (data->bClosed) pPoints[data->nCount * 3] = pPoints[0]; // Àӽ÷ΠÁ÷¼±ÀÏ °æ¿ì¸¸ üũ if (data->nCount == 1) { if ((pPoints[0].x == pPoints[1].x && pPoints[0].y == pPoints[1].y) && (pPoints[2].x == pPoints[3].x && pPoints[2].y == pPoints[3].y)) { if (abs(pPoints[0].x - pPoints[2].x) < 2) { pPoints[0].x = pPoints[0].x - 0.5; pPoints[1].x = pPoints[1].x + 0.5; pPoints[2].x = pPoints[2].x + 0.5; pPoints[3].x = pPoints[3].x - 0.5; pPoints[0].y = pPoints[0].y; pPoints[1].y = pPoints[1].y; pPoints[2].y = pPoints[2].y; pPoints[3].y = pPoints[3].y; } else { pPoints[0].x = pPoints[0].x; pPoints[1].x = pPoints[1].x; pPoints[2].x = pPoints[2].x; pPoints[3].x = pPoints[3].x; pPoints[0].y = pPoints[0].y - 0.5; pPoints[1].y = pPoints[1].y + 0.5; pPoints[2].y = pPoints[2].y + 0.5; pPoints[3].y = pPoints[3].y - 0.5; } } } BeginPath(dcDst); MoveToEx(dcDst, pPoints[0].x, pPoints[0].y, NULL); PolyBezierTo(dcDst, pPoints + 1, data->nCount * 3); FillPath(dcDst); // StrokeAndFillPath(dcDst); // StrokePath(dcDst); EndPath(dcDst); *rgn = PathToRegion(dcDst); SetPolyFillMode(dcDst, nFillMode); DeleteObject(SelectObject(dcDst, hOldPen)); DeleteObject(SelectObject(dcDst, hOldBrush)); } if (pPoints) delete[]pPoints; pPoints = NULL; END_LOG; } // --------------------------------------------------------------------------- /// vector objectÀÇ regionÀ» ±¸ÇØÁØ´Ù. void __fastcall TVecDraw::GetRegion(TVecData *data, HRGN *rgn, int Item) { BEGIN_LOG(""); // Item 0 : FillPath // 1 : only path // 2 : only inside // 3 : path & inside HDC dcDst = MainImageForm->iMainImage->Canvas->Handle; HPEN hPen = NULL, hOldPen = NULL; HBRUSH hBrush = NULL, hOldBrush = NULL; int nFillMode; POINT *pPoints = NULL; // pPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) nFillMode = GetPolyFillMode(dcDst); SetPolyFillMode(dcDst, ALTERNATE); if (data->Kind == V_TEXTBOX) { pPoints = new POINT[5]; } else { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new POINT[(data->nCount + 1) * 3 + 1]; } else { pPoints = new POINT[data->nCount * 3 + 1]; } } if (Item == 0) { hPen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0)); hOldPen = (HPEN)SelectObject(dcDst, hPen); hBrush = CreateSolidBrush(RGB(0, 0, 0)); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); for (int i = 0; i < data->nCount * 3 + 1; i++) pPoints[i] = data->pList[i].P(); if (data->bClosed) pPoints[data->nCount * 3] = pPoints[0]; BeginPath(dcDst); MoveToEx(dcDst, pPoints[0].x, pPoints[0].y, NULL); PolyBezierTo(dcDst, pPoints + 1, data->nCount * 3); FillPath(dcDst); EndPath(dcDst); *rgn = PathToRegion(dcDst); SetPolyFillMode(dcDst, nFillMode); DeleteObject(SelectObject(dcDst, hOldPen)); DeleteObject(SelectObject(dcDst, hOldBrush)); } else if (Item == 1) { hPen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0)); hOldPen = (HPEN)SelectObject(dcDst, hPen); for (int i = 0; i < data->nCount * 3 + 1; i++) pPoints[i] = data->pList[i].P(); if (data->bClosed) pPoints[data->nCount * 3] = pPoints[0]; BeginPath(dcDst); MoveToEx(dcDst, pPoints[0].x, pPoints[0].y, NULL); PolyBezierTo(dcDst, pPoints + 1, data->nCount * 3); FillPath(dcDst); EndPath(dcDst); WidenPath(dcDst); *rgn = PathToRegion(dcDst); SetPolyFillMode(dcDst, nFillMode); DeleteObject(SelectObject(dcDst, hOldPen)); } else if (Item == 2) { HRGN rgnPath, rgnPen, rgnCombine; hPen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0)); hOldPen = (HPEN)SelectObject(dcDst, hPen); hBrush = CreateSolidBrush(RGB(0, 0, 0)); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); for (int i = 0; i < data->nCount * 3 + 1; i++) pPoints[i] = data->pList[i].P(); if (data->bClosed) pPoints[data->nCount * 3] = pPoints[0]; BeginPath(dcDst); MoveToEx(dcDst, pPoints[0].x, pPoints[0].y, NULL); PolyBezierTo(dcDst, pPoints + 1, data->nCount * 3); FillPath(dcDst); EndPath(dcDst); rgnPath = PathToRegion(dcDst); BeginPath(dcDst); MoveToEx(dcDst, pPoints[0].x, pPoints[0].y, NULL); PolyBezierTo(dcDst, pPoints + 1, data->nCount * 3); FillPath(dcDst); EndPath(dcDst); WidenPath(dcDst); rgnPen = PathToRegion(dcDst); rgnCombine = CreateRectRgn(0, 0, 1, 1); CombineRgn(rgnCombine, rgnPath, rgnPen, RGN_DIFF); // RGN_XOR); *rgn = rgnCombine; SetPolyFillMode(dcDst, nFillMode); DeleteObject(SelectObject(dcDst, hOldBrush)); DeleteObject(SelectObject(dcDst, hOldPen)); if (rgnPath) { DeleteObject(rgnPath); rgnPath = NULL; } if (rgnPen) { DeleteObject(rgnPen); rgnPen = NULL; } } else if (Item == 3) { HRGN rgnPath, rgnPen, rgnCombine; hPen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0)); hOldPen = (HPEN)SelectObject(dcDst, hPen); hBrush = CreateSolidBrush(RGB(0, 0, 0)); hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); for (int i = 0; i < data->nCount * 3 + 1; i++) pPoints[i] = data->pList[i].P(); if (data->bClosed) pPoints[data->nCount * 3] = pPoints[0]; BeginPath(dcDst); MoveToEx(dcDst, pPoints[0].x, pPoints[0].y, NULL); PolyBezierTo(dcDst, pPoints + 1, data->nCount * 3); FillPath(dcDst); EndPath(dcDst); rgnPath = PathToRegion(dcDst); BeginPath(dcDst); MoveToEx(dcDst, pPoints[0].x, pPoints[0].y, NULL); PolyBezierTo(dcDst, pPoints + 1, data->nCount * 3); FillPath(dcDst); EndPath(dcDst); WidenPath(dcDst); rgnPen = PathToRegion(dcDst); rgnCombine = CreateRectRgn(0, 0, 1, 1); CombineRgn(rgnCombine, rgnPath, rgnPen, RGN_OR); *rgn = rgnCombine; SetPolyFillMode(dcDst, nFillMode); DeleteObject(SelectObject(dcDst, hOldBrush)); DeleteObject(SelectObject(dcDst, hOldPen)); if (rgnPath) { DeleteObject(rgnPath); rgnPath = NULL; } if (rgnPen) { DeleteObject(rgnPen); rgnPen = NULL; } } if (pPoints) delete[]pPoints; pPoints = NULL; END_LOG; } // --------------------------------------------------------------------------- /** object¿¡ Ãß°¡µÈ Á¡ À§Ä¡¿¡¼­ Àß¶ó³»¾î ¿µ¿ªº°·Î ºÐ¸®½ÃÅ´. * ÇÑ segment(object¿¡¼­ Àß¶ó³½ ºÎºÐ)¾¿ Àß¶ó³»±â À§Çؼ­ objectÀÇ ³¡ÂÊ Á¡ºÎÅÍ Àß¶ó³½´Ù. (±×·¸Áö¾ÊÀ¸¸é ºÐ¸®µÈ µÎ ¿ÀºêÁ§Æ®¿¡¼­ °¢°¢ Á¡À» ã¾Æ ³ª´©¾îÁÖ¾î¾ßÇÔ) * ³Ö¾î³õÀº °Íµé Áß °°Àº À§Ä¡¿¡ ÀÖ´Â °ÍÀÌ ÀÖÀ¸¸é »©³»¼­ sameSegments¿¡´Ù ³Ö´Â´Ù. * Àß¶ó³½ object¸¦ ºÐ¸®½Ãų ¶§´Â »ó´ëÆí object¾È¿¡ ¼ÓÇÏ´ÂÁöÀÇ ¿©ºÎ·Î ºÐ¸®ÇÑ´Ù. */ bool __fastcall TVecDraw::MakeSegments(TVecData *tempFst, TVecData *tempSec, int pointCount, int *fpt, int *spt, HRGN fstRgn, HRGN secRgn, HRGN rgnCombine, TList *fstIn, TList *fstOut, TList *secIn, TList *secOut, TList *sameSegments, bool fstClosed, bool secClosed) { BEGIN_LOG(""); // ÇÑ ¿ÀºêÁ§Æ®¾¿ Àß¶ó³»±â À§Çؼ­ objectÀÇ ³¡ÂÊ Á¡ºÎÅÍ Àß¶ó³½´Ù. ±×·¸Áö¾ÊÀ¸¸é ºÐ¸®µÈ µÎ ¿ÀºêÁ§Æ®¿¡¼­ °¢°¢ Á¡À» ã¾Æ ³ª´©¾îÁÖ¾î¾ßÇÔ. TList *fList = new TList; TList *sList = new TList; // Àß¶ó³õÀº °ÍµéÀ» ¸®½ºÆ®¿¡ ³Ö¾î³õ´Â´Ù. int start_fst = fstClosed; int start_sec = secClosed; for (int i = start_fst; i < pointCount; i++) { int fstIndex = -1; int fstmax; for (int j = start_fst; j < pointCount; j++) { if (fpt[j] >= 0 && fpt[j] > fstIndex) { fstIndex = fpt[j]; fstmax = j; } } fpt[fstmax] = -1; if (fstIndex < 0 || fstIndex >= tempFst->nCount) { END_LOG; return false; } TVecData *fndata = NULL; fndata = KnifeInVecData(tempFst, fstIndex * 3); if (fndata == NULL) { END_LOG; return false; } fList->Add(fndata); } for (int i = start_sec; i < pointCount; i++) { int secIndex = -1; int secmax; for (int j = start_sec; j < pointCount; j++) { if (spt[j] >= 0 && spt[j] > secIndex) { secIndex = spt[j]; secmax = j; } } spt[secmax] = -1; if (secIndex < 0 || secIndex >= tempSec->nCount) { END_LOG; return false; } TVecData *sndata = NULL; sndata = KnifeInVecData(tempSec, secIndex * 3); if (sndata == NULL) { END_LOG; return false; } sList->Add(sndata); } // if (start != 0) { fList->Add(tempFst); // } sList->Add(tempSec); // ³Ö¾î³õÀº °Íµé Áß °°Àº À§Ä¡¿¡ ÀÖ´Â °ÍÀÌ ÀÖÀ¸¸é »©³»¼­ sameSegments¿¡´Ù ³Ö´Â´Ù. // HRGN rgnCombine = NULL; // rgnCombine = CreateRectRgn(0, 0, 0, 0); // CombineRgn(rgnCombine, fstRgn, secRgn, RGN_AND); RECT r; GetRgnBox(rgnCombine, &r); if (r.left == 0 && r.right == 0 && r.top == 0 && r.bottom == 0) { // } else { for (int i = 0; i < fList->Count; i++) { TVecData *fdata = (TVecData*)fList->Items[i]; double flen = GetRoughLength(fdata, fdata->nCount * 5); for (int j = 0; j < sList->Count; j++) { TVecData *sdata = (TVecData*)sList->Items[j]; double slen = GetRoughLength(sdata, sdata->nCount * 5); bool same = false; if ((fdata->pList[0].x - sdata->pList[0].x < 1) && (fdata->pList[0].x - sdata->pList[0].x > -1) && (fdata->pList[0].y - sdata->pList[0].y < 1) && (fdata->pList[0].y - sdata->pList[0].y > -1) && (fdata->pList[fdata->nCount * 3].x - sdata->pList[sdata->nCount * 3] .x < 1) && (fdata->pList[fdata->nCount * 3].x - sdata->pList [sdata->nCount * 3].x > -1) && (fdata->pList[fdata->nCount * 3].y - sdata->pList[sdata->nCount * 3] .y < 1) && (fdata->pList[fdata->nCount * 3].y - sdata->pList [sdata->nCount * 3].y > -1)) { if (abs(long(flen - slen)) < 1) same = true; } else if ((fdata->pList[0].x - sdata->pList[sdata->nCount * 3].x < 1) && (fdata->pList[0].x - sdata->pList[sdata->nCount * 3].x > -1) && (fdata->pList[0].y - sdata->pList[sdata->nCount * 3].y < 1) && (fdata->pList[0].y - sdata->pList[sdata->nCount * 3].y > -1) && (fdata->pList[fdata->nCount * 3].x - sdata->pList[0].x < 1) && (fdata->pList[fdata->nCount * 3].x - sdata->pList[0].x > -1) && (fdata->pList[fdata->nCount * 3].y - sdata->pList[0].y < 1) && (fdata->pList[fdata->nCount * 3].y - sdata->pList[0].y > -1)) { if (abs(long(flen - slen)) < 1) same = true; } if (same) { bool bInf = false, bIns = false; bInf = SegmentInRegion(sdata, rgnCombine); bIns = SegmentInRegion(fdata, rgnCombine); if (bInf && bIns) { sameSegments->Add(sdata); sList->Remove(sdata); fList->Remove(fdata); delete fdata; i--; break; } else if (fdata->nCount == 1 && sdata->nCount == 1) { bool diff = false; for (int k = 0; k <= 3; k++) { if (abs(long(fdata->pList[k].x - sdata->pList[k].x)) > 2 || abs (long(fdata->pList[k].y - sdata->pList[k].y)) > 2) { diff = true; } } if (!diff) { sameSegments->Add(sdata); sList->Remove(sdata); fList->Remove(fdata); delete fdata; i--; break; } else { diff = false; for (int k = 0; k <= 3; k++) { if (abs(long(fdata->pList[k].x - sdata->pList[3 - k].x)) > 2 || abs(long(fdata->pList[k].y - sdata->pList[3 - k].y)) > 2) { diff = true; } } if (!diff) { sameSegments->Add(sdata); sList->Remove(sdata); fList->Remove(fdata); delete fdata; i--; break; } } } } } } DeleteObject(rgnCombine); rgnCombine = NULL; } double t = 0.5; for (int i = 0; i < fList->Count; i++) { bool bIn = false; TVecData *fdata = (TVecData*)fList->Items[i]; bIn = SegmentInRegion(fdata, secRgn); if (bIn) { fstIn->Add(fdata); } else { fstOut->Add(fdata); } } delete fList; for (int i = 0; i < sList->Count; i++) { bool bIn = false; TVecData *sdata = (TVecData*)sList->Items[i]; bIn = SegmentInRegion(sdata, fstRgn); if (bIn) { secIn->Add(sdata); } else { secOut->Add(sdata); } } delete sList; for (int i = 0; i < sameSegments->Count; i++) { TVecData *same01 = (TVecData*)sameSegments->Items[i]; DPOINT first, last; first.x = same01->pList[0].x; first.y = same01->pList[0].y; last.x = same01->pList[same01->nCount * 3].x; last.y = same01->pList[same01->nCount * 3].y; for (int j = i + 1; j < sameSegments->Count; j++) { TVecData *same02 = (TVecData*)sameSegments->Items[j]; if (IsEndPoint(&first, same02)) { JoinObjects(same01, same02, first.x, first.y); sameSegments->Remove(same02); delete same02; j--; } else if (IsEndPoint(&last, same02)) { JoinObjects(same01, same02, last.x, last.y); sameSegments->Remove(same02); delete same02; j--; } } } END_LOG; return true; } // --------------------------------------------------------------------------- /** ºÐ¸®µÈ segmentµéÀ» ¿¬°á½ÃÅ´. * FstSegment¿Í SecSegment¿¡¼­ °°Àº Á¡ÀÌ ÀÖ´Â °æ¿ì ¿¬°áÇÑ´Ù. * SameSegments¿¡´Â µÎ ¿ÀºêÁ§Æ®¿¡ °øÅëµÈ segment°¡ ÀÖÀ¸¹Ç·Î Çʿ信 µû¶ó ¿¬°á½ÃÄÑÁØ´Ù. */ void __fastcall TVecDraw::JoinSegments(TList *ResultList, TList *IntersectionPtList, TList *FstSegment, TList *SecSegment, TList *SameSegments, ECutObject Item) { BEGIN_LOG(""); TVecData *resultData = NULL; int findPointCount = IntersectionPtList->Count; for (int i = 0; i < findPointCount; i++) { DPOINT *pt = (DPOINT*)IntersectionPtList->Items[i]; TVecData *joinFst = NULL, *joinSec = NULL; TVecData *fdata = NULL, *sdata = NULL; for (int j = 0; j < FstSegment->Count; j++) { fdata = (TVecData*)FstSegment->Items[j]; if (IsEndPoint(pt, fdata)) { joinFst = fdata; break; } } for (int j = 0; j < SecSegment->Count; j++) { sdata = (TVecData*)SecSegment->Items[j]; if (IsEndPoint(pt, sdata)) { joinSec = sdata; break; } } if (joinFst || joinSec) { if (!ResultList) { ResultList = new TList; resultData = new TVecData(MainImageForm->Number); if (joinFst && joinSec) { resultData->Copy(joinFst); if (Item != 4) { JoinObjects(resultData, joinSec, pt->x, pt->y); } FstSegment->Remove(joinFst); SecSegment->Remove(joinSec); delete joinFst; delete joinSec; } else { if (joinFst) { resultData->Copy(joinFst); FstSegment->Remove(joinFst); delete joinFst; } else if (joinSec) { resultData->Copy(joinSec); SecSegment->Remove(joinSec); delete joinSec; } } ResultList->Add(resultData); } else { bool find = false; for (int i = 0; i < ResultList->Count; i++) { TVecData *data = (TVecData*)ResultList->Items[i]; if (!data->bClosed) { DPOINT first, last; if (joinFst) { first.x = joinFst->pList[0].x; first.y = joinFst->pList[0].y; last.x = joinFst->pList[joinFst->nCount * 3].x; last.y = joinFst->pList[joinFst->nCount * 3].y; if (IsEndPoint(&first, data)) { if (Item != 4) { JoinObjects(joinFst, data, first.x, first.y); } data->Copy(joinFst); FstSegment->Remove(joinFst); delete joinFst; find = true; break; } else if (IsEndPoint(&last, data)) { if (Item != 4) { JoinObjects(joinFst, data, last.x, last.y); } data->Copy(joinFst); FstSegment->Remove(joinFst); delete joinFst; find = true; break; } } else if (joinSec) { DPOINT first, last; first.x = joinSec->pList[0].x; first.y = joinSec->pList[0].y; last.x = joinSec->pList[joinSec->nCount * 3].x; last.y = joinSec->pList[joinSec->nCount * 3].y; if (IsEndPoint(&first, data)) { if (Item != 4) { JoinObjects(data, joinSec, first.x, first.y); } SecSegment->Remove(joinSec); delete joinSec; find = true; break; } else if (IsEndPoint(&last, data)) { if (Item != 4) { JoinObjects(data, joinSec, last.x, last.y); } SecSegment->Remove(joinSec); delete joinSec; find = true; break; } } } /* if (!data->bClosed && IsEndPoint(pt, data)){ if (joinFst){ JoinObjects(joinFst, data, pt->x, pt->y); //JoinObjects(data, joinFst, pt->x, pt->y); data->Copy(joinFst); FstSegment->Remove(joinFst); delete joinFst; } else if (joinSec){ JoinObjects(data, joinSec, pt->x, pt->y); SecSegment->Remove(joinSec); delete joinSec; } find = true; break; } */ } if (!find) { resultData = new TVecData(MainImageForm->Number); if (joinFst && joinSec) { resultData->Copy(joinFst); if (Item != 4) { JoinObjects(resultData, joinSec, pt->x, pt->y); } FstSegment->Remove(joinFst); SecSegment->Remove(joinSec); delete joinFst; delete joinSec; } else { if (joinFst) { resultData->Copy(joinFst); FstSegment->Remove(joinFst); delete joinFst; } else if (joinSec) { resultData->Copy(joinSec); SecSegment->Remove(joinSec); delete joinSec; } } ResultList->Add(resultData); } } } } if (ResultList) { if (Item == C_MERGE) { if (SameSegments->Count > 0) { if (ResultList->Count > 0) { for (int i = 0; i < ResultList->Count; i++) { TVecData *data = (TVecData*)ResultList->Items[i]; if (!data->bClosed) { DPOINT first, last; for (int j = 0; j < SameSegments->Count; j++) { TVecData *same = (TVecData*)SameSegments->Items[j]; first.x = same->pList[0].x; first.y = same->pList[0].y; last.x = same->pList[same->nCount * 3].x; last.y = same->pList[same->nCount * 3].y; if (IsEndPoint(&first, data)) { if (Item != 4) { JoinObjects(data, same, first.x, first.y); } SameSegments->Remove(same); delete same; j--; break; } else if (IsEndPoint(&last, data)) { if (Item != 4) { JoinObjects(data, same, last.x, last.y); } SameSegments->Remove(same); delete same; j--; break; } } if (!data->bClosed) { if (abs(long(data->pList[0].x - data->pList[data->nCount * 3].x) ) <= 1 && abs (long(data->pList[0].y - data->pList[data->nCount * 3] .y)) <= 1) { data->bClosed = true; data->pList[data->nCount * 3].x = data->pList[0].x; data->pList[data->nCount * 3].y = data->pList[0].y; } } } } } /* else { for (int j = 0; j < SameSegments->Count; j++){ TVecData *same = (TVecData *)SameSegments->Items[j]; if(same->bClosed){ ResultList->Add(same); SameSegments->Remove(same); j--; } } } */ } } // else if (Item == C_MAKE_INTERSECTION){ else { if (SameSegments->Count > 0) { if (ResultList->Count > 0) { for (int i = 0; i < ResultList->Count; i++) { TVecData *data = (TVecData*)ResultList->Items[i]; if (!data->bClosed) { DPOINT first, last; for (int j = 0; j < SameSegments->Count; j++) { TVecData *same = (TVecData*)SameSegments->Items[j]; first.x = same->pList[0].x; first.y = same->pList[0].y; last.x = same->pList[same->nCount * 3].x; last.y = same->pList[same->nCount * 3].y; if (IsEndPoint(&first, data)) { if (Item != 4) { JoinObjects(data, same, first.x, first.y); } SameSegments->Remove(same); delete same; j--; // break; } else if (IsEndPoint(&last, data)) { if (Item != 4) { JoinObjects(data, same, last.x, last.y); } SameSegments->Remove(same); delete same; j--; // break; } } if (!data->bClosed) { if (data->pList[0].x - data->pList[data->nCount * 3] .x < 1 && data->pList[0].x - data->pList[data->nCount * 3] .x > -1 && data->pList[0].y - data->pList[data->nCount * 3] .y < 1 && data->pList[0].y - data->pList[data->nCount * 3] .y > -1) { // if (((int)data->pList[0].x == (int)data->pList[data->nCount*3].x) && ((int)data->pList[0].y == (int)data->pList[data->nCount*3].y)){ data->bClosed = true; } } } } } /* else { for (int j = 0; j < SameSegments->Count; j++){ TVecData *same = (TVecData *)SameSegments->Items[j]; ResultList->Add(same); SameSegments->Remove(same); j--; } } */ } } } END_LOG; } // --------------------------------------------------------------------------- /// ÀÌ point°¡ ¼±ÅÃÇÑ vector objectÀÇ ³¡ Á¡ÀÎÁö È®ÀÎÇÑ´Ù. bool __fastcall TVecDraw::IsEndPoint(DPOINT *pt, TVecData *data) { bool rtn = false; double len01 = sqrt((pt->x - data->pList[0].x) * (pt->x - data->pList[0].x) + (pt->y - data->pList[0].y) * (pt->y - data->pList[0].y)); double len02 = sqrt((pt->x - data->pList[data->nCount * 3].x) * (pt->x - data->pList[data->nCount * 3].x) + (pt->y - data->pList[data->nCount * 3].y) * (pt->y - data->pList[data->nCount * 3].y)); if (len01 < 2 || len02 < 2) rtn = true; return rtn; } // --------------------------------------------------------------------------- /// ÇöÀç object(object¿¡¼­ Àß¶ó³½ segment)°¡ Region¾È¿¡ (ÀϺΰ¡)µé¾î°¡ ÀÖ´ÂÁöÀÇ ¿©ºÎ üũ bool _fastcall TVecDraw::SegmentInRegion(TVecData *Data, HRGN Rgn) { double px = 0.0, py = 0.0; double t = 0.5; bool rtn = false; /* // Àüü°¡ ´Ù µé¾îÀÖ³ª bool in = true; for (int i = 0; i < Data->nCount; i++){ in = PtInRegion(Rgn, Data->pList[i*3].x, Data->pList[i*3].y); if (!in){ rtn = false; break; } } if (in) rtn = true; */ ///* if (Data->nCount < 2) { px = (1 - t) * (1 - t) * (1 - t) * Data->pList[0].x + 3 * t * (t - 1) * (t - 1) * Data->pList[1].x - 3 * t * t * (t - 1) * Data->pList[2].x + t * t * t * Data->pList[3].x; py = (1 - t) * (1 - t) * (1 - t) * Data->pList[0].y + 3 * t * (t - 1) * (t - 1) * Data->pList[1].y - 3 * t * t * (t - 1) * Data->pList[2].y + t * t * t * Data->pList[3].y; } else { double maxLen = 0; int index = -1; // ¼±ºÐÀÇ ±æÀ̰¡ Á¦ÀÏ ±ä°Í¿¡¼­ ã´Â´Ù. for (int i = 0; i < Data->nCount; i++) { double len = 0; len = sqrt((Data->pList[i * 3].x - Data->pList[(i + 1) * 3].x) * (Data->pList[i * 3].x - Data->pList[(i + 1) * 3].x) + (Data->pList[i * 3].y - Data->pList[(i + 1) * 3].y) * (Data->pList[i * 3].y - Data->pList[(i + 1) * 3].y)); if (maxLen < len) { maxLen = len; index = i; } } px = (1 - t) * (1 - t) * (1 - t) * Data->pList[index * 3].x + 3 * t * (t - 1) * (t - 1) * Data->pList[index * 3 + 1].x - 3 * t * t * (t - 1) * Data->pList[index * 3 + 2].x + t * t * t * Data->pList[index * 3 + 3] .x; py = (1 - t) * (1 - t) * (1 - t) * Data->pList[index * 3].y + 3 * t * (t - 1) * (t - 1) * Data->pList[index * 3 + 1].y - 3 * t * t * (t - 1) * Data->pList[index * 3 + 2].y + t * t * t * Data->pList[index * 3 + 3] .y; } rtn = PtInRegion(Rgn, px, py); // */ return rtn; } // --------------------------------------------------------------------------- /// ÇÑ object°¡ ´Ù¸¥ object·Î µÑ·¯½Î¿©ÀÖ´ÂÁö üũ bool __fastcall TVecDraw::ObjectInObject(TVecData *DstData, TVecData *CompData) { bool rtn = false; HRGN rgn = NULL; GetRegion(DstData, &rgn); int count = 0; for (int i = 0; i < CompData->nCount; i++) { int px = CompData->pList[i * 3].x; int py = CompData->pList[i * 3].y; if (PtInRegion(rgn, px, py)) { count++; } } if (count == CompData->nCount) rtn = true; return rtn; } // --------------------------------------------------------------------------- /// ¸¸µé¾îÁø objectµéÀ» °¢ Itemº°·Î ó¸®. Vector list¿¡ Ãß°¡Çϰųª UndoSave µîÀ» ÇØÁØ´Ù. void __fastcall TVecDraw::MakeResult(TList *ResultList, TVecData *FstData, TVecData *SecData, int FstIndex, int SecIndex, ECutObject Item, bool bApplyList) { BEGIN_LOG(""); if (ResultList) { TList *DataList = NVector->DataList; int Index = -1; // ¸·È÷Áö ¾ÊÀº ¿ÀºêÁ§Æ®µéÀÌ ÀÖÀ¸¸é À̾îÁØ´Ù. for (int i = 0; i < ResultList->Count; i++) { TVecData *data = (TVecData*)ResultList->Items[i]; if (!data->bClosed) { for (int j = ResultList->Count - 1; j >= 0; j--) { TVecData *compdata = (TVecData*)ResultList->Items[j]; if (i != j && !compdata->bClosed) { if (IsEndPoint(&data->pList[0], compdata)) { JoinObjects(data, compdata, data->pList[0].x, data->pList[0].y); ResultList->Remove(compdata); delete compdata; } else if (IsEndPoint(&data->pList[data->nCount * 3], compdata)) { JoinObjects(data, compdata, data->pList[data->nCount * 3].x, data->pList[data->nCount * 3].y); ResultList->Remove(compdata); delete compdata; } } } if (!data->bClosed) { if (sqrt((data->pList[0].x - data->pList[data->nCount * 3].x) * (data->pList[0].x - data->pList[data->nCount * 3].x) + (data->pList[0].y - data->pList[data->nCount * 3].y) * (data->pList[0].y - data->pList[data->nCount * 3].y)) < 2) { // if (abs(data->pList[0].x - data->pList[data->nCount*3].x) <= 1 && abs(data->pList[0].y - data->pList[data->nCount*3].y) <= 1){ data->bClosed = true; data->pList[data->nCount * 3].x = data->pList[0].x; data->pList[data->nCount * 3].y = data->pList[0].y; } } } } switch(Item) { case C_MERGE: // merge objects Index = FstIndex; if (bApplyList) { if (FstIndex > SecIndex) { UndoSave(VU_DELETE, FstIndex, true); UndoSave(VU_DELETE, SecIndex, false); } else { UndoSave(VU_DELETE, SecIndex, true); UndoSave(VU_DELETE, FstIndex, false); } DataList->Remove(FstData); DataList->Remove(SecData); delete FstData; delete SecData; } break; case C_CUT_BOTTOM: // À§ ÂÊ ¿ÀºêÁ§Æ®(SecData)·Î ¾Æ·¡ ¿ÀºêÁ§Æ®(FstData)¸¦ Àß¶ó³¿. (¾ÕÂÊ À妽º°¡ ¾Æ·¡ÂÊ) Index = FstIndex; if (bApplyList) { UndoSave(VU_DELETE, FstIndex, true); DataList->Remove(FstData); delete FstData; } break; case C_CUT_FRONT: // ¾Æ·¡ ÂÊ ¿ÀºêÁ§Æ®(FstData)·Î À§ ¿ÀºêÁ§Æ®(SecData)¸¦ Àß¶ó³¿. (¾ÕÂÊ À妽º°¡ ¾Æ·¡ÂÊ) Index = SecIndex; if (bApplyList) { UndoSave(VU_DELETE, SecIndex, true); DataList->Remove(SecData); delete SecData; } break; case C_MAKE_INTERSECTION: Index = SecIndex + 1; // óÀ½ µÎ ¿ÀºêÁ§Æ®ÀÇ ¼ø¼­¸¦ ¹Ù²ãÁÖ¾î¾ß »ý¼ºµÈ ¿ÀºêÁ§Æ®¸¦ ±¸ºÐÇÒ ¼ö ÀÖ´Ù. if (FstIndex > SecIndex) { UndoSave(VU_ORDERF, FstIndex, true, SecIndex); UndoSave(VU_ORDERF, SecIndex + 1, false, FstIndex); DataList->Move(FstIndex, SecIndex); DataList->Move(SecIndex + 1, FstIndex); } else { UndoSave(VU_ORDERF, SecIndex, true, FstIndex); UndoSave(VU_ORDERF, FstIndex + 1, false, SecIndex); DataList->Move(SecIndex, FstIndex); DataList->Move(FstIndex + 1, SecIndex); } break; case C_EACH_CUT: // Index = SecIndex + 1; Index = SecIndex; // óÀ½ µÎ ¿ÀºêÁ§Æ®ÀÇ ¼ø¼­¸¦ ¹Ù²ãÁÖ¾î¾ß »ý¼ºµÈ ¿ÀºêÁ§Æ®¸¦ ±¸ºÐÇÒ ¼ö ÀÖ´Ù. if (FstIndex > SecIndex) { // UndoSave(VU_ORDERF, FstIndex, true, SecIndex); // UndoSave(VU_ORDERF, SecIndex + 1, false, FstIndex); DataList->Move(FstIndex, SecIndex); DataList->Move(SecIndex + 1, FstIndex); } else { // UndoSave(VU_ORDERF, SecIndex, true, FstIndex); // UndoSave(VU_ORDERF, FstIndex + 1, false, SecIndex); DataList->Move(SecIndex, FstIndex); DataList->Move(FstIndex + 1, SecIndex); } if (bApplyList) { // UndoSave(VU_DELETE, SecIndex, true); DataList->Remove(SecData); delete SecData; } break; } if (Item == C_MERGE) { int resultIndex = 0; bool InObject = false; if (ResultList->Count > 1) { // µÎ°¡Áö °æ¿ì°¡ ÀÖÀ½. 1. ÇÑ ¿ÀºêÁ§Æ®°¡ ´Ù¸¥ ¿ÀºêÁ§Æ®µéÀ» µÑ·¯½Î°í ÀÖ´Â °æ¿ì. 2. °ãÃÄÁ® ÀÖ´Â °æ¿ì. // ÀÌ µÎ °æ¿ì¸¦ ±¸ºÐÇÑ´Ù. // °¡Àå ±æÀ̰¡ ±ä ¿ÀºêÁ§Æ®°¡ µÑ·¯½Î°í ÀÖ´Â °ÍÀ̹ǷΠ±× ¿ÀºêÁ§Æ®¸¦ ã´Â´Ù. int maxLength = 0; for (int i = 0; i < ResultList->Count; i++) { TVecData *data = (TVecData*)ResultList->Items[i]; int len = 0; for (int j = 0; j < data->nCount * 3 - 2; j += 3) { len += sqrt((data->pList[j + 3].x - data->pList[j].x) * (data->pList[j + 3].x - data->pList[j].x) + (data->pList[j + 3].y - data->pList[j].y) * (data->pList[j + 3].y - data->pList[j].y)); } if (len > maxLength) { resultIndex = i; maxLength = len; } } TVecData *MaxData = (TVecData*)ResultList->Items[resultIndex]; InObject = true; for (int i = 0; i < ResultList->Count; i++) { if (i != resultIndex) { TVecData *data = (TVecData*)ResultList->Items[i]; if (!ObjectInObject(MaxData, data)) { InObject = false; } else { // ¾È¿¡ÀÖ´Â ¿ÀºêÁ§Æ®°¡ ÀÖÀ½. if (i < resultIndex) { resultIndex--; } ResultList->Remove(data); if (data) delete data; i--; } } } if (InObject) { // ´Ù ¾È¿¡ ÀÖÀ½. ÀÌ °æ¿ì Á¦ÀÏ ±ä ¿ÀºêÁ§Æ®¸¸ Ãß°¡ÇÑ´Ù. TVecData *outData = (TVecData*)ResultList->Items[resultIndex]; if (outData->bPatternFill) MakePatternBitmap(outData); if (bApplyList) { DataList->Insert(Index, outData); UndoSave(VU_CREATE, Index, false); } ResultList->Remove(outData); } else { // ¾È¿¡ ÀÖ´Â ¿ÀºêÁ§Æ®µéÀ» ´Ù ÇÕÃÄÁØ´Ù. if (ResultList->Count == 2) { TVecData *fstData = (TVecData*)ResultList->Items[0]; TVecData *secData = (TVecData*)ResultList->Items[1]; TList *IntersectionPtList; IntersectionPtList = new TList; FindBezierIntersection(fstData, secData, IntersectionPtList); if (IntersectionPtList->Count > 0) { TList *result = new TList; bool cutted = Cutting(result, IntersectionPtList, fstData, secData, Item); if (cutted) { if (result->Count == 1) { TVecData *data = (TVecData*)result->Items[0]; result->Remove(data); ResultList->Insert(0, data); ResultList->Remove(fstData); ResultList->Remove(secData); delete fstData; delete secData; fstData = data; } /* if (result->Count > 1){ MakeResult(result, fstData, secData, -1, -1, Item, false); if (result->Count == 1){ TVecData *data = (TVecData *)result->Items[0]; result->Remove(data); ResultList->Insert(0, data); ResultList->Remove(fstData); ResultList->Remove(secData); delete fstData; delete secData; fstData = data; } } else if (result->Count == 1){ TVecData *data = (TVecData *)result->Items[0]; result->Remove(data); ResultList->Insert(0, data); ResultList->Remove(fstData); ResultList->Remove(secData); delete fstData; delete secData; fstData = data; } */ } DeleteVecList(result); delete result; } while (IntersectionPtList->Count > 0) { DPOINT *pt = (DPOINT*)IntersectionPtList->Last(); IntersectionPtList->Remove(pt); delete pt; } delete IntersectionPtList; } else if (ResultList->Count > 2) { for (int i = 0; i < ResultList->Count; i++) { TVecData *fstData = (TVecData*)ResultList->Items[i]; for (int j = ResultList->Count - 1; j >= 0; j--) { TVecData *secData = (TVecData*)ResultList->Items[j]; if (fstData != secData) { TList *IntersectionPtList; IntersectionPtList = new TList; FindBezierIntersection(fstData, secData, IntersectionPtList); if (IntersectionPtList->Count > 0) { TList *result = new TList; bool cutted = Cutting(result, IntersectionPtList, fstData, secData, Item); if (cutted) { TVecData *data = (TVecData*)result->Items[0]; result->Remove(data); if (i < j) { ResultList->Insert(i, data); } else { ResultList->Insert(j, data); } ResultList->Remove(fstData); ResultList->Remove(secData); delete fstData; delete secData; fstData = data; /* if (result->Count > 1){ MakeResult(result, fstData, secData, -1, -1, Item, false); if (result->Count == 1){ TVecData *data = (TVecData *)result->Items[0]; result->Remove(data); if (i < j){ ResultList->Insert(i, data); } else { ResultList->Insert(j, data); } ResultList->Remove(fstData); ResultList->Remove(secData); delete fstData; delete secData; fstData = data; } } else if (result->Count == 1){ TVecData *data = (TVecData *)result->Items[0]; result->Remove(data); if (i < j){ ResultList->Insert(i, data); } else { ResultList->Insert(j, data); } ResultList->Remove(fstData); ResultList->Remove(secData); delete fstData; delete secData; fstData = data; } */ } DeleteVecList(result); delete result; } while (IntersectionPtList->Count > 0) { DPOINT *pt = (DPOINT*)IntersectionPtList->Last(); IntersectionPtList->Remove(pt); delete pt; } delete IntersectionPtList; } } } } while (ResultList->Count > 0) { TVecData *data = (TVecData*)ResultList->Last(); if (data->bPatternFill) MakePatternBitmap(data); SetRect(data); if (bApplyList) { DataList->Insert(Index, data); UndoSave(VU_CREATE, Index, false); } ResultList->Remove(data); } } } else { TVecData *outData = (TVecData*)ResultList->Items[resultIndex]; if (outData->bPatternFill) MakePatternBitmap(outData); SetRect(outData); if (bApplyList) { DataList->Insert(Index, outData); UndoSave(VU_CREATE, Index, false); } ResultList->Remove(outData); } } else { while (ResultList->Count > 0) { TVecData *data = (TVecData*)ResultList->Last(); if (data->bPatternFill) MakePatternBitmap(data); SetRect(data); if (bApplyList) { DataList->Insert(Index, data); if (Item != C_EACH_CUT) UndoSave(VU_CREATE, Index, false); } ResultList->Remove(data); } } } END_LOG; } // --------------------------------------------------------------------------- /// Gradient¸¦ ½ÇÇàÇÒ °ÍÀÎÁö üũ. ½ÇÇàÇÒ ¼ö ÀÖÀ» ¶§´Â Color¿Í nCount¸¦ ¹ÝÈ¯ÇØÁØ´Ù. bool __fastcall TVecDraw::CheckGradient(TColor *Color, int *Count) { bool rtn = false; TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) int count = 0, index; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (data->bSelected) { count++; index = i; } } if (count == 1) { rtn = true; TVecData *data = (TVecData*)DataList->Items[index]; *Color = data->Color; *Count = data->nCount; } return rtn; } // --------------------------------------------------------------------------- /// object¿¡ Gradient¿¡ ÇÊ¿äÇÑ dataµéÀ» ¼³Á¤ÇØÁØ´Ù. void __fastcall TVecDraw::FillGradient(POINT PtStart, POINT PtEnd) { TList *DataList = NVector->DataList; TVecData *data = NULL; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (data->bSelected) break; } if (data->gradientColorCount > 1) { int x = 0, y = 0, centerx = 0, centery = 0; for (int i = 0; i < data->nCount + 1; i++) { x += data->pList[i * 3].x; y += data->pList[i * 3].y; } centerx = x / (data->nCount + 1); centery = y / (data->nCount + 1); double basis = tan((double)(centery - data->pList[0].y) / (centerx - data->pList[0].x)); double addition = tan((double)(PtStart.y - PtEnd.y) / (PtStart.x - PtEnd.x) ); data->gAngle = atan((double)(basis - addition) / (1 + basis * addition)); data->bGradientFill = true; data->bPatternFill = false; data->bFill = false; } else if (data->gradientColorCount == 0) { data->bFill = true; data->bGradientFill = true; data->bPatternFill = false; } } // --------------------------------------------------------------------------- /// Gradient°¡ ¼³Á¤µÈ object¸¦ item¿¡ µû¶ó dcDst¿¡ ±×·ÁÁØ´Ù. GDI+ void __fastcall TVecDraw::DrawGradientFill(HDC dcDst, TVecData *data, gdp::PointF *Points, int PointCount, int FirstX, int FirstY, int SecondX, int SecondY, int nReflectionMode, int nReflectionIndex, gdp::PointF *RefPoints, int R_FirstX, int R_FirstY, int R_SecondX, int R_SecondY) { POINT *pPoints1 = NULL, *pPoints2 = NULL; // pPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) int sx, sy, ex, ey, sx2, sy2, ex2, ey2; sx = FirstX; ex = SecondX; sy = FirstY; ey = SecondY; // ¹ÝÀü °Å¿ï ¸ðµå Ãß°¡ - by monkman (2009.04.15) TVecData *datagradient = NULL; if (nReflectionMode == 1 || nReflectionMode == 2) { datagradient = new TVecData(data->GetInstNum()); datagradient->Copy(data); GradientVecDataReflection(datagradient, nReflectionMode); sx2 = R_FirstX; ex2 = R_SecondX; sy2 = R_FirstY; ey2 = R_SecondY; } pPoints1 = new POINT[PointCount]; pPoints2 = new POINT[PointCount]; for (int i = 0; i < PointCount; i++) { pPoints1[i].x = Points[i].X; pPoints1[i].y = Points[i].Y; // ¹ÝÀü °Å¿ï ¸ðµå Ãß°¡ - by monkman (2009.04.15) if ((nReflectionMode == 1 || nReflectionMode == 2) && datagradient) { pPoints2[i].x = RefPoints[i].X; pPoints2[i].y = RefPoints[i].Y; } } switch(data->gradientItem) { case G_LINEAR_SIMPLE: DrawGradientLinearSimple(dcDst, data, pPoints1, PointCount, sx, sy, ex, ey); // ¹ÝÀü °Å¿ï ¸ðµå Ãß°¡ - by monkman (2009.04.15) if ((nReflectionMode == 1 || nReflectionMode == 2) && datagradient) DrawGradientLinearSimple(dcDst, datagradient, pPoints2, PointCount, sx2, sy2, ex2, ey2); break; case G_LINEAR_CENTER: DrawGradientLinearCenter(dcDst, data, pPoints1, PointCount, sx, sy, ex, ey); // ¹ÝÀü °Å¿ï ¸ðµå Ãß°¡ - by monkman (2009.04.15) if ((nReflectionMode == 1 || nReflectionMode == 2) && datagradient) DrawGradientLinearCenter(dcDst, datagradient, pPoints2, PointCount, sx2, sy2, ex2, ey2); break; case G_CORNER: DrawGradientCorner(dcDst, data, pPoints1, PointCount, sx, sy, ex, ey); // ¹ÝÀü °Å¿ï ¸ðµå Ãß°¡ - by monkman (2009.04.15) if ((nReflectionMode == 1 || nReflectionMode == 2) && datagradient) DrawGradientCorner(dcDst, datagradient, pPoints2, PointCount, sx2, sy2, ex2, ey2); break; case G_CENTER: DrawGradientCenter(dcDst, data, pPoints1, PointCount, sx, sy, ex, ey); // ¹ÝÀü °Å¿ï ¸ðµå Ãß°¡ - by monkman (2009.04.15) if ((nReflectionMode == 1 || nReflectionMode == 2) && datagradient) DrawGradientCenter(dcDst, datagradient, pPoints2, PointCount, sx2, sy2, ex2, ey2); break; } // ¹ÝÀü °Å¿ï ¸ðµå Ãß°¡ - by monkman (2009.04.15) if ((nReflectionMode == 1 || nReflectionMode == 2) && datagradient) { delete datagradient; } datagradient = NULL; if (pPoints1) delete[]pPoints1; pPoints1 = NULL; if (pPoints2) delete[]pPoints2; pPoints2 = NULL; } // --------------------------------------------------------------------------- /// Gradient°¡ ¼³Á¤µÈ object¸¦ item¿¡ µû¶ó dcDst¿¡ ±×·ÁÁØ´Ù. GDI void __fastcall TVecDraw::DrawGradientFill(HDC dcDst, TVecData *data, POINT *Points, int PointCount, int FirstX, int FirstY, int SecondX, int SecondY, int nReflectionMode, int nReflectionIndex, POINT *RefPoints, int R_FirstX, int R_FirstY, int R_SecondX, int R_SecondY) { int sx, sy, ex, ey, sx2, sy2, ex2, ey2; sx = FirstX; ex = SecondX; sy = FirstY; ey = SecondY; // ¹ÝÀü °Å¿ï ¸ðµå Ãß°¡ - by monkman (2009.04.15) TVecData *datagradient = NULL; if (nReflectionMode == 1 || nReflectionMode == 2) { datagradient = new TVecData(data->GetInstNum()); datagradient->Copy(data); GradientVecDataReflection(datagradient, nReflectionMode); sx2 = R_FirstX; ex2 = R_SecondX; sy2 = R_FirstY; ey2 = R_SecondY; } switch(data->gradientItem) { case G_LINEAR_SIMPLE: DrawGradientLinearSimple(dcDst, data, Points, PointCount, sx, sy, ex, ey); // ¹ÝÀü °Å¿ï ¸ðµå Ãß°¡ - by monkman (2009.04.15) if ((nReflectionMode == 1 || nReflectionMode == 2) && datagradient) DrawGradientLinearSimple(dcDst, datagradient, RefPoints, PointCount, sx2, sy2, ex2, ey2); break; case G_LINEAR_CENTER: DrawGradientLinearCenter(dcDst, data, Points, PointCount, sx, sy, ex, ey); // ¹ÝÀü °Å¿ï ¸ðµå Ãß°¡ - by monkman (2009.04.15) if ((nReflectionMode == 1 || nReflectionMode == 2) && datagradient) DrawGradientLinearCenter(dcDst, datagradient, RefPoints, PointCount, sx2, sy2, ex2, ey2); break; case G_CORNER: DrawGradientCorner(dcDst, data, Points, PointCount, sx, sy, ex, ey); // ¹ÝÀü °Å¿ï ¸ðµå Ãß°¡ - by monkman (2009.04.15) if ((nReflectionMode == 1 || nReflectionMode == 2) && datagradient) DrawGradientCorner(dcDst, datagradient, RefPoints, PointCount, sx2, sy2, ex2, ey2); break; case G_CENTER: DrawGradientCenter(dcDst, data, Points, PointCount, sx, sy, ex, ey); // ¹ÝÀü °Å¿ï ¸ðµå Ãß°¡ - by monkman (2009.04.15) if ((nReflectionMode == 1 || nReflectionMode == 2) && datagradient) DrawGradientCenter(dcDst, datagradient, RefPoints, PointCount, sx2, sy2, ex2, ey2); break; } // ¹ÝÀü °Å¿ï ¸ðµå Ãß°¡ - by monkman (2009.04.15) if ((nReflectionMode == 1 || nReflectionMode == 2) && datagradient) { delete datagradient; } datagradient = NULL; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::DrawGradientLinearSimple(HDC dcDst, TVecData *data, POINT *Points, int PointCount, int sx, int sy, int ex, int ey) { POINT *pPoints = NULL; // pPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) BYTE r0, g0, b0, r1, g1, b1; r0 = data->gradientColors[0].rgbRed; g0 = data->gradientColors[0].rgbGreen; b0 = data->gradientColors[0].rgbBlue; r1 = data->gradientColors[1].rgbRed; g1 = data->gradientColors[1].rgbGreen; b1 = data->gradientColors[1].rgbBlue; TRIVERTEX vert[] = { { sx, sy, (r0) << 8, (g0) << 8, (b0) << 8, 0 }, { ex, ey, (r1) << 8, (g1) << 8, (b1) << 8, 0 }, { sx, ey, ((r0 + r1) / 2) << 8, ((g0 + g1) / 2) << 8, ((b0 + b1) / 2) << 8, 0 }, { ex, sy, ((r0 + r1) / 2) << 8, ((g0 + g1) / 2) << 8, ((b0 + b1) / 2) << 8, 0 } }; ULONG Index[] = { 0, 1, 2, 0, 1, 3 }; if (data->Kind == V_TEXTBOX) { pPoints = new POINT[5]; } else { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new POINT[(data->nCount + 1) * 3 + 1]; } else { pPoints = new POINT[data->nCount * 3 + 1]; } } for (int i = 0; i < PointCount; i++) { pPoints[i].x = Points[i].x; pPoints[i].y = Points[i].y; } BeginPath(dcDst); MoveToEx(dcDst, pPoints[0].x, pPoints[0].y, NULL); PolyBezierTo(dcDst, pPoints + 1, data->nCount * 3); EndPath(dcDst); HRGN oldRgn; GetClipRgn(dcDst, oldRgn); HRGN rgn = PathToRegion(dcDst); ExtSelectClipRgn(dcDst, rgn, RGN_AND); switch(data->gAngle) { case 0: GradientFill(dcDst, vert, 2, Index, 1, GRADIENT_FILL_RECT_H); break; case 1: // 45: GradientFill(dcDst, vert, 4, Index, 2, GRADIENT_FILL_TRIANGLE); break; case 2: // 90: GradientFill(dcDst, vert, 2, Index, 1, GRADIENT_FILL_RECT_V); break; case 3: // 135: vert[0].x = ex; vert[3].x = sx; vert[1].x = sx; vert[2].x = ex; GradientFill(dcDst, vert, 4, Index, 2, GRADIENT_FILL_TRIANGLE); break; } if (bIsPrint) SelectClipRgn(dcDst, oldRgn); else SelectClipRgn(dcDst, NULL); DeleteObject(rgn); if (pPoints) delete[]pPoints; pPoints = NULL; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::DrawGradientLinearCenter(HDC dcDst, TVecData *data, POINT *Points, int PointCount, int sx, int sy, int ex, int ey) { POINT *pPoints = NULL; // pPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) BYTE r0, g0, b0, r1, g1, b1; r0 = data->gradientColors[0].rgbRed; g0 = data->gradientColors[0].rgbGreen; b0 = data->gradientColors[0].rgbBlue; r1 = data->gradientColors[1].rgbRed; g1 = data->gradientColors[1].rgbGreen; b1 = data->gradientColors[1].rgbBlue; TRIVERTEX vert[] = { { sx, sy, (r0) << 8, (g0) << 8, (b0) << 8, 0 }, { ex, (sy + ey) / 2, (r1) << 8, (g1) << 8, (b1) << 8, 0 }, { sx, (sy + ey) / 2, (r1) << 8, (g1) << 8, (b1) << 8, 0 }, { ex, ey, (r0) << 8, (g0) << 8, (b0) << 8, 0 }, { ex, sy, (r1) << 8, (g1) << 8, (b1) << 8, 0 }, { sx, ey, (r1) << 8, (g1) << 8, (b1) << 8, 0 }, { (sx + ex) / 2, ey, (r1) << 8, (g1) << 8, (b1) << 8, 0 }, { (sx + ex) / 2, sy, (r1) << 8, (g1) << 8, (b1) << 8, 0 } }; TRIVERTEX vert2[] = { { sx, sy, (r1) << 8, (g1) << 8, (b1) << 8, 0 }, { ex, sy, (r0) << 8, (g0) << 8, (b0) << 8, 0 }, { sx, ey, (r0) << 8, (g0) << 8, (b0) << 8, 0 }, { ex, ey, (r1) << 8, (g1) << 8, (b1) << 8, 0 } }; if (data->Kind == V_TEXTBOX) { pPoints = new POINT[5]; } else { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new POINT[(data->nCount + 1) * 3 + 1]; } else { pPoints = new POINT[data->nCount * 3 + 1]; } } for (int i = 0; i < PointCount; i++) { pPoints[i].x = Points[i].x; pPoints[i].y = Points[i].y; } BeginPath(dcDst); MoveToEx(dcDst, pPoints[0].x, pPoints[0].y, NULL); PolyBezierTo(dcDst, pPoints + 1, data->nCount * 3); EndPath(dcDst); HRGN oldRgn; GetClipRgn(dcDst, oldRgn); HRGN rgn = PathToRegion(dcDst); ExtSelectClipRgn(dcDst, rgn, RGN_AND); ULONG Index[10]; switch(data->gAngle) { case 0: // 0 Index[0] = 0; Index[1] = 6; Index[2] = 7; Index[3] = 3; // Index[] = { 0, 6, 7, 3 }; GradientFill(dcDst, vert, 8, Index, 2, GRADIENT_FILL_RECT_H); break; case 1: // 45 Index[0] = 0; Index[1] = 4; Index[2] = 5; Index[3] = 4; Index[4] = 5; Index[5] = 3; GradientFill(dcDst, vert, 6, Index, 2, GRADIENT_FILL_TRIANGLE); break; case 2: // 90 Index[0] = 0; Index[1] = 1; Index[2] = 2; Index[3] = 3; // ULONG Index[] = { 0, 1, 2, 3 }; GradientFill(dcDst, vert, 4, Index, 2, GRADIENT_FILL_RECT_V); break; case 3: // 135 // ULONG Index[] = { 0, 1, 3, 0, 3, 2 }; Index[0] = 0; Index[1] = 1; Index[2] = 3; Index[3] = 0; Index[4] = 3; Index[5] = 2; GradientFill(dcDst, vert2, 4, Index, 2, GRADIENT_FILL_TRIANGLE); break; } if (bIsPrint) SelectClipRgn(dcDst, oldRgn); else SelectClipRgn(dcDst, NULL); DeleteObject(rgn); if (pPoints) delete[]pPoints; pPoints = NULL; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::DrawGradientCorner(HDC dcDst, TVecData *data, POINT *Points, int PointCount, int sx, int sy, int ex, int ey) { POINT *pPoints = NULL; // pPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) BYTE r0, g0, b0, r1, g1, b1; r0 = data->gradientColors[0].rgbRed; g0 = data->gradientColors[0].rgbGreen; b0 = data->gradientColors[0].rgbBlue; r1 = data->gradientColors[1].rgbRed; g1 = data->gradientColors[1].rgbGreen; b1 = data->gradientColors[1].rgbBlue; TRIVERTEX vert[] = { { sx, sy, (r1) << 8, (g1) << 8, (b1) << 8, 0 }, { ex, sy, (r1) << 8, (g1) << 8, (b1) << 8, 0 }, { ex, ey, (r1) << 8, (g1) << 8, (b1) << 8, 0 }, { sx, ey, (r1) << 8, (g1) << 8, (b1) << 8, 0 } }; int corner = data->gAngle; vert[corner].Red = (r0) << 8; vert[corner].Green = (g0) << 8; vert[corner].Blue = (b0) << 8; ULONG Index[] = { corner, (corner + 1) % 4, (corner + 2) % 4, corner, (corner + 3) % 4, (corner + 2) % 4 }; if (data->Kind == V_TEXTBOX) { pPoints = new POINT[5]; } else { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new POINT[(data->nCount + 1) * 3 + 1]; } else { pPoints = new POINT[data->nCount * 3 + 1]; } } for (int i = 0; i < PointCount; i++) { pPoints[i].x = Points[i].x; pPoints[i].y = Points[i].y; } BeginPath(dcDst); MoveToEx(dcDst, pPoints[0].x, pPoints[0].y, NULL); PolyBezierTo(dcDst, pPoints + 1, data->nCount * 3); EndPath(dcDst); /* HRGN oldRgn; GetClipRgn(dcDst, oldRgn); HRGN rgn = PathToRegion(dcDst); SelectClipRgn(dcDst, rgn); */ HRGN oldRgn; GetClipRgn(dcDst, oldRgn); HRGN rgn = PathToRegion(dcDst); ExtSelectClipRgn(dcDst, rgn, RGN_AND); GradientFill(dcDst, vert, 4, Index, 2, GRADIENT_FILL_TRIANGLE); if (bIsPrint) SelectClipRgn(dcDst, oldRgn); else SelectClipRgn(dcDst, NULL); DeleteObject(rgn); if (pPoints) delete[]pPoints; pPoints = NULL; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::DrawGradientCenter(HDC dcDst, TVecData *data, POINT *Points, int PointCount, int sx, int sy, int ex, int ey) { POINT *pPoints = NULL; // pPoints[1024]¸¦ µ¿ÀûÀ¸·Î ÇÒ´ç¹Þµµ·Ï ¼öÁ¤ - by monkman (2011.04.14) BYTE r0, g0, b0, r1, g1, b1; r0 = data->gradientColors[0].rgbRed; g0 = data->gradientColors[0].rgbGreen; b0 = data->gradientColors[0].rgbBlue; r1 = data->gradientColors[1].rgbRed; g1 = data->gradientColors[1].rgbGreen; b1 = data->gradientColors[1].rgbBlue; if (data->Kind == V_TEXTBOX) { pPoints = new POINT[5]; } else { if (data->bClosed && data->PenStyle == P_SOLID) { pPoints = new POINT[(data->nCount + 1) * 3 + 1]; } else { pPoints = new POINT[data->nCount * 3 + 1]; } } for (int i = 0; i < PointCount; i++) { pPoints[i].x = Points[i].x; pPoints[i].y = Points[i].y; } BeginPath(dcDst); MoveToEx(dcDst, pPoints[0].x, pPoints[0].y, NULL); PolyBezierTo(dcDst, pPoints + 1, data->nCount * 3); EndPath(dcDst); /* HRGN oldRgn; GetClipRgn(dcDst, oldRgn); HRGN rgn = PathToRegion(dcDst); SelectClipRgn(dcDst, rgn); */ HRGN oldRgn; GetClipRgn(dcDst, oldRgn); HRGN rgn = PathToRegion(dcDst); ExtSelectClipRgn(dcDst, rgn, RGN_AND); const double PI2 = 3.1415927 * 2; int nPart = 0; if (data->gAngle > 0) { // Angle·Î °è»êÇÏ¿© part¸¦ ³ª´©¾î ±×¸². nPart = data->gAngle; } else { nPart = data->nCount; // dataÀÇ °¢ ³¡Á¡À» part·Î ³ª´©¾î ±×¸². } TRIVERTEX * pVertex = new TRIVERTEX[nPart + 1]; ULONG * pMesh = new ULONG[(nPart + 1) * 3]; if (data->gAngle == 0) { int centerX = 0, centerY = 0; for (int i = 0; i < nPart; i++) { pVertex[i + 1].x = Points[(i + 1) * 3].x; pVertex[i + 1].y = Points[(i + 1) * 3].y; pVertex[i + 1].Red = (r1) << 8; pVertex[i + 1].Green = (g1) << 8; pVertex[i + 1].Blue = (b1) << 8; pVertex[i + 1].Alpha = 0; pMesh[i * 3] = 0; pMesh[i * 3 + 1] = i + 1; pMesh[i * 3 + 2] = (i + 1) % nPart + 1; centerX += Points[(i + 1) * 3].x; centerY += Points[(i + 1) * 3].y; } centerX /= (nPart); centerY /= (nPart); pVertex[0].x = centerX; pVertex[0].y = centerY; pVertex[0].Red = (r0) << 8; pVertex[0].Green = (g0) << 8; pVertex[0].Blue = (b0) << 8; pVertex[0].Alpha = 0; } else { int centerx = (sx + ex) / 2; int centery = (sy + ey) / 2; pVertex[0].x = centerx; pVertex[0].y = centery; pVertex[0].Red = (r0) << 8; pVertex[0].Green = (g0) << 8; pVertex[0].Blue = (b0) << 8; pVertex[0].Alpha = 0; // center¿¡¼­ °¡Àå ¸Õ Á¡±îÁöÀÇ °Å¸® // int centerX = 0, centerY = 0; int maxlen = 0; for (int i = 0; i < data->nCount; i++) { int len = sqrt((Points[i * 3].x - centerx) * (Points[i * 3].x - centerx) + (Points[i * 3].y - centery) * (Points[i * 3].y - centery)); if (len > maxlen) maxlen = len; } int len = maxlen; int borderlen = sqrt((ex - sx) * (ex - sx) + (ey - sy) * (ey - sy)) / 2; if (maxlen < borderlen) len = (borderlen - maxlen) / 2 + maxlen; double temp = cos(360 / (nPart * 2) * (M_PI / 180.0)); int radius = (double)len / temp; for (int i = 0; i < nPart; i++) { pVertex[i + 1].x = centerx + (int)(radius * cos(PI2 * i / nPart)); pVertex[i + 1].y = centery + (int)(radius * sin(PI2 * i / nPart)); pVertex[i + 1].Red = (r1) << 8; pVertex[i + 1].Green = (g1) << 8; pVertex[i + 1].Blue = (b1) << 8; pVertex[i + 1].Alpha = 0; pMesh[i * 3 + 0] = 0; pMesh[i * 3 + 1] = i + 1; pMesh[i * 3 + 2] = (i + 1) % nPart + 1; } } GradientFill(dcDst, pVertex, nPart + 1, pMesh, nPart, GRADIENT_FILL_TRIANGLE); if (pVertex) delete[]pVertex; pVertex = NULL; if (pMesh) delete[]pMesh; pMesh = NULL; if (bIsPrint) SelectClipRgn(dcDst, oldRgn); else SelectClipRgn(dcDst, NULL); DeleteObject(rgn); if (pPoints) delete[]pPoints; pPoints = NULL; } // --------------------------------------------------------------------------- /// object¿¡ Gradient¿¡ ÇÊ¿äÇÑ dataµéÀ» ¼³Á¤ÇØÁØ´Ù. void __fastcall TVecDraw::SetGradientData(EGradientItem GradientItem, int ColorCount, TColor *Colors, int Angle) { BEGIN_LOG(""); TList *DataList = NVector->DataList; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (data->bSelected) { UndoSave(VU_MODIFY, i, true); if (data->gradientColors) delete[] data->gradientColors; if (ColorCount > 1){ data->gradientColors = new RGBQUAD[ColorCount]; for (int i = 0; i < ColorCount; i++){ Byte r, g, b; TColor2RGB(Colors[i], r, g, b); data->gradientColors[i].rgbRed = r; data->gradientColors[i].rgbGreen = g; data->gradientColors[i].rgbBlue = b; data->gradientColors[i].rgbReserved = 255; } data->gradientItem = GradientItem; data->gradientColorCount = ColorCount; data->gAngle = Angle;//atan((double)(basis - addition)/(1 + basis*addition)); data->bGradientFill = true; data->bPatternFill = false; data->bFill = false; } else if (ColorCount == 0){ data->Brush = Colors[0]; data->bFill = true; data->bGradientFill = true; data->bPatternFill = false; } } } /* if (data->gradientColors) delete[]data->gradientColors; data->gradientColors = NULL; if (ColorCount > 1) { data->gradientColors = new RGBQUAD[ColorCount]; for (int i = 0; i < ColorCount; i++) { Byte r, g, b; TColor2RGB(Colors[i], r, g, b); data->gradientColors[i].rgbRed = r; data->gradientColors[i].rgbGreen = g; data->gradientColors[i].rgbBlue = b; data->gradientColors[i].rgbReserved = 255; } data->gradientItem = GradientItem; data->gradientColorCount = ColorCount; data->gAngle = Angle; // atan((double)(basis - addition)/(1 + basis*addition)); data->bGradientFill = true; data->bPatternFill = false; data->bFill = false; } else if (ColorCount == 0) { data->Brush = Colors[0]; data->bFill = true; data->bGradientFill = true; data->bPatternFill = false; } */ END_LOG; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::GradientFillMouseUp(int X, int Y) { return; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::GradientFillMouseMove(int X, int Y) { if (mousedown == 1) MainImageForm->DrawLineLocate(First, Point(X, Y)); } // --------------------------------------------------------------------------- void __fastcall TVecDraw::GradientFillMouseDown(int X, int Y) { /* mousedown++; if (mousedown == 1){ First.x = X; First.y = Y; } else if (mousedown == 2){ Second.x = X; Second.y = Y; FillGradient(First, Second);//GradientItem, GradientCount, ColorValues, First, Second); mousedown = 0; } */ return; } // --------------------------------------------------------------------------- /// Curve lineÀÌ Æ÷ÇÔµÈ objectÀÇ °æ¿ì °¢ ¸ð¼­¸®¿¡¼­ Gradient°¡ µÇµµ·Ï ÇÒ ¼ö ¾øÀ¸¹Ç·Î üũ°¡ ÇÊ¿äÇÔ. bool __fastcall TVecDraw::hasCurveInSelectObject() { BEGIN_LOG(""); bool rtn = false; TList *DataList = NVector->DataList; TVecData *data = NULL; int count = 0, index = 0; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (!data->Equal(MainImageForm->Number)) continue; if (data->bSelected){ for(int i = 0; i < data->nCount; i++){ if (data->pList[i*3].x != data->pList[i*3 + 1].x || data->pList[i*3].y != data->pList[i*3 + 1].y){ rtn = true; break; } if (i != 0){ if (data->pList[i*3].x != data->pList[i*3 - 1].x || data->pList[i*3].y != data->pList[i*3 - 1].y){ rtn = true; break; } } } } // if (data->bSelected) { // count++; // index = i; // } } /* if (count == 1) { data = (TVecData*)DataList->Items[index]; for (int i = 0; i < data->nCount; i++) { if (data->pList[i * 3].x != data->pList[i * 3 + 1].x || data->pList[i * 3] .y != data->pList[i * 3 + 1].y) { rtn = true; break; } if (i != 0) { if (data->pList[i * 3].x != data->pList[i * 3 - 1].x || data->pList [i * 3].y != data->pList[i * 3 - 1].y) { rtn = true; break; } } } } */ END_LOG; return rtn; } // --------------------------------------------------------------------------- float __fastcall TVecDraw::FindContactPoint(TVecData *data, DPOINT &findpt) { int width = data->PenThick; DPOINT onPoint; float x = data->pList[0].x; float y = data->pList[0].y; float len = 3 * width * width; float t = 0.01; float dist = 0.0; float min = len; float minx = 0, miny = 0; float mint = 0.0; for (t = 0.01; t < 1; t += 0.01) { onPoint = FindingPointOnBezier(&data->pList[0], t); dist = (x - onPoint.x) * (x - onPoint.x) + (y - onPoint.y) * (y - onPoint.y); if (abs(long(len - dist)) < min) { minx = onPoint.x; miny = onPoint.y; min = abs(long(len - dist)); mint = t; } } findpt.x = minx; findpt.y = miny; return mint; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::DrawArrow(HDC dcDst, TVecData *data) { POINT pTemp[4], pLineTemp[1024]; DPOINT findpt, uppt, downpt; float t = FindContactPoint(data, findpt); uppt = FindingNormalOnBezier(&data->pList[0], t, data->PenThick, true); downpt = FindingNormalOnBezier(&data->pList[0], t, data->PenThick, false); pTemp[0].x = data->pList[0].x; pTemp[0].y = data->pList[0].y; pTemp[1].x = uppt.x; pTemp[1].y = uppt.y; pTemp[2].x = downpt.x; pTemp[2].y = downpt.y; pTemp[3].x = data->pList[0].x; pTemp[3].y = data->pList[0].y; Polyline(dcDst, pTemp, 4); /* pLineTemp[0].x = ; pLineTemp[0].y = ; for (int i = 1; i < (data->nCount+(data->bClosed&&data->PenStyle==P_SOLID))*3+1; i++){ pLineTemp[i].x = data->pList[i].x; pLineTemp[i].y = data->pList[i].y; } PolyBezier(dcDst, pLineTemp, (data->nCount+(data->bClosed&&data->PenStyle==P_SOLID))*3+1); */ } // --------------------------------------------------------------------------- void __fastcall TVecDraw::FreeDrawing() { int pList_index = 0, previous_count, additional_count; int point_list_size = bezierCurveApproximator.freeDrawingPointList.size(); TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) int nCheckJoinX, nCheckJoinY; bezierCurveApproximator.Approximate2(0, point_list_size); std::list::iterator iter = bezierCurveApproximator.bezierCurvePointsList.begin(); if (bezierCurveApproximator.bezierCurvePointsList.size() == 0) { bezierCurveApproximator.Reset(); return; } TList *DataList = NVector->DataList; /* std::list::iterator ii = bezierCurveApproximator.freeDrawingPointList.begin(); for(int a = 0 ; a < point_list_size - 1 ; ++a) LineAdd (V_LINE, *ii, *(++ii)); */ if (NVector->bExtend) { data = (TVecData*)DataList->Items[Index]; UndoSave(VU_MODIFY, Index); if (NVector->bExtendFirst) { // ùÁ¡À» ¿¬ÀåÇÏ´Â °æ¿ì´Â ùÁ¡À» ¸¶Áö¸·Á¡À¸·Î ¹Ù²Ù°í ¿¬°áÇÑ´Ù POINT *temp = new POINT[data->nCount * 3 + 1]; for (int i = 0; i < data->nCount * 3 + 1; i++) temp[i] = data->pList[i].P(); for (int i = 0; i < data->nCount * 3 + 1; i++) data->pList[i].DPoint(temp[data->nCount * 3 - i]); if (temp) delete[]temp; temp = NULL; } } else if ((data = new TVecData(MainImageForm->Number)) == NULL) return; NVector->bExtendFirst = false; data->Kind = V_CURVE; data->bRound = !PenManagerForm->Pen->Shape; data->Color = PenManagerForm->PenShape->Pen->Color; // -----------------> 2005 Vector Upgrade Shin 0315 data->PenThick = VectorForm->DrawingThick; data->PenStyle = (EPenStyle)VectorForm->PenStyle; data->CapStyle[0] = VectorForm->CapStyle[0]; data->CapStyle[1] = VectorForm->CapStyle[1]; if (data->ArrowCap){ data->ArrowCap->LineCapWidthScale = VectorForm->LineCapWidthScale; data->ArrowCap->LineCapWidth = VectorForm->LineCapWidth; data->ArrowCap->LineCapHeight = VectorForm->LineCapHeight; data->ArrowCap->LineCapLine = VectorForm->LineCapLine; data->ArrowCap->bFillLineCap = VectorForm->bFillLineCap; data->ArrowCap->bShowArrowBoth = VectorForm->bShowArrowBoth; } thick = data->PenThick; if (data->PenStyle == P_USERSTYLE) { data->DashValues[0] = dashcount; data->DashValues[1] = dset[0] / thick; data->DashValues[2] = dset[1] / thick; data->DashValues[3] = dset[2] / thick; data->DashValues[4] = dset[3] / thick; data->DashValues[5] = dset[4] / thick; data->DashValues[6] = dset[5] / thick; } // -------------< previous_count = data->nCount; additional_count = bezierCurveApproximator.bezierCurvePointsList.size(); data->nCount = previous_count + additional_count; if (NVector->bExtend) { 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); pList_index = previous_count * 3 + 1; } else { 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); pList_index = 0; } // ------------------> 2005 Vector upgrade Shin 0315 // Color fill ¼³Á¤ 20050225 shin if (VectorForm->cbFill->Checked) { data->bFill = true; data->Brush = PenManagerForm->PenShape->Pen->Color; } else data->bFill = false; // Antialiasing ¼³Á¤ : ±×¸±¶§ 20050222 shin data->bAntialiasing = VectorForm->cbObjAntialiasing->Checked; // -----------------------------------< if (!NVector->bExtend) { DataList->Add(data); UndoSave(VU_CREATE, DataList->Count - 1); /* data->pList[pList_index++].DPoint(iter->start); data->pList[pList_index++].DPoint(iter->control1); data->pList[pList_index++].DPoint(iter->control2); data->pList[pList_index++].DPoint(iter->end); ++iter; } while(iter != bezierCurveApproximator.bezierCurvePointsList.end()) { data->pList[pList_index++].DPoint(iter->control1); data->pList[pList_index++].DPoint(iter->control2); data->pList[pList_index++].DPoint(iter->end); ++iter; } */ // 2009 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É - 'J'۸¦ ´­·¶À» ¶§ ùÁ¡ÀÌ ¹ÝÀü ±âÁؼ±¿¡ ´Þ¶ó ºÙµµ·Ï ÇÑ´Ù - by monkman (2009.11.27) nCheckJoinX = (int)(iter->start.x + 0.5); nCheckJoinY = (int)(iter->start.y + 0.5); if (bJKeyState && NVector->bVectorReflectionMode) { // ¼öÁ÷ ±âÁؼ± if (NVector->ReflectionVH == 1 && nCheckJoinX == NVector->ReflectionVIndex) { data->bFirstJoin = true; bJoinState = false; // ´Ù½Ã ÃʱâÈ­½ÃÄÑÁØ´Ù } // ¼öÆò ±âÁؼ± if (NVector->ReflectionVH == 2 && nCheckJoinY == NVector->ReflectionHIndex) { data->bFirstJoin = true; bJoinState = false; // ´Ù½Ã ÃʱâÈ­½ÃÄÑÁØ´Ù } } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- data->pList[pList_index++] = iter->start; data->pList[pList_index++] = iter->control1; data->pList[pList_index++] = iter->control2; data->pList[pList_index++] = iter->end; ++iter; } while (iter != bezierCurveApproximator.bezierCurvePointsList.end()) { data->pList[pList_index++] = iter->control1; data->pList[pList_index++] = iter->control2; data->pList[pList_index++] = iter->end; ++iter; } if (data) { // 2009 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É - 'J'۸¦ ´­·¶À» ¶§ ùÁ¡ÀÌ ¹ÝÀü ±âÁؼ±¿¡ ´Þ¶ó ºÙµµ·Ï ÇÑ´Ù - by monkman (2009.11.27) --iter; // ¸¶Áö¸·À¸·Î µÇµ¹¸°´Ù nCheckJoinX = (int)(iter->end.x + 0.5); nCheckJoinY = (int)(iter->end.y + 0.5); if (bJKeyState && NVector->bVectorReflectionMode) { // ¼öÁ÷ ±âÁؼ± if (NVector->ReflectionVH == 1 && nCheckJoinX == NVector->ReflectionVIndex) { data->bLastJoin = true; } // ¼öÆò ±âÁؼ± if (NVector->ReflectionVH == 2 && nCheckJoinY == NVector->ReflectionHIndex) { data->bLastJoin = true; } } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } NVector->bClosedState = bAltState && IsFreeDrawingClosingState (data->pList[data->nCount * 3].x, data->pList[data->nCount * 3].y); bezierCurveApproximator.Reset(); SET_RECT; if (NVector->bClosedState) { data->bClosed = true; NVector->step = 0; NVector->bFstLine = true; bJoinState = false; // stepÀÌ 0 À̸é ÃʱâÈ­ ÇØÁØ´Ù - by monkman (2009.11.26) MainImageForm->iMainImage->Cursor = crDefault; } NVector->bFirst = true; NVector->bFstLine = true; if (VectorForm->sbSpray->Down && tempChildList && tempChildList->Count) { data = (TVecData*)DataList->Last(); MakeMotiveObject(data); } RECT rc = TRect(data->First.x - data->PenThick, data->First.y - data->PenThick, data->Second.x + data->PenThick, data->Second.y + data->PenThick); MainImageForm->iMainImage->RectPaint(rc); return; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::DrawTracesOfFreeDrawing(HDC dcDst) { TPItemImage* Image = MainImageForm->iMainImage; float ratio = (float)Image->ZoomIn / Image->ZoomOut; int nXOffset = -Image->PositionX * ratio; int nYOffset = -Image->PositionY * ratio; HPEN newPen = CreatePen(PS_SOLID, (VectorForm->DrawingThick)*ratio , PenManagerForm->PenShape->Pen->Color); HPEN oldPen = (HPEN)SelectObject(dcDst, newPen); int oldDrawMode = SetROP2(dcDst, R2_COPYPEN); TPoint st_view_point, end_view_point; std::list::iterator i = bezierCurveApproximator.freeDrawingPointList.begin(); st_view_point.x = nXOffset + (i->x * ratio); st_view_point.y = nYOffset + (i->y * ratio); MoveToEx(dcDst, st_view_point.x, st_view_point.y, NULL); i++; while (i != bezierCurveApproximator.freeDrawingPointList.end()) { end_view_point.x = nXOffset + (i->x * ratio); end_view_point.y = nYOffset + (i->y * ratio); LineTo(dcDst, end_view_point.x, end_view_point.y); i++; } SetROP2(dcDst, oldDrawMode); SelectObject(dcDst, oldPen); DeleteObject(newPen); /* for(std::list::iterator i = bezierCurveApproximator.freeDrawingPointList.begin(); i != bezierCurveApproximator.freeDrawingPointList.end(); ++i) { TPoint view_point; view_point.x = nXOffset + (i->x * ratio); view_point.y = nYOffset + (i->y * ratio); SetPixel(dcDst, view_point.x, view_point.y, !GetPixel(dcDst, view_point.x, view_point.y)); } */ } // --------------------------------------------------------------------------- void __fastcall TVecDraw::MotiveToCanvas(TVecMotive *stitchItem) { TList *DataList = NVector->DataList; TVecData *data = NULL; TVecData *cdata = NULL; PasteRange = Rect(50000, 50000, 0, 0); bool sw = true; // ========== ÀúÀåµÇ¾ú´ø copydataÁö¿ò for (int i = 0; i < CopyList->Count; i++) { cdata = (TVecData*)CopyList->Items[i]; if (cdata) { if (cdata->ParentTextBox) { delete cdata->ParentTextBox; cdata->ParentTextBox = NULL; } } delete cdata; } CopyList->Clear(); MaxThick = 0; // ========== ¿Ü°û µÑ·¹ ±¸ÇÏ´Â ºÎºÐ for (int i = 0; i < stitchItem->MotiveList->Count; i++) { data = (TVecData*)stitchItem->MotiveList->Items[i]; MaxThick = max(MaxThick, data->PenThick); PasteRange.left = min(PasteRange.left, min(data->First.x, data->Second.x) - data->PenThick * 2); PasteRange.right = max(PasteRange.right, max(data->First.x, data->Second.x) + data->PenThick * 2); PasteRange.top = min(PasteRange.top, min(data->First.y, data->Second.y) - data->PenThick * 2); PasteRange.bottom = max(PasteRange.bottom, max(data->First.y, data->Second.y) + data->PenThick * 2); } // ========== º¹»ç ÇÏ´Â ºÎºÐ for (int i = 0; i < stitchItem->MotiveList->Count; i++) { data = (TVecData*)stitchItem->MotiveList->Items[i]; if (data->Kind != V_LINE && data->Kind != V_CURVE) continue; // Text´Â ¹ÝÀüº¹»ç ¸øÇØ¿ä... // -->by linuxjun for CurvedVectorText if (data->ParentTextBox) continue; // <--by linuxjun for CurvedVectorText cdata = new TVecData(MainImageForm->Number); cdata->Copy(data); if (cdata->Kind == V_LINE || cdata->Kind == V_CURVE) { for (int j = 0; j < cdata->nCount * 3 + 1; j++) { cdata->pList[j].x -= PasteRange.left; cdata->pList[j].y -= PasteRange.top; } } int tempx = cdata->First.x; cdata->First.x -= PasteRange.left; cdata->Second.x -= PasteRange.left; cdata->First.y -= PasteRange.top; cdata->Second.y -= PasteRange.top; cdata->GroupIndex = 0; // GroupIndex´Â copy¾ÈµÇ°Ô.. if (cdata->bPatternFill) { MakePatternBitmap(cdata); } cdata->bSelected = true; CopyList->Add(cdata); } // ==========ºÙÀÌ´Â ºÎºÐ if (NVector->bMergeMode) DeleteVectorObject(false); deSelect(); NVector->bMergeMode = true; NVector->bSelected = true; for (int i = 0; i < CopyList->Count; i++) { cdata = (TVecData*)CopyList->Items[i]; data = new TVecData(MainImageForm->Number); data->Copy(cdata); data->bSelected = true; DataList->Add(data); UndoSave(VU_CREATE, DataList->Count - 1, sw); sw = false; } // ========== ÀúÀåµÇ¾ú´ø copydataÁö¿ò for (int i = 0; i < CopyList->Count; i++) { cdata = (TVecData*)CopyList->Items[i]; if (cdata) { if (cdata->ParentTextBox) { delete cdata->ParentTextBox; cdata->ParentTextBox = NULL; } } delete cdata; } CopyList->Clear(); } // --------------------------------------------------------------------------- bool __fastcall TVecDraw::IsFreeDrawingClosingState(int X, int Y) { int rg = 3; RECT rc; if (NVector->bExtend) { TVecData* extend_data = (TVecData*)NVector->DataList->Items[Index]; int check_index; if (NVector->bExtendFirst) check_index = extend_data->nCount * 3; else check_index = 0; rc = Rect(extend_data->pList[check_index].x - rg, extend_data->pList[check_index].y - rg, extend_data->pList[check_index].x + rg, extend_data->pList[check_index].y + rg); } else { std::list::iterator begin = bezierCurveApproximator.freeDrawingPointList.begin(); // for I.V by tmddn85 rc = Rect(begin->x - rg, begin->y - rg, begin->x + rg, begin->y + rg); } return PtInRect(&rc, Point(X, Y)); ; } // --------------------------------------------------------------------------- /** VectorÀÇ DataList¸¦ °Ë»çÇÏ¿© ¾î¶°ÇÑ ¿ÀºêÁ§Æ®°¡ 340ÀÌ ³Ñ´ÂÁö üũ - by monkman (2011.04.29) IN : form - üũÇÒ MainImageForm method - üũ ¹æ½Ä bSelected - ³Ñ´Â ¿ÀºêÁ§Æ®¸¦ ¼±Åà ǥ½ÃÇÒ °æ¿ì OUT : 340°³ ÀÌ»óÀÇ Æ÷ÀÎÆ®¸¦ °¡Áö°í ÀÖ´Â ¿ÀºêÁ§Æ®ÀÇ ¼ö * - method * 2 : ÇÑ Á¡ÀÌ¶óµµ Area¾È¿¡ Àִ°æ¿ì ÀúÀå * 3 : ÇÑ Á¡ÀÌ¶óµµ Area¹Û¿¡ ÀÖÀ¸¸é ÀúÀåÇÏÁö ¾ÊÀ½ * 4 : ¼±ÅÃµÈ Object¸¸ ÀúÀåµÊ * 5 : Motive Object ÀúÀåÀ¸·Î ÀÛ¾÷±¸¿ª°ú »ó°ü¾øÀÌ ÀúÀåÇÑ´Ù. */ int __fastcall TVecDraw::CheckObjectPoint1024(TMainImageForm *form, int method, bool bSelected) { TVecData *data = NULL; TList *DataList = NULL; bool bRange = false; TRect rtRange; int nReturn = 0; DataList = form->V_DATA; if (form->WorkArea->Mask && !(method & 8) && !(method & 16)) { // ÀÛ¾÷±¸¿ªÀÌ ÀÖ´Â °æ¿ì¿¡´Â ¿µ¿ªÀÇ »çÀÌÁî¿¡ ¸ÂÃß¾î shift~ bRange = true; rtRange = form->WorkArea->Range; } if (DataList) { for (int i = 0; i < DataList->Count; i++) { data = (TVecData *)DataList->Items[i]; if (!(method & 16) && (!data->Equal(form->Number))) continue; if ((method & 8) && !data->bSelected) continue; if (!InRectMethod(rtRange, data, method, bRange)) continue; if (340 < data->nCount) { if (bSelected) data->bSelected = true; nReturn++; } } if (0 < nReturn && bSelected) NVector->bSelected = true; } return nReturn; } // --------------------------------------------------------------------------- // idxListÀÇ Point Index¸¦ ±âÁØÀ¸·Î srcDataIdx¿¡ ÇØ´çÇÏ´Â Vector ºÐÇÒ void __fastcall TVecDraw::SegmentVecData(TList *dataList, int srcDataIdx, TList *idxList, int boundDataIdx) { BEGIN_LOG(""); // Sort idxList Items by Item's Value In Ascending Order for (int i = 0; i < idxList->Count; i++) { int *idxItm = static_cast(idxList->Items[i]); for (int j = 0; j < i; j++) { int *cmpIdxItm = static_cast(idxList->Items[j]); if (*idxItm < *cmpIdxItm) { int temp = *idxItm; *idxItm = *cmpIdxItm; *cmpIdxItm = temp; } } } // Set Bound Rect TVecData *boundData = static_cast(dataList->Items[boundDataIdx]); DRECT boundRect; boundRect.DRect(MaxInt, MaxInt, 0, 0); TVecData *firstVecData = NULL; for (int i = 0; i < boundData->nCount * 3 + 1; i++) { DPOINT pt = boundData->pList[i]; boundRect.left = min(boundRect.left, pt.x); boundRect.right = max(boundRect.right, pt.x); boundRect.top = min(boundRect.top, pt.y); boundRect.bottom = max(boundRect.bottom, pt.y); } // Segment Vector TVecData *srcData = static_cast(dataList->Items[srcDataIdx]); int stCurveIdx = 0; int endCurveIdx = 0; for (int i = 0; i < idxList->Count + 1; i++) { if (i < idxList->Count) endCurveIdx = *(static_cast(idxList->Items[i])); else endCurveIdx = srcData->nCount; if (stCurveIdx == endCurveIdx) continue; TVecData *segData = GetSegmentVecData(srcData, stCurveIdx, endCurveIdx, boundRect); if (segData != NULL && srcData->bClosed && i == 0) { firstVecData = segData; } else if (segData != NULL && firstVecData != NULL && srcData->bClosed && endCurveIdx == srcData->nCount) { int segVecCount = segData->nCount; segData->nCount = segData->nCount + firstVecData->nCount; int ptCnt = segData->nCount * 3 + 1; segData->pList = (DPOINT*)HeapReAlloc(GetProcessHeap(), 0, segData->pList, sizeof(DPOINT) * ptCnt); segData->pMask = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, segData->pMask, (segData->nCount * 3 + 1) % 8 == 0 ? (segData->nCount * 3 + 1) / 8 : (segData->nCount * 3 + 1) / 8 + 1); HeapCompact(GetProcessHeap(), 0); segData->pList[3 * segVecCount + 1] = firstVecData->pList[1]; segData->pList[3 * segVecCount + 2] = firstVecData->pList[2]; segData->pList[3 * segVecCount + 3] = firstVecData->pList[3]; for (int j = 1; j < firstVecData->nCount; j++) { segData->pList[3 * (segVecCount + j) + 1] = firstVecData->pList[3 * j + 1]; segData->pList[3 * (segVecCount + j) + 2] = firstVecData->pList[3 * j + 2]; segData->pList[3 * (segVecCount + j) + 3] = firstVecData->pList[3 * j + 3]; } SetRect(segData); if (segData->bPatternFill) MakePatternBitmap(segData); dataList->Add(segData); delete firstVecData; firstVecData = NULL; } else if (segData != NULL){ SetRect(segData); if (segData->bPatternFill) MakePatternBitmap(segData); dataList->Add(segData); } stCurveIdx = endCurveIdx; } delete srcData; dataList->Items[srcDataIdx] = NULL; END_LOG; } // --------------------------------------------------------------------------- // Get VecData Segmented between stCurveIdx and endCurveIdx TVecData* __fastcall TVecDraw::GetSegmentVecData(TVecData *srcData, int stCurveIdx, int endCurveIdx, DRECT boundRect) { TVecData *segData = new TVecData(srcData->GetInstNum()); segData->Copy(srcData); segData->bClosed = false; segData->nCount = endCurveIdx - stCurveIdx; int ptCnt = segData->nCount * 3 + 1; memcpy(segData->pList, &(srcData->pList[stCurveIdx * 3]), sizeof(DPOINT) * ptCnt); segData->pList = (DPOINT*)HeapReAlloc(GetProcessHeap(), 0, segData->pList, sizeof(DPOINT) * ptCnt); segData->pMask = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, segData->pMask, (segData->nCount * 3 + 1) % 8 == 0 ? (segData->nCount * 3 + 1) / 8 : (segData->nCount * 3 + 1) / 8 + 1); HeapCompact(GetProcessHeap(), 0); // Check segData Is In boundRect if (IsSegmentInRect(segData, boundRect) == false) { delete segData; segData = NULL; } return segData; } // --------------------------------------------------------------------------- // Check vecData Is In boundRect bool __fastcall TVecDraw::IsSegmentInRect(TVecData *vecData, DRECT boundRect) { DPOINT midPt; if (vecData->nCount > 1) { int midPtIdx = vecData->nCount / 2 * 3; midPt = vecData->pList[midPtIdx]; } else if (vecData->nCount == 1) { DPOINT bezierCtrlPt[4]; bezierCtrlPt[0] = vecData->pList[0]; bezierCtrlPt[1] = vecData->pList[1]; bezierCtrlPt[2] = vecData->pList[2]; bezierCtrlPt[3] = vecData->pList[3]; // Bezier CurveÀÇ Àüü ±æÀ̸¦ roughÇÏ°Ô ±¸ÇØÁØ´Ù double length = sqrt((bezierCtrlPt[1].x - bezierCtrlPt[0].x) * (bezierCtrlPt[1].x - bezierCtrlPt[0].x) + (bezierCtrlPt[1].y - bezierCtrlPt[0].y) * (bezierCtrlPt[1].y - bezierCtrlPt[0].y)) + sqrt ((bezierCtrlPt[2].x - bezierCtrlPt[1].x) * (bezierCtrlPt[2].x - bezierCtrlPt[1].x) + (bezierCtrlPt[2].y - bezierCtrlPt[1].y) * (bezierCtrlPt[2].y - bezierCtrlPt[1].y)) + sqrt ((bezierCtrlPt[3].x - bezierCtrlPt[2].x) * (bezierCtrlPt[3].x - bezierCtrlPt[2].x) + (bezierCtrlPt[3].y - bezierCtrlPt[2].y) * (bezierCtrlPt[3].y - bezierCtrlPt[2].y)); // ±× ±æÀÌÀÇ 4¹è ¸¸Å­À» division½ÃÄÑ Bezier PointµéÀ» ±¸Çϰڴ٠(ÀÌ °ªÀº user define value Å©¸é Ŭ¼ö·Ï // Á¤±³ÇÏ°Ô Bezier Point±¸ÇÒ ¼ö ÀÖÀ½) double division = length * 4; // °¢°¢ÀÇ Á¡µéÀ» °¡Á®¿À´Â ºÎºÐ DPOINT s[4]; s[3].x = bezierCtrlPt[3].x - 3 * bezierCtrlPt[2].x + 3 * bezierCtrlPt[1] .x - bezierCtrlPt[0].x; s[3].y = bezierCtrlPt[3].y - 3 * bezierCtrlPt[2].y + 3 * bezierCtrlPt[1] .y - bezierCtrlPt[0].y; s[2].x = 3 * bezierCtrlPt[2].x - 6 * bezierCtrlPt[1].x + 3 * bezierCtrlPt[0] .x; s[2].y = 3 * bezierCtrlPt[2].y - 6 * bezierCtrlPt[1].y + 3 * bezierCtrlPt[0] .y; s[1].x = 3 * bezierCtrlPt[1].x - 3 * bezierCtrlPt[0].x; s[1].y = 3 * bezierCtrlPt[1].y - 3 * bezierCtrlPt[0].y; s[0].x = bezierCtrlPt[0].x; s[0].y = bezierCtrlPt[0].y; midPt.x = s[3].x * 0.5 * 0.5 * 0.5 + s[2].x * 0.5 * 0.5 + s[1].x * 0.5 + s [0].x; midPt.y = s[3].y * 0.5 * 0.5 * 0.5 + s[2].y * 0.5 * 0.5 + s[1].y * 0.5 + s [0].y; } else { return false; } if (midPt.x > boundRect.left && midPt.x < boundRect.right && midPt.y > boundRect.top && midPt.y < boundRect.bottom) return true; else return false; } // --------------------------------------------------------------------------- void __fastcall GetPerpendicularPoint(DPOINT target, DPOINT pivot, double lenRatio, DPOINT &pt1, DPOINT &pt2) { pt1.x = lenRatio*target.y - lenRatio*pivot.y + pivot.x; // ry1-rn+m pt1.y = -lenRatio*target.x + lenRatio*pivot.x + pivot.y; // -rx1+rm+n pt2.x = -lenRatio*target.y + lenRatio*pivot.y + pivot.x; //-ry1+rn+m pt2.y = lenRatio*target.x - lenRatio*pivot.x + pivot.y; //rx1-rm+n } // --------------------------------------------------------------------------- DPOINT __fastcall TVecDraw::GetArrowPointOfContact(TVecData *data, double arrowHeight, bool bBack) { DPOINT rtpt; rtpt.x = -1; rtpt.y = -1; double t = 0; int i = 0; bool EnableBreak = false; DPOINT stpt, onpt; if (bBack == false){ stpt.x = data->pList[0].x; stpt.y = data->pList[0].y; for (i = 0; i < data->nCount; i++){ for (t = 0.01; t < 1; t += 0.01) { onpt = FindingPointOnBezier(&data->pList[i*3], t); if (sqrt((stpt.x - onpt.x)*(stpt.x - onpt.x)+(stpt.y - onpt.y)*(stpt.y - onpt.y)) > arrowHeight){ EnableBreak = true; break; } } if(EnableBreak) break; } if (t != 0){ if (t < 1 && i >= 0 && i < data->nCount){ double tt = 0; for (tt = t-0.01; tt < t; tt += 0.001){ onpt = FindingPointOnBezier(&data->pList[i*3], tt); if (sqrt((stpt.x - onpt.x)*(stpt.x - onpt.x)+(stpt.y - onpt.y)*(stpt.y - onpt.y)) >= arrowHeight){ break; } } rtpt.x = onpt.x; rtpt.y = onpt.y; } else { rtpt.x = -1;//copyData->pList[copyData->nCount*3].x; rtpt.y = -1;//copyData->pList[copyData->nCount*3].y; } } } else { stpt.x = data->pList[data->nCount*3].x; stpt.y = data->pList[data->nCount*3].y; for (i = data->nCount-1; i >= 0 ; i--){ for (t = 1-0.01; t >= 0; t -= 0.01) { onpt = FindingPointOnBezier(&data->pList[i*3], t); if (sqrt((stpt.x - onpt.x)*(stpt.x - onpt.x)+(stpt.y - onpt.y)*(stpt.y - onpt.y)) > arrowHeight){ EnableBreak = true; break; } } if(EnableBreak) break; } if (t != 0){ if (t < 1 && i >= 0 && i < data->nCount){ double tt = 0; for (tt = t+0.1; tt >= t; tt -= 0.001){ onpt = FindingPointOnBezier(&data->pList[i*3], tt); if (sqrt((stpt.x - onpt.x)*(stpt.x - onpt.x)+(stpt.y - onpt.y)*(stpt.y - onpt.y)) >= arrowHeight){ break; } } rtpt.x = onpt.x; rtpt.y = onpt.y; } else { rtpt.x = -1;//copyData->pList[copyData->nCount*3].x; rtpt.y = -1;//copyData->pList[copyData->nCount*3].y; } } } return rtpt; } // --------------------------------------------------------------------------- DPOINT __fastcall TVecDraw::GetArrowPointOfGradient(TVecData *data, bool bBack) { DPOINT rtpt; rtpt.x = -1; rtpt.y = -1; double t = 0; int i = 0; bool EnableBreak = false; DPOINT stpt, onpt; if (bBack == false){ stpt.x = data->pList[0].x; stpt.y = data->pList[0].y; for (i = 0; i < data->nCount; i++){ for (t = 0.01; t < 1; t += 0.01) { onpt = FindingPointOnBezier(&data->pList[i*3], t); if (sqrt((stpt.x - onpt.x)*(stpt.x - onpt.x)+(stpt.y - onpt.y)*(stpt.y - onpt.y)) > data->PenThick*data->ArrowCap->LineCapWidthScale){ EnableBreak = true; break; } } if(EnableBreak) break; } if (t != 0){ if (t < 1 && i >= 0 && i < data->nCount){ double tt = 0; for (tt = t-0.01; tt < t; tt += 0.001){ onpt = FindingPointOnBezier(&data->pList[i*3], tt); if (sqrt((stpt.x - onpt.x)*(stpt.x - onpt.x)+(stpt.y - onpt.y)*(stpt.y - onpt.y)) >= data->PenThick*data->ArrowCap->LineCapWidthScale){ break; } } rtpt.x = onpt.x; rtpt.y = onpt.y; } else { //rtpt.x = data->pList[data->nCount*3].x; //rtpt.y = data->pList[data->nCount*3].y; rtpt.x = data->pList[3].x; rtpt.y = data->pList[3].y; } } else { rtpt.x = data->pList[3].x; rtpt.y = data->pList[3].y; } } else { stpt.x = data->pList[data->nCount*3].x; stpt.y = data->pList[data->nCount*3].y; for (i = data->nCount-1; i >= 0 ; i--){ for (t = 1-0.01; t >= 0; t -= 0.01) { onpt = FindingPointOnBezier(&data->pList[i*3], t); if (sqrt((stpt.x - onpt.x)*(stpt.x - onpt.x)+(stpt.y - onpt.y)*(stpt.y - onpt.y)) > data->PenThick*data->ArrowCap->LineCapWidthScale){ EnableBreak = true; break; } } if(EnableBreak) break; } if (t != 0){ if (t < 1 && i >= 0 && i < data->nCount){ double tt = 0; for (tt = t+0.1; tt >= t; tt -= 0.001){ onpt = FindingPointOnBezier(&data->pList[i*3], tt); if (sqrt((stpt.x - onpt.x)*(stpt.x - onpt.x)+(stpt.y - onpt.y)*(stpt.y - onpt.y)) >= data->PenThick*data->ArrowCap->LineCapWidthScale){ break; } } rtpt.x = onpt.x; rtpt.y = onpt.y; } else { rtpt.x = data->pList[data->nCount*3 - 3].x; rtpt.y = data->pList[data->nCount*3 - 3].y; } } else { rtpt.x = data->pList[data->nCount*3 - 3].x; rtpt.y = data->pList[data->nCount*3 - 3].y; } } return rtpt; } // --------------------------------------------------------------------------- bool __fastcall TVecDraw::DrawArrow_Fill(HDC dcDst, double arrowHeight, double arrowWidth, TVecData *copyData , int PositionX, int PositionY, int px, int py, int ZoomIn, int ZoomOut) { DPOINT stpt, edpt, edpt_st, edpt_ed, onpt; DPOINT fpt, lpt; LOGBRUSH logbrush; logbrush.lbStyle = BS_SOLID; logbrush.lbColor = copyData->Color; logbrush.lbHatch = 0; HPEN hPen = NULL, hOldPen = NULL; if (copyData->bRound){ hPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_ROUND | PS_JOIN_ROUND, int(copyData->PenThick*ZoomIn/ZoomOut+0.5), &logbrush, 0, NULL); } else { hPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_FLAT | PS_JOIN_MITER, int(copyData->PenThick*ZoomIn/ZoomOut+0.5), &logbrush, 0, NULL); } hOldPen = (HPEN)SelectObject(dcDst, hPen); stpt.x = copyData->pList[0].x; stpt.y = copyData->pList[0].y; edpt.x = copyData->pList[copyData->nCount*3].x; edpt.y = copyData->pList[copyData->nCount*3].y; // È­»ìÇ¥ Çìµå¿Í ¼±ÀÌ ¸¸³ª´Â Á¡ ã±â - À½¼öÀΰæ¿ì´Â ¶óÀκ¸´Ù Çìµå°¡ Ä¿¼­ ¼±À» ¹þ¾î³ª´Â °æ¿ìÀÓ. edpt_st = GetArrowPointOfContact(copyData, arrowHeight); if (copyData->ArrowCap->bShowArrowBoth) edpt_ed = GetArrowPointOfContact(copyData, arrowHeight, true); bool bDrawLine = true; if (edpt_st.x != -1 && edpt_st.y != -1){ int pos = AddPointInVecData(copyData, edpt_st.x, edpt_st.y); if (pos >= 0){ if (copyData->bClosed) KnifeInVecData(copyData, 0); TVecData *newData = KnifeInVecData(copyData, pos * 3); if (copyData->ArrowCap->bShowArrowBoth){ // ¾ç³¡ È­»ìÇ¥¸¦ ±×¸®´Â °æ¿ì ¾çÂÊ Çìµå°¡ °ãÃÄÁö´Â °æ¿ì°¡ »ý±è. À̶§´Â ¼±À» ±×¸®Áö¾ÊÀ½. int pos_end = -1; if (newData){ pos_end = AddPointInVecData(newData, edpt_ed.x, edpt_ed.y); if (pos_end >= 0){ TVecData *newData_end = KnifeInVecData(newData, pos_end * 3); delete newData_end; } else bDrawLine = false; } else { // copyData°¡ ClosedÀ϶§´Â ÀÚ¸£±â¸¸ÇϹǷΠnewData°¡ null pos_end = AddPointInVecData(copyData, edpt_ed.x, edpt_ed.y); if (pos_end >= 0){ TVecData *newData_end = KnifeInVecData(copyData, pos_end * 3); delete newData_end; newData = new TVecData(MainImageForm->Number); newData->Copy(copyData); } else bDrawLine = false; } } else { if (newData == NULL){ newData = new TVecData(MainImageForm->Number); newData->Copy(copyData); } } if (bDrawLine){ POINT *pPoints = new POINT[newData->nCount*3+1]; for (int i = 0; i < newData->nCount*3 +1; i++) { pPoints[i].x = (newData->pList[i].x - PositionX) * ZoomIn / ZoomOut -px; pPoints[i].y = (newData->pList[i].y - PositionY) * ZoomIn / ZoomOut -py; } PolyBezier(dcDst, pPoints, newData->nCount*3+1); if (pPoints) delete[] pPoints; } DrawArrowHead(dcDst, stpt, edpt_st, copyData->bRound, copyData->Color, 1, arrowWidth, arrowHeight, PositionX, PositionY, px, py, ZoomIn, ZoomOut, true); if (copyData->ArrowCap->bShowArrowBoth){ DrawArrowHead(dcDst, edpt, edpt_ed, copyData->bRound, copyData->Color, 1, arrowWidth, arrowHeight, PositionX, PositionY, px, py, ZoomIn, ZoomOut, true); } if (newData) delete newData; } else { POINT *pPoints = new POINT[copyData->nCount*3+1]; for (int i = 0; i < copyData->nCount*3 +1; i++) { pPoints[i].x = (copyData->pList[i].x - PositionX) * ZoomIn / ZoomOut -px; pPoints[i].y = (copyData->pList[i].y - PositionY) * ZoomIn / ZoomOut -py; } PolyBezier(dcDst, pPoints, copyData->nCount*3+1); if (pPoints) delete[] pPoints; } } else { if (copyData->nCount >= 1){ double dtx = edpt.x - stpt.x; double dty = edpt.y - stpt.y; double len = sqrt(dtx*dtx + dty*dty); if (len <= 0) goto fail; edpt_st.x = stpt.x + (dtx*arrowHeight)/len; edpt_st.y = stpt.y + (dty*arrowHeight)/len; DrawArrowHead(dcDst, stpt, edpt_st, copyData->bRound, copyData->Color, 1, arrowWidth, arrowHeight, PositionX, PositionY, px, py, ZoomIn, ZoomOut, true); if (copyData->ArrowCap->bShowArrowBoth){ edpt_ed.x = edpt.x - (dtx*arrowHeight)/len; edpt_ed.y = edpt.y - (dty*arrowHeight)/len; DrawArrowHead(dcDst, edpt, edpt_ed, copyData->bRound, copyData->Color, 1, arrowWidth, arrowHeight, PositionX, PositionY, px, py, ZoomIn, ZoomOut, true); } } } if (hPen) SelectObject(dcDst, (HPEN)DeleteObject(hPen)); return true; fail: if (hPen) SelectObject(dcDst, (HPEN)DeleteObject(hPen)); return false; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::DrawArrowHead(HDC dcDst, DPOINT startPoint, DPOINT endPoint, bool bRound, TColor Color, double arrowLineWidth, double arrowWidth, double arrowHeight, int PositionX, int PositionY, int px, int py, int ZoomIn, int ZoomOut, bool bFill) { DPOINT fpt, lpt; LOGBRUSH logbrush; logbrush.lbStyle = BS_SOLID; logbrush.lbColor = Color; logbrush.lbHatch = 0; POINT *head = new POINT[5]; if (arrowHeight == 0) { return; } double lenRatio = double(arrowWidth/2)/arrowHeight; GetPerpendicularPoint(startPoint, endPoint, lenRatio, fpt, lpt); head[0].x = (fpt.x - PositionX)*ZoomIn/ZoomOut - px; head[0].y = (fpt.y - PositionY)*ZoomIn/ZoomOut - py; head[1].x = (startPoint.x - PositionX)*ZoomIn/ZoomOut - px; head[1].y = (startPoint.y - PositionY)*ZoomIn/ZoomOut - py; head[2].x = (lpt.x - PositionX)*ZoomIn/ZoomOut - px; head[2].y = (lpt.y - PositionY)*ZoomIn/ZoomOut - py; head[3].x = (endPoint.x - PositionX)*ZoomIn/ZoomOut - px; head[3].y = (endPoint.y - PositionY)*ZoomIn/ZoomOut - py; head[4].x = (fpt.x - PositionX)*ZoomIn/ZoomOut - px; head[4].y = (fpt.y - PositionY)*ZoomIn/ZoomOut - py; HPEN hPen, hOldPen; HBRUSH hBrush = CreateBrushIndirect(&logbrush); HBRUSH hOldBrush = (HBRUSH)SelectObject(dcDst, hBrush); if (bFill){ if (bRound){ hPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_ROUND | PS_JOIN_MITER, 1, &logbrush, 0, NULL); } else { hPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_FLAT | PS_JOIN_MITER, 1, &logbrush, 0, NULL); } hOldPen = (HPEN)SelectObject(dcDst, hPen); BeginPath(dcDst); MoveToEx(dcDst, head[0].x, head[0].y, NULL); PolylineTo(dcDst, head+1, 4); EndPath(dcDst); FillPath(dcDst); } else { if (bRound){ hPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_ROUND | PS_JOIN_MITER, arrowLineWidth, &logbrush, 0, NULL); } else { hPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_FLAT | PS_JOIN_MITER, arrowLineWidth, &logbrush, 0, NULL); } hOldPen = (HPEN)SelectObject(dcDst, hPen); Polyline(dcDst, head, 3); } if (hPen) SelectObject(dcDst, (HPEN)DeleteObject(hPen)); if (hBrush) SelectObject(dcDst, (HBRUSH)DeleteObject(hBrush)); delete[] head; } // --------------------------------------------------------------------------- bool __fastcall TVecDraw::DrawArrow_Line(HDC dcDst, double arrowHeight, double arrowWidth, TVecData *copyData , int PositionX, int PositionY, int px, int py, int ZoomIn, int ZoomOut) { DPOINT stpt, edpt, onpt, edpt_st, edpt_ed, temppt; DPOINT fpt, lpt; LOGBRUSH logbrush; logbrush.lbStyle = BS_SOLID; logbrush.lbColor = copyData->Color; logbrush.lbHatch = 0; HPEN hPen = NULL, hOldPen = NULL; if (copyData->bRound){ hPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_ROUND | PS_JOIN_ROUND, int(copyData->PenThick*ZoomIn/ZoomOut+0.5), &logbrush, 0, NULL); } else { hPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_FLAT | PS_JOIN_MITER, int(copyData->PenThick*ZoomIn/ZoomOut+0.5), &logbrush, 0, NULL); } hOldPen = (HPEN)SelectObject(dcDst, hPen); POINT *pPoints = new POINT[copyData->nCount*3+1]; for (int i = 0; i < copyData->nCount*3 +1; i++) { pPoints[i].x = (copyData->pList[i].x - PositionX) * ZoomIn / ZoomOut -px; pPoints[i].y = (copyData->pList[i].y - PositionY) * ZoomIn / ZoomOut -py; } PolyBezier(dcDst, pPoints, copyData->nCount*3+1); // draw arrow stpt.x = copyData->pList[0].x; stpt.y = copyData->pList[0].y; edpt.x = copyData->pList[copyData->nCount*3].x; edpt.y = copyData->pList[copyData->nCount*3].y; edpt_st.x = -1; edpt_st.y = -1; edpt_ed.x = -1; edpt_ed.y = -1; temppt = GetArrowPointOfGradient(copyData); if (temppt.x == -1 && temppt.y == -1){ temppt.x = copyData->pList[copyData->nCount*3].x; temppt.y = copyData->pList[copyData->nCount*3].y; } double len = sqrt(pow(temppt.x - stpt.x, 2)+pow(temppt.y - stpt.y, 2)); edpt_st.x = stpt.x + ((temppt.x-stpt.x)/len)*arrowHeight; edpt_st.y = stpt.y + ((temppt.y-stpt.y)/len)*arrowHeight; double arrowLineWidth = copyData->PenThick*copyData->ArrowCap->LineCapWidthScale*ZoomIn/ZoomOut; bool drawHead = true; if ((stpt.x < 0 && edpt_st.x < 0) || (stpt.y < 0 && edpt_st.y < 0)) drawHead = false; if (drawHead){ DrawArrowHead(dcDst, stpt, edpt_st, copyData->bRound, copyData->Color, arrowLineWidth, arrowWidth, arrowHeight, PositionX, PositionY, px, py, ZoomIn, ZoomOut, false); } if (copyData->ArrowCap->bShowArrowBoth){ temppt = GetArrowPointOfGradient(copyData, true); if (temppt.x == -1 && temppt.y == -1){ temppt.x = copyData->pList[0].x; temppt.y = copyData->pList[0].y; } edpt_ed.x = edpt.x + ((temppt.x-edpt.x)/len)*arrowHeight; edpt_ed.y = edpt.y + ((temppt.y-edpt.y)/len)*arrowHeight; drawHead = true; if ((edpt.x < 0 && edpt_ed.x < 0)|| (edpt.y < 0 && edpt_ed.y < 0) || (abs((int)(edpt.x - edpt_ed.x)) > MainImageForm->iMainImage->uBitmap->Width || abs((int)(edpt.y - edpt_ed.y)) > MainImageForm->iMainImage->uBitmap->Height)){ drawHead = false; } if (drawHead){ DrawArrowHead(dcDst, edpt, edpt_ed, copyData->bRound, copyData->Color, arrowLineWidth, arrowWidth, arrowHeight, PositionX, PositionY, px, py, ZoomIn, ZoomOut, false); } } if (pPoints) { delete[] pPoints; pPoints = NULL; } if (hPen) SelectObject(dcDst, (HPEN)DeleteObject(hPen)); return true; fail: if (pPoints) { delete[] pPoints; pPoints = NULL; } if (hPen) SelectObject(dcDst, (HPEN)DeleteObject(hPen)); return false; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::DrawArrow(HDC dcDst, TVecData *data, int PointCount, int ZoomIn, int ZoomOut, int PositionX, int PositionY, int px, int py, TMainImageForm *form) { DPOINT stpt, edpt, onpt; DPOINT fpt, lpt; TVecData *copyData = NULL, *copyDataRef = NULL; double arrowHeight = data->PenThick*data->ArrowCap->LineCapWidthScale*data->ArrowCap->LineCapHeight; double arrowWidth = data->PenThick*data->ArrowCap->LineCapWidthScale*data->ArrowCap->LineCapWidth; int nReflectionIndex = form->NVector->ReflectionVH == 1 ? form->NVector->ReflectionVIndex : form->NVector->ReflectionHIndex; copyData = new TVecData(MainImageForm->Number); if (copyData){ copyData->Copy(data); if (data->ArrowCap->bFillLineCap){ if (!DrawArrow_Fill(dcDst, arrowHeight, arrowWidth, copyData, PositionX, PositionY, px, py, ZoomIn, ZoomOut)) goto fail; if (form->NVector->bVectorReflectionMode){ copyDataRef = new TVecData(MainImageForm->Number); copyDataRef->Copy(data); if (form->NVector->ReflectionVH == 1) { for (int i = 0; i < data->nCount*3+1; i++){ copyDataRef->pList[i].x = nReflectionIndex*2 - data->pList[i].x; copyDataRef->pList[i].y = data->pList[i].y; } } else if (form->NVector->ReflectionVH == 2) { for (int i = 0; i < data->nCount*3+1; i++){ copyDataRef->pList[i].x = data->pList[i].x; copyDataRef->pList[i].y = nReflectionIndex*2 - data->pList[i].y; } } if (!DrawArrow_Fill(dcDst, arrowHeight, arrowWidth, copyDataRef, PositionX, PositionY, px, py, ZoomIn, ZoomOut)) goto fail; delete copyDataRef; } } else { if (!DrawArrow_Line(dcDst, arrowHeight, arrowWidth, copyData, PositionX, PositionY, px, py, ZoomIn, ZoomOut)) goto fail; if (form->NVector->bVectorReflectionMode){ copyDataRef = new TVecData(MainImageForm->Number); copyDataRef->Copy(data); if (form->NVector->ReflectionVH == 1) { for (int i = 0; i < data->nCount*3+1; i++){ copyDataRef->pList[i].x = nReflectionIndex*2 - data->pList[i].x; copyDataRef->pList[i].y = data->pList[i].y; } } else if (form->NVector->ReflectionVH == 2) { for (int i = 0; i < data->nCount*3+1; i++){ copyDataRef->pList[i].x = data->pList[i].x; copyDataRef->pList[i].y = nReflectionIndex*2 - data->pList[i].y; } } if (!DrawArrow_Line(dcDst, arrowHeight, arrowWidth, copyDataRef, PositionX, PositionY, px, py, ZoomIn, ZoomOut)) goto fail; delete copyDataRef; } } delete copyData; copyData = NULL; } return; fail: if (copyData){ delete copyData; copyData = NULL; } if (copyDataRef){ delete copyDataRef; copyDataRef = NULL; } return; } // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // Yuka DXF ÆÄÀÏÀ» ¿­°í ĵ¹ö½º¿¡ º¤Å͸¦ Ãß°¡ÇÏ´Â ÇÔ¼ö by david 20101222 // --------------------------------------------------------------------------- bool __fastcall TVecDraw::LoadFromDXFFile(String filename, TList *list) { DXFObject* fileObject = new DXFObject(); DXFParser* fileParser = new DXFParser(fileObject); wstree *DXFTree = 0; wstree *current = 0; int patternCnt = 0; // DXF°¡ °¡Áö°í ÀÖ´Â patternÀÇ °³¼ö Ç¥½Ã AnsiString strTemp; // ȣȯÀ» À§ÇØ À¯Áö!! C++ Builder 2010¿¡¼­ º¯°æÇÏ¸é ¾ÈµÊ!! - by monkman (2011.03.09) const int prevXsize = MainImageForm->iMainImage->Width; const int prevYsize = MainImageForm->iMainImage->Height; POINT pFst, pScd; TList *DataList = NULL; TVecData *data = NULL; // Ŭ·¡½º ¸â¹ö º¯¼ö¸¦ »ç¿ëÇÏÁö ¾Êµµ·Ï ÇÔ - by monkman (2009.04.01) double thick = 1; if (list) DataList = list; else DataList = NVector->DataList; strTemp = filename; if (fileObject->LoadDXFFile(strTemp.c_str())) { // ÆÄÀÏ À̸§À» ÀÎÀÚ·Î ¹Þ¾Æ µ¥ÀÌÅÍ ºÒ·¯¿À±â fileParser->ParseDXFText(); // DXF ÆÄÀÏ ³»¿ëÀ» parsing fileParser->AnalyzeDXFText(); DXFTree = fileObject->GetUnits(); current = DXFTree; // layer level for (int layerIdx = 0; layerIdx < current->CountChild(); layerIdx++) { current = current->GetChild(layerIdx); if (((DXFUnit*)current->Get())->unitType != DXFTYPE_LAYER) continue; // block level - block´ç ÇϳªÀÇ patternÀ» °¡Áö°í ÀÖÀ½ for (int blockIdx = 0; blockIdx < current->CountChild(); blockIdx++) { current = current->GetChild(blockIdx); if (((DXFUnit*)current->Get())->unitType != DXFTYPE_BLOCK) continue; patternCnt++; int coordX = ((DXFBlock*)current->Get())->blockX; int coordY = ((DXFBlock*)current->Get())->blockY; int realWidth = ((DXFBlock*)current->Get())->width + coordX * 2; int realHeight = ((DXFBlock*)current->Get())->height + coordY * 2; float zoomRatio; if ((float)realWidth / (float)prevXsize < (float)realHeight / (float) prevYsize) zoomRatio = (float)realHeight / (float)prevYsize; else zoomRatio = (float)realWidth / (float)prevXsize; // polyline level for (int polyIdx = 0; polyIdx < current->CountChild(); polyIdx++) { current = current->GetChild(polyIdx); if (((DXFUnit*)current->Get())->unitType != DXFTYPE_POLYLINE) continue; int crtX, crtY, oldX, oldY; // vertex level for (int vertexIdx = 0; vertexIdx < current->CountChild(); vertexIdx++) { current = current->GetChild(vertexIdx); if (((DXFUnit*)current->Get())->unitType != DXFTYPE_VERTEX) continue; // preview bitmap¿¡ ±×·ÁÁÖ±â if (vertexIdx == 0) { if ((data = new TVecData(MainImageForm->Number)) == NULL) goto fail; data->Kind = V_CURVE; data->PenThick = thick; data->Color = clBlack; oldX = ((DXFVertex*)current->Get())->pointX / zoomRatio; oldY = prevYsize - ((DXFVertex*)current->Get()) ->pointY / zoomRatio; 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 = TPoint(oldX, oldY); pScd = pFst; data->pList[0].DPoint(pFst); data->pList[1].DPoint(pFst); data->pList[2].DPoint(pScd); data->pList[3].DPoint(pScd); } else { crtX = ((DXFVertex*)current->Get())->pointX / zoomRatio; crtY = prevYsize - ((DXFVertex*)current->Get()) ->pointY / zoomRatio; 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); pScd = TPoint(crtX, crtY); data->pList[data->nCount * 3 - 2].DPoint(pFst); data->pList[data->nCount * 3 - 1].DPoint(pScd); data->pList[data->nCount * 3].DPoint(pScd); pFst = pScd; } // PolyLineÀ¸·Î ¿Ã¶ó°¡±â current = current->GetParent(); } // BlockÀ¸·Î ¿Ã¶ó°¡±â current = current->GetParent(); SET_RECT; DataList->Add(data); } // Layer·Î ¿Ã¶ó°¡±â current = current->GetParent(); } // root·Î ¿Ã¶ó°¡±â current = current->GetParent(); } fileObject->ClearDXFFile(); } delete fileParser; // delete fileObject; return true; fail: return false; } // --------------------------------------------------------------------------- // *.sty ÆÄÀÏÀÇ Çì´õ¸¦ ÃʱâÈ­ ÇÑ´Ù - by monkman (2004.03.31) void __fastcall TVecDraw::InitSTYHeader(STYLEDATAFILEHEADER *header) { header->Version = STYSTIFileVersion; header->Division = (EDivision)0; header->Type = (EType)0; header->Sort = (ESort)0; header->EMethod = (EDetailMethod)0; header->ESilhouette = (EDetailSilhouette)0; header->ESleeve = (EDetailSleeve)0; header->ECollar = (EDetailCollar)0; header->EPants = (EDetailPants)0; header->EBelt = (EDetailBelt)0; header->EUpperMaterial = (EDetailUpperMaterial)0; header->ELowerMaterial = (EDetailLowerMaterial)0; header->Count1 = 0; header->Count2 = 0; header->AvailableSleeve.Clear(); header->AvailableSleeve.Clear(); header->AvailableSleeve.Clear(); memset(header->TraitFrontNumber, 0, sizeof(int) * 80); memset(header->TraitBackNumber, 0, sizeof(int) * 80); header->bSleeve = false; header->bCollar = false; header->bBelt = false; header->Year = 0; header->SSFW = 0; memset(header->Comment, 0, sizeof(BYTE) * 100); // ÀÛ¾÷Áö½Ã¼­ ±â´É Ãß°¡·Î º¯°æ - by monkman (2010.12.24) // memset(header->Reserved, 0, sizeof(BYTE)*64); header->FileIndex = 0; memset(header->Crypt, 0, sizeof(BYTE) * 24); memset(header->StyleID, 0, sizeof(BYTE) * 20); memset(header->Reserved, 0, sizeof(BYTE) * 14); } // --------------------------------------------------------------------------- void __fastcall TVecDraw::CopySTYHeader(STYLEDATAFILEHEADER *pDstHeader, STYLEDATAFILEHEADER SrcHeader) { pDstHeader->Version = SrcHeader.Version; pDstHeader->Division = SrcHeader.Division; pDstHeader->Type = SrcHeader.Type; pDstHeader->Sort = SrcHeader.Sort; pDstHeader->EMethod = SrcHeader.EMethod; pDstHeader->ESilhouette = SrcHeader.ESilhouette; pDstHeader->ESleeve = SrcHeader.ESleeve; pDstHeader->ECollar = SrcHeader.ECollar; pDstHeader->EPants = SrcHeader.EPants; pDstHeader->EBelt = SrcHeader.EBelt; pDstHeader->EUpperMaterial = SrcHeader.EUpperMaterial; pDstHeader->ELowerMaterial = SrcHeader.ELowerMaterial; pDstHeader->Count1 = SrcHeader.Count1; pDstHeader->Count2 = SrcHeader.Count2; pDstHeader->AvailableSleeve = SrcHeader.AvailableSleeve; pDstHeader->AvailableNeckline = SrcHeader.AvailableNeckline; pDstHeader->AvailableCollar = SrcHeader.AvailableCollar; pDstHeader->bSleeve = SrcHeader.bSleeve; pDstHeader->bCollar = SrcHeader.bCollar; pDstHeader->bBelt = SrcHeader.bBelt; memcpy(pDstHeader->TraitFrontNumber, &SrcHeader.TraitFrontNumber, sizeof(int) * 80); memcpy(pDstHeader->TraitBackNumber, &SrcHeader.TraitBackNumber, sizeof(int) * 80); // ÀÛ¾÷Áö½Ã¼­ ±â´É Ãß°¡·Î º¯°æ - by monkman (2010.12.24) // memcpy(pDstHeader->Reserved, SrcHeader.Reserved, sizeof(BYTE)*64); // pDstHeader->FileIndex = SrcHeader.FileIndex; memcpy(pDstHeader->Comment, SrcHeader.Comment, sizeof(BYTE) * 100); memcpy(pDstHeader->Crypt, SrcHeader.Crypt, sizeof(BYTE) * 24); memcpy(pDstHeader->StyleID, SrcHeader.StyleID, sizeof(BYTE) * 20); memcpy(pDstHeader->Reserved, SrcHeader.Reserved, sizeof(BYTE) * 14); } // --------------------------------------------------------------------------- // *.sty ÆÄÀÏÀÇ Çì´õ¸¦ »õ·Î¿î ¹öÀüÀÇ Çì´õ·Î º¯È¯ÇÑ´Ù - by monkman (2004.03.30) void __fastcall TVecDraw::ConvertNewSTYHeader(STYLEDATAFILEHEADER *pNewHeader, OLDSTYLEDATAFILEHEADER *pOldHeader) { pNewHeader->Version = pOldHeader->Version; pNewHeader->Division = pOldHeader->Division; pNewHeader->Type = pOldHeader->Type; switch(int(pOldHeader->Sort)) { case 1: if (int(pOldHeader->ESilhouette) > 0) pNewHeader->Sort = SO_TOPFULL; else if (int(pOldHeader->EPants) > 0) pNewHeader->Sort = SO_BOTTOMFULL; else pNewHeader->Sort = SO_TOPFULL; break; case 2: if (int(pOldHeader->ESilhouette) > 0) pNewHeader->Sort = SO_SILHOUETTE; else if (int(pOldHeader->EPants) > 0) pNewHeader->Sort = SO_PANTS; else pNewHeader->Sort = SO_SILHOUETTE; break; case 3: pNewHeader->Sort = SO_COLLAR; break; case 4: pNewHeader->Sort = SO_SLEEVE; break; case 5: pNewHeader->Sort = SO_BELT; break; } pNewHeader->EMethod = pOldHeader->ESilhouette; pNewHeader->ESilhouette = (EDetailSilhouette)0; pNewHeader->ESleeve = pOldHeader->ESleeve; pNewHeader->ECollar = pOldHeader->ECollar; pNewHeader->EPants = pOldHeader->EPants; pNewHeader->EBelt = pOldHeader->EBelt; pNewHeader->EUpperMaterial = (EDetailUpperMaterial)0; pNewHeader->ELowerMaterial = (EDetailLowerMaterial)0; pNewHeader->Count1 = pOldHeader->Count1; pNewHeader->Count2 = pOldHeader->Count2; pNewHeader->AvailableSleeve = pOldHeader->AvailableSleeve; pNewHeader->AvailableNeckline = pOldHeader->AvailableNeckline; pNewHeader->AvailableCollar = pOldHeader->AvailableCollar; pNewHeader->bSleeve = pOldHeader->bSleeve; pNewHeader->bCollar = pOldHeader->bCollar; pNewHeader->bBelt = pOldHeader->bBelt; pNewHeader->Year = 0; pNewHeader->SSFW = 0; memcpy(pNewHeader->TraitFrontNumber, pOldHeader->TraitFrontNumber, sizeof(int) * 80); memcpy(pNewHeader->TraitBackNumber, pOldHeader->TraitBackNumber, sizeof(int) * 80); memset(pNewHeader->Comment, 0, sizeof(BYTE) * 100); // ÀÛ¾÷Áö½Ã¼­ ±â´É Ãß°¡·Î º¯°æ - by monkman (2010.12.24) // memcpy(pNewHeader->Reserved, pOldHeader->Reserved, sizeof(BYTE)*64); pNewHeader->FileIndex = 0; // StyleID¿Í Reserved´Â OLDSTYLEDATAFILEHEADER ¿¡¼­´Â »ç¿ëÇÏÁö ¾Ê¾Ò´ø °ªÀ̹ǷΠº¹»çÇÏÁö ¾Ê°í, ÃʱâÈ­ÇØµµ »ó°ü¾ø´Ù - by monkman (2010.12.24) memset(pNewHeader->Crypt, 0, sizeof(BYTE) * 24); memset(pNewHeader->StyleID, 0, sizeof(BYTE) * 20); memset(pNewHeader->Reserved, 0, sizeof(BYTE) * 14); /* if (BeforeVersion >= 200 && AfterVersion == 100) { bH->Version = aH->Version; bH->Division = aH->Division; bH->Type = aH->Type; switch (int(bH->Sort)) { case 1 : bH->Sort = SO_TOPFULL; break; case 2 : bH->Sort = SO_SILHOUETTE; break; case 3 : bH->Sort = SO_SLEEVE; break; case 4 : bH->Sort = SO_COLLAR; break; case 5 : bH->Sort = SO_BOTTOMFULL; break; case 6 : bH->Sort = SO_PANTS; break; case 7 : bH->Sort = SO_BELT; break; } bH->ESilhouette = aH->EMethod; bH->ESleeve = aH->ESleeve; bH->ECollar = aH->ECollar; bH->EPants = aH->EPants; bH->EBelt = aH->EBelt; bH->Count1 = aH->Count1; bH->Count2 = aH->Count2; bH->AvailableSleeve = aH->AvailableSleeve; bH->AvailableNeckline = aH->AvailableNeckline; bH->AvailableCollar = aH->AvailableCollar; bH->bSleeve = aH->bSleeve; bH->bCollar = aH->bCollar; bH->bBelt = aH->bBelt; memcpy(bH->TraitFrontNumber, aH->TraitFrontNumber, sizeof(int)*80); memcpy(bH->TraitBackNumber, aH->TraitBackNumber, sizeof(int)*80); // ÀÛ¾÷Áö½Ã¼­ ±â´É Ãß°¡·Î º¯°æ - by monkman (2010.12.24) //memcpy(bH->Reserved, aH->Reserved, sizeof(BYTE)*64); // StyleID¿Í Reserved´Â OLDSTYLEDATAFILEHEADER ¿¡¼­´Â »ç¿ëÇÏÁö ¾Ê¾Ò´ø °ªÀ̹ǷΠº¹»çÇÏÁö ¾Ê°í, ÃʱâÈ­ÇØµµ »ó°ü¾ø´Ù - by monkman (2010.12.24) memset(bH->Reserved, 0, sizeof(BYTE)*64); } */ } // --------------------------------------------------------------------------- // *.sty ÆÄÀÏÀ» ¹öÀü º°·Î ÀÐ°í º¯È¯ÇÑ´Ù - by monkman (2004.03.30) STYLEDATAFILEHEADER __fastcall TVecDraw::ReadSTYFileHeader(HANDLE hFile, String filename, int *Version, bool PositionReset) { OLDSTYLEDATAFILEHEADER oldheader; STYLEDATAFILEHEADER header; DWORD dwRead; BYTE pCrypt[24] = { 0, }; // Çì´õ ÃʱâÈ­ InitSTYHeader(&header); if (PositionReset) { if (!ReadFile(hFile, Version, sizeof(int), &dwRead, NULL)) goto fail; if (SetFilePointer(hFile, 0, NULL, FILE_BEGIN) == 0xFFFFFFFF) goto fail; } else { if (!ReadFile(hFile, Version, sizeof(int), &dwRead, NULL)) goto fail; if (SetFilePointer(hFile, -4, NULL, FILE_CURRENT) == 0xFFFFFFFF) goto fail; } if (*Version == 0) { // Version == 0 (VersionÀÌ 100À϶§ °¡²û ¹öÀüÀÌ 0À¸·Î ÀúÀåµÇ´Â°æ¿ìµµ ÀÖ´Ù..) - by monkman if (!ReadFile(hFile, &oldheader, sizeof(OLDSTYLEDATAFILEHEADER), &dwRead, NULL)) goto fail; ConvertNewSTYHeader(&header, &oldheader); } else if (*Version == 100) { // Version == 100 if (!ReadFile(hFile, &oldheader, sizeof(OLDSTYLEDATAFILEHEADER), &dwRead, NULL)) goto fail; ConvertNewSTYHeader(&header, &oldheader); } else if (200 <= *Version && *Version < 500) { // Version == 200 if (!ReadFile(hFile, &header, sizeof(STYLEDATAFILEHEADER), &dwRead, NULL)) goto fail; #ifdef WORKSHEET // ¾²·¹±â °ª Á¦°Å - by monkman (2011.01.04) if (memcmp(header.Crypt, pCrypt, sizeof(BYTE) * 24)) { memset(header.Crypt, 0, sizeof(BYTE) * 24); memset(header.StyleID, 0, sizeof(BYTE) * 20); memset(header.Reserved, 0, sizeof(BYTE) * 14); } #endif header.FileIndex = 0; // ÃʱâÈ­ÇØÁØ´Ù - by monkman (2011.01.04) } else if (500 <= *Version && *Version <= (STYSTIFileVersion + 300)) { #ifndef NOT_STYLEDATA_LOCK // Version == 500 (¿µ¿ì ÆÇ¸Å¿ë µ¥ÀÌÅÍ) if (!ReadFile(hFile, &header, sizeof(STYLEDATAFILEHEADER), &dwRead, NULL)) goto fail; header.FileIndex = 0; // ÃʱâÈ­ÇØÁØ´Ù - by monkman (2011.01.04) #endif } else { InitSTYHeader(&header); } return header; fail: return header; } // --------------------------------------------------------------------------- bool __fastcall TVecDraw::ReadSTYFileData(HANDLE hFile, int Version, BYTE *StyleData, STYLEDATAFILEHEADER header) { // Style Data¸¦ ÆÄÀÏ¿¡¼­ Á÷Á¢ ÀÐÁö ¾Ê°í ¸Þ¸ð¸®·Î ·ÎµåÇÏ¿© Àеµ·Ï ¼öÁ¤ - by monkman (2004.12.28) // Style Data Lock¿¡¼­ Data¸¦ ¹ÝÀüÇÑ °ÍÀ» ¿©±â¼­ ¹Ù·Î µ¹¸°´Ù DWORD dwRead; short nDataCount; DWORD dwDataSize; nDataCount = header.Count1 + header.Count2; if (Version == 0 || Version == 100) { // Version 100 ÀÏ °æ¿ì ¸ø Àд ¿¡·¯·Î ±ä±ÞÃß°¡ - by monkman (2005.06.10) dwDataSize = GetFileSize(hFile, NULL)-sizeof(OLDSTYLEDATAFILEHEADER); } else { dwDataSize = GetFileSize(hFile, NULL)-sizeof(STYLEDATAFILEHEADER); } if (100 <= header.Version && header.Version < 500) { // Data LockÀÌ ¾È °É·Á ÀÖ´Â ¹öÀü if (!ReadFile(hFile, StyleData, dwDataSize, &dwRead, NULL)) goto fail; // ÆÄÀÏÀ» ÀÐÀ½ } else if (500 <= header.Version) { // Data LockÀÌ °É·Á ÀÖ´Â ¹öÀü if (!ReadFile(hFile, StyleData, dwDataSize, &dwRead, NULL)) goto fail; // ÆÄÀÏÀ» ÀÐÀ½ for (unsigned int i = 0; i < dwDataSize - 1; i++) { if (i % nDataCount == 0) { StyleData[i] = ~StyleData[i]; } } } return true; fail: return false; } // --------------------------------------------------------------------------- bool __fastcall TVecDraw::CheckSTYLock(HANDLE hFile, STYLEDATAFILEHEADER header) { // STY Lock °ü·Ã üũ - by monkman (2004.11.02) DWORD dwRead; double dVersion; short nVolume; BYTE cReadSerialNumber[4][9]; BYTE cReadSeedCode[9]; AnsiString strSerialNumber[4], strSeedCode, strTemp; unsigned int nSerialNumber[4]; unsigned int nSeedCode, nKey; Crypt = new TCrypt; memset(cReadSerialNumber, 0, sizeof(cReadSerialNumber)); memset(cReadSeedCode, 0, sizeof(cReadSeedCode)); memset(nSerialNumber, 0, sizeof(nSerialNumber)); // Header¿¡¼­ ÇÊ¿äÇÑ Á¤º¸µéÀ» º¹»ç // Version : 1.8 (double - 8Byte - ºñ¾Ïȣȭ) // Volume : 1 (short - 2Byte - ºñ¾Ïȣȭ) // SeedCode : 1 (Byte * 9 - 9Byte - '\0'°¡ Ãß°¡µÇ¾úÀ½ - ¾Ïȣȭ(Version°ú Volume·Î..) // Key : 1 (unsigned int - 4Byte - ºñ¾Ïȣȭ) // Header ÀÌÈÄ¿¡ ÇÊ¿äÇÑ Á¤º¸ // SerialNumber : 11538-27371-1260-34147 (Byte * 4 * 9 - 36Byte - ¾Ïȣȭ(Key·Î¸¸..)) memcpy(&dVersion, header.Crypt, sizeof(dVersion)); memcpy(&nVolume, header.Crypt +sizeof(dVersion), sizeof(nVolume)); memcpy(cReadSeedCode, header.Crypt +sizeof(dVersion)+sizeof(nVolume), sizeof(cReadSeedCode)); memcpy(&nKey, header.Crypt +sizeof(dVersion)+sizeof(nVolume)+sizeof (cReadSeedCode), sizeof(nKey)); if (!ReadFile(hFile, cReadSerialNumber, sizeof(cReadSerialNumber), &dwRead, NULL)) goto fail; for (int i = 0; i < 4; i++) { strSerialNumber[i] = strTemp.sprintf(cReadSerialNumber[i]); strSerialNumber[i] = Crypt->DeCode(strSerialNumber[i], 0.0, nKey); nSerialNumber[i] = StrToInt(strSerialNumber[i]); } strSeedCode = strTemp.sprintf(cReadSeedCode); strSeedCode = Crypt->DeCode(strSeedCode, dVersion, nVolume); nSeedCode = StrToInt(strSeedCode); if (Crypt) { delete Crypt; Crypt = NULL; } #ifndef LOCK_CRYPKEY #ifndef LOCK_IFC if (HASP_SerialNumber[0] == (unsigned int) nSerialNumber[0] && HASP_SerialNumber[1] == (unsigned int) nSerialNumber[1] && HASP_SerialNumber[2] == (unsigned int) nSerialNumber[2] && HASP_SerialNumber[3] == (unsigned int) nSerialNumber[3] && HASP_SeedCode == (unsigned int)nSeedCode) return true; else return false; #endif #endif fail: if (Crypt) { delete Crypt; Crypt = NULL; } // ¸Þ½ÃÁö : ÇØ´ç ÆÄÀÏ¿¡ ¹®Á¦°¡ À־ ÆÄÀÏÀ» Àоî¿Ã ¼ö ¾ø½À´Ï´Ù. // MessageDlg(IDS_MESSAGE17, mtError, TMsgDlgButtons() << mbOK, 0); return false; } // --------------------------------------------------------------------------- STYLEDATAFILEHEADER __fastcall TVecDraw::FakeSTYVersionAndHASPSeedCodeAndHASPKey (STYLEDATAFILEHEADER header) { // ÆÄÀÏÀÇ Á¤º¸¸¦ °¨Ãß±â À§ÇØ °¡Â¥ SeedCode¿Í SerialNumber¸¦ »ý¼ºÇؼ­ Áý¾î³Ö´Â´Ù - by monkman (2004.12.02) double dVersion; BYTE cSeedCode[9], cRandom; AnsiString strSeedCode; unsigned int nSeedCode, nKey; short nVolume, nCount; if (header.Version <= 500) { // Header¿¡¼­ ÇÊ¿äÇÑ Á¤º¸µéÀ» º¹»ç // Version : 1.8 (double - 8Byte - ºñ¾Ïȣȭ) // Volume : 1 (short - 2Byte - ºñ¾Ïȣȭ) // SeedCode : 1 (Byte * 9 - 9Byte - '\0'°¡ Ãß°¡µÇ¾úÀ½ - ¾Ïȣȭ(Version°ú Volume·Î..) // Key : 1 (unsigned int - 4Byte - ºñ¾Ïȣȭ) // Header ÀÌÈÄ¿¡ ÇÊ¿äÇÑ Á¤º¸ // SerialNumber : 11538-27371-1260-34147 (Byte * 4 * 9 - 36Byte - ¾Ïȣȭ(Key·Î¸¸..)) dVersion = ((double)random(100) / (random(10) + 1)); // 0À¸·Î ³ª´©¸é ¾È µÇ´Ï±ñ.. nVolume = random(10); nSeedCode = random(65535); #ifndef LOCK_CRYPKEY #ifndef LOCK_IFC Crypt = new TCrypt; AnsiString tempSeed = IntToStr((int)HASP_SeedCode); strSeedCode = Crypt->EnCode(tempSeed, dVersion, nVolume).c_str(); if (Crypt) { delete Crypt; Crypt = NULL; } strncpy(cSeedCode, strSeedCode.c_str(), 9); // _tcsncpy(cSeedCode, strSeedCode.c_str(), 9); #endif #endif nKey = random(65535); // Header¿¡¼­ ÇÊ¿äÇÑ Á¤º¸µéÀ» º¹»ç // Version : 1.8 // SeedCode : 1 // Key : 1 memcpy(header.Crypt, &dVersion, sizeof(dVersion)); memcpy(header.Crypt +sizeof(dVersion), cSeedCode, sizeof(cSeedCode)); memcpy(header.Crypt +sizeof(dVersion)+sizeof(nVolume), &nVolume, sizeof(nVolume)); memcpy(header.Crypt +sizeof(dVersion)+sizeof(nVolume)+sizeof(nSeedCode), &nKey, sizeof(nKey)); nCount = sizeof(dVersion)+sizeof(nVolume)+sizeof(nSeedCode); for (int i = 0; i < 24 - nCount; i++) { cRandom = (BYTE)random(255); memcpy(header.Crypt + nCount + i, &cRandom, sizeof(cRandom)); } } return header; } // --------------------------------------------------------------------------- // *.sty ÆÄÀÏ ¹öÀüÀ» üũÇÑ´Ù - by monkman (2004.03.30) int __fastcall TVecDraw::CheckSTYFileVersion(HANDLE hFile, String filename) { DWORD dwRead; int Version; if (SetFilePointer(hFile, 0, NULL, FILE_BEGIN) == 0xFFFFFFFF) goto fail; if (!ReadFile(hFile, &Version, sizeof(int), &dwRead, NULL)) goto fail; if (Version == 100) { return Version; } else if (200 <= Version && Version < 500) { return Version; } else if (500 <= Version && Version <= (STYSTIFileVersion + 300)) { #ifndef NOT_STYLEDATA_LOCK // Version == 500 (¿µ¿ì ÆÇ¸Å¿ë µ¥ÀÌÅÍ) return Version; #endif } else { return 0; } fail: return 0; } // --------------------------------------------------------------------------- // *.sti ÆÄÀÏÀÇ Çì´õ¸¦ ÃʱâÈ­ ÇÑ´Ù - by monkman (2004.04.02) void __fastcall TVecDraw::InitSTIHeader(ILLUSTDATAFILEHEADER *IllustHeader) { strcpy(IllustHeader->FileType, "StylistIllustFile\0"); IllustHeader->Version = STYSTIFileVersion; IllustHeader->UpDown = 0; IllustHeader->Division = (EDivision)0; IllustHeader->Type1 = (EType)0; IllustHeader->Type2 = (EType)0; IllustHeader->EMethod = (EDetailMethod)0; IllustHeader->ESilhouette = (EDetailSilhouette)0; IllustHeader->ESleeve = (EDetailSleeve)0; IllustHeader->ECollar = (EDetailCollar)0; IllustHeader->EPants = (EDetailPants)0; IllustHeader->Year = 0; IllustHeader->SSFW = 0; memset(IllustHeader->Comment, 0, sizeof(BYTE) * 100); memset(IllustHeader->Reserved, 0, sizeof(BYTE) * 64); } // --------------------------------------------------------------------------- // *.sty ÆÄÀÏÀÇ Çì´õ¸¦ ¿øÇÏ´Â ¹öÀüÀ¸·Î º¯È¯ÇÑ´Ù - by monkman (2004.03.30) void __fastcall TVecDraw::ConvertNewSTIHeader(ILLUSTDATAFILEHEADER *pNewHeader, OLDILLUSTDATAFILEHEADER *pOldHeader) { memcpy(pNewHeader->FileType, &pOldHeader->FileType, sizeof(char) * 18); pNewHeader->Version = pOldHeader->Version; pNewHeader->UpDown = pOldHeader->UpDown; pNewHeader->Division = pOldHeader->Division; pNewHeader->Type1 = pOldHeader->Type1; pNewHeader->Type2 = pOldHeader->Type2; pNewHeader->EMethod = pOldHeader->ESilhouette; pNewHeader->ESilhouette = (EDetailSilhouette)0; pNewHeader->ESleeve = pOldHeader->ESleeve; pNewHeader->ECollar = pOldHeader->ECollar; pNewHeader->EPants = pOldHeader->EPants; pNewHeader->EBelt = pOldHeader->EBelt; pNewHeader->Year = 0; pNewHeader->SSFW = 0; memset(pNewHeader->Comment, 0, sizeof(BYTE) * 100); memset(pNewHeader->Reserved, 0, sizeof(BYTE) * 64); /* if (BeforeVersion >= 200 && AfterVersion == 100) { memcpy(bH->FileType, &aH->FileType, sizeof(char)*18); bH->Version = aH->Version; bH->UpDown = aH->UpDown; bH->Division = aH->Division; bH->Type1 = aH->Type1; bH->Type2 = aH->Type2; bH->ESilhouette = aH->EMethod; bH->ESleeve = aH->ESleeve; bH->ECollar = aH->ECollar; bH->EPants = aH->EPants; bH->EBelt = aH->EBelt; } */ } // --------------------------------------------------------------------------- // *.sti ÆÄÀÏÀ» ¹öÀü º°·Î ÀÐ°í º¯È¯ÇÑ´Ù - by monkman (2004.04.01) ILLUSTDATAFILEHEADER __fastcall TVecDraw::ReadSTIFileHeader(HANDLE hFile, String filename, int *Version) { OLDILLUSTDATAFILEHEADER oldheader; ILLUSTDATAFILEHEADER header; DWORD dwRead; // Çì´õ ÃʱâÈ­ InitSTIHeader(&header); if (SetFilePointer(hFile, 20, NULL, FILE_BEGIN) == 0xFFFFFFFF) goto fail; if (!ReadFile(hFile, Version, sizeof(int), &dwRead, NULL)) goto fail; if (SetFilePointer(hFile, 0, NULL, FILE_BEGIN) == 0xFFFFFFFF) goto fail; // ¹öÀü üũ if (*Version == 100) { if (!ReadFile(hFile, &oldheader, sizeof(OLDILLUSTDATAFILEHEADER), &dwRead, NULL)) goto fail; ConvertNewSTIHeader(&header, &oldheader); } else if (200 <= *Version && *Version < 500) { if (!ReadFile(hFile, &header, sizeof(ILLUSTDATAFILEHEADER), &dwRead, NULL)) goto fail; } else if (500 <= *Version) { #ifndef NOT_STYLEDATA_LOCK // Version == 500 (¿µ¿ì ÆÇ¸Å¿ë µ¥ÀÌÅÍ) if (!ReadFile(hFile, &header, sizeof(ILLUSTDATAFILEHEADER), &dwRead, NULL)) goto fail; #endif } else { // Çì´õ ÃʱâÈ­ InitSTIHeader(&header); } return header; fail: return header; } // --------------------------------------------------------------------------- void __fastcall TVecDraw::ClearDataList(TList *DataList) { TVecData *data = NULL; if (DataList) { for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (data) delete data; data = NULL; } DataList->Clear(); } } // --------------------------------------------------------------------------- void __fastcall TVecDraw::SetInstNumDataList(TList *DataList, int InstNum, int SetInstNum) { TVecData *data = NULL; if (DataList) { for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (data->Equal(InstNum)) data->Set(SetInstNum); } } } // --------------------------------------------------------------------------- bool __fastcall TVecDraw::CopyDataList(TList *DstList, TList *SrcList, int InstNum, int SetInstNum) { TVecData *dataSrc = NULL, *dataDst = NULL; if (SetInstNum == -1) SetInstNum = 0; if (SrcList == NULL || DstList == NULL) goto fail; ClearDataList(DstList); for (int i = 0; i < SrcList->Count; i++) { dataSrc = (TVecData*)SrcList->Items[i]; if (dataSrc) { if (InstNum < 0 || (0 <= InstNum && dataSrc->GetInstNum() == InstNum)) { if ((dataDst = new TVecData(SetInstNum)) == NULL) goto fail; // InstNum = 0 dataDst->Copy(dataSrc); DstList->Add(dataDst); } } } return true; fail: ClearDataList(DstList); return false; } // --------------------------------------------------------------------------- bool __fastcall TVecDraw::MoveDataList(TList *DstList, TList *SrcList, int InstNum, int SetInstNum) { TVecData *data = NULL; if (SrcList == NULL || DstList == NULL) goto fail; for (int i = 0; i < SrcList->Count; i++) { data = (TVecData*)SrcList->Items[i]; if (data) { if (InstNum < 0 || (0 <= InstNum && data->Equal(InstNum))) { if (0 <= SetInstNum) data->Set(SetInstNum); DstList->Add(data); SrcList->Delete(i); i--; } } } return true; fail: ClearDataList(DstList); return false; } // --------------------------------------------------------------------------- bool __fastcall TVecDraw::AssignDataList(TList *DstList, TList *SrcList, int InstNumFrom, int InstNumTo) { TVecData *data = NULL; int InstNum; if (SrcList == NULL || DstList == NULL) goto fail; for (int i = 0; i < SrcList->Count; i++) { data = (TVecData*)SrcList->Items[i]; if (data) { InstNum = data->GetInstNum(); if (InstNumFrom <= InstNum && InstNum <= InstNumTo) { DstList->Add(data); } } } return true; fail: ClearDataList(DstList); return false; } // --------------------------------------------------------------------------- bool __fastcall TVecDraw::DeleteDataList(TList *DataList, int InstNum) { TVecData *data = NULL; if (DataList == NULL) goto fail; for (int i = 0; i < DataList->Count; i++) { data = (TVecData*)DataList->Items[i]; if (data) { if (InstNum < 0 || (0 <= InstNum && data->Equal(InstNum))) { DataList->Delete(i); if (data) delete data; data = NULL; i--; } } } return true; fail: return false; } // --------------------------------------------------------------------------- ///////////////// ÀÛ¾÷Áö½Ã¼­ ///////////////////////// - by monkman (2011.01.12) // Combination Á¤º¸¸¦ Load/Save - by monkman (2011.01.10) #ifdef WORKSHEET bool __fastcall TVecDraw::LoadFromCombiItem(String strFileName) { bool bReturn = true; HANDLE hFile = NULL; DWORD dwRead; int nCellCount = 0; int nVersion = -1; // ÃʱâÈ­ SilhouetteName[0] = "None"; SleeveName[0] = "None"; CollarName[0] = "None"; UpperMaterialName[0] = "None"; PantsName[0] = "None"; BeltName[0] = "None"; LowerMaterialName[0] = "None"; for (int i = 1; i < 127; i++) { SilhouetteName[i] = ""; SleeveName[i] = ""; CollarName[i] = ""; UpperMaterialName[i] = ""; PantsName[i] = ""; BeltName[i] = ""; LowerMaterialName[i] = ""; } if ((hFile = CreateFile(strFileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE) { // ¹öÀüÀº ¾Æ½±°Ôµµ 3.2 ¹öÀüÀÌ ³ª°£µÚ 2010¿¡¼­ Ãß°¡µÇ¾ú´Ù. - by monkman (2011.03.10) if (!ReadFile(hFile, &nVersion, sizeof(int), &dwRead, NULL)) goto fail; if (nVersion != 101) { SetFilePointer(hFile, 0, NULL, FILE_BEGIN); // 101ÀÌ ¾Æ´Ò °æ¿ì ¹öÀüÀ» µÇµ¹¸®°í, 100À̶ó°í ¼³Á¤ÇÑ´Ù. nVersion = 100; } // Silhouette if (!ReadFile(hFile, &SilhouetteCount, sizeof(int), &dwRead, NULL)) goto fail; for (int i = 1; i < SilhouetteCount; i++) { SilhouetteName[i] = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); } // Sleeve if (!ReadFile(hFile, &SleeveCount, sizeof(int), &dwRead, NULL)) goto fail; for (int i = 1; i < SleeveCount; i++) { SleeveName[i] = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); } // Collar if (!ReadFile(hFile, &CollarCount, sizeof(int), &dwRead, NULL)) goto fail; for (int i = 1; i < CollarCount; i++) { CollarName[i] = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); } // UpperMaterial if (!ReadFile(hFile, &UpperMaterialCount, sizeof(int), &dwRead, NULL)) goto fail; for (int i = 1; i < UpperMaterialCount; i++) { UpperMaterialName[i] = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); } // Pants if (!ReadFile(hFile, &PantsCount, sizeof(int), &dwRead, NULL)) goto fail; for (int i = 1; i < PantsCount; i++) { PantsName[i] = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); } // Belt if (!ReadFile(hFile, &BeltCount, sizeof(int), &dwRead, NULL)) goto fail; for (int i = 1; i < BeltCount; i++) { BeltName[i] = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); } // LowerMaterial if (!ReadFile(hFile, &LowerMaterialCount, sizeof(int), &dwRead, NULL)) goto fail; for (int i = 1; i < LowerMaterialCount; i++) { LowerMaterialName[i] = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); } // CombiSet Load /* bReturn &= Man.LoadFromFile(hFile); bReturn &= Woman.LoadFromFile(hFile); bReturn &= Child.LoadFromFile(hFile); bReturn &= Baby.LoadFromFile(hFile); */ bReturn &= Man_Coat_Sil.LoadFromFile(hFile); bReturn &= Man_Coat_Sle.LoadFromFile(hFile); bReturn &= Man_Coat_Col.LoadFromFile(hFile); bReturn &= Man_Coat_Mat.LoadFromFile(hFile); bReturn &= Man_Jacket_Sil.LoadFromFile(hFile); bReturn &= Man_Jacket_Sle.LoadFromFile(hFile); bReturn &= Man_Jacket_Col.LoadFromFile(hFile); bReturn &= Man_Jacket_Mat.LoadFromFile(hFile); bReturn &= Man_Jumper_Sil.LoadFromFile(hFile); bReturn &= Man_Jumper_Sle.LoadFromFile(hFile); bReturn &= Man_Jumper_Col.LoadFromFile(hFile); bReturn &= Man_Jumper_Mat.LoadFromFile(hFile); bReturn &= Man_Knit_Sil.LoadFromFile(hFile); bReturn &= Man_Knit_Sle.LoadFromFile(hFile); bReturn &= Man_Knit_Col.LoadFromFile(hFile); bReturn &= Man_Knit_Mat.LoadFromFile(hFile); bReturn &= Man_Shirts_Sil.LoadFromFile(hFile); bReturn &= Man_Shirts_Sle.LoadFromFile(hFile); bReturn &= Man_Shirts_Col.LoadFromFile(hFile); bReturn &= Man_Shirts_Mat.LoadFromFile(hFile); bReturn &= Man_Top_Sil.LoadFromFile(hFile); bReturn &= Man_Top_Sle.LoadFromFile(hFile); bReturn &= Man_Top_Col.LoadFromFile(hFile); bReturn &= Man_Top_Mat.LoadFromFile(hFile); bReturn &= Man_Vest_Sil.LoadFromFile(hFile); bReturn &= Man_Vest_Sle.LoadFromFile(hFile); bReturn &= Man_Vest_Col.LoadFromFile(hFile); bReturn &= Man_Vest_Mat.LoadFromFile(hFile); bReturn &= Man_Pants_Sil.LoadFromFile(hFile); bReturn &= Man_Pants_Belt.LoadFromFile(hFile); bReturn &= Man_Pants_Mat.LoadFromFile(hFile); bReturn &= Woman_Coat_Sil.LoadFromFile(hFile); bReturn &= Woman_Coat_Sle.LoadFromFile(hFile); bReturn &= Woman_Coat_Col.LoadFromFile(hFile); bReturn &= Woman_Coat_Mat.LoadFromFile(hFile); bReturn &= Woman_Jacket_Sil.LoadFromFile(hFile); bReturn &= Woman_Jacket_Sle.LoadFromFile(hFile); bReturn &= Woman_Jacket_Col.LoadFromFile(hFile); bReturn &= Woman_Jacket_Mat.LoadFromFile(hFile); bReturn &= Woman_Jumper_Sil.LoadFromFile(hFile); bReturn &= Woman_Jumper_Sle.LoadFromFile(hFile); bReturn &= Woman_Jumper_Col.LoadFromFile(hFile); bReturn &= Woman_Jumper_Mat.LoadFromFile(hFile); bReturn &= Woman_Knit_Sil.LoadFromFile(hFile); bReturn &= Woman_Knit_Sle.LoadFromFile(hFile); bReturn &= Woman_Knit_Col.LoadFromFile(hFile); bReturn &= Woman_Knit_Mat.LoadFromFile(hFile); bReturn &= Woman_Shirts_Sil.LoadFromFile(hFile); bReturn &= Woman_Shirts_Sle.LoadFromFile(hFile); bReturn &= Woman_Shirts_Col.LoadFromFile(hFile); bReturn &= Woman_Shirts_Mat.LoadFromFile(hFile); bReturn &= Woman_Top_Sil.LoadFromFile(hFile); bReturn &= Woman_Top_Sle.LoadFromFile(hFile); bReturn &= Woman_Top_Col.LoadFromFile(hFile); bReturn &= Woman_Top_Mat.LoadFromFile(hFile); bReturn &= Woman_Vest_Sil.LoadFromFile(hFile); bReturn &= Woman_Vest_Sle.LoadFromFile(hFile); bReturn &= Woman_Vest_Col.LoadFromFile(hFile); bReturn &= Woman_Vest_Mat.LoadFromFile(hFile); bReturn &= Woman_OnePiece_Sil.LoadFromFile(hFile); bReturn &= Woman_OnePiece_Sle.LoadFromFile(hFile); bReturn &= Woman_OnePiece_Col.LoadFromFile(hFile); bReturn &= Woman_OnePiece_Mat.LoadFromFile(hFile); bReturn &= Woman_Blouse_Sil.LoadFromFile(hFile); bReturn &= Woman_Blouse_Sle.LoadFromFile(hFile); bReturn &= Woman_Blouse_Col.LoadFromFile(hFile); bReturn &= Woman_Blouse_Mat.LoadFromFile(hFile); bReturn &= Woman_Pants_Sil.LoadFromFile(hFile); bReturn &= Woman_Pants_Belt.LoadFromFile(hFile); bReturn &= Woman_Pants_Mat.LoadFromFile(hFile); bReturn &= Woman_Skirt_Sil.LoadFromFile(hFile); bReturn &= Woman_Skirt_Belt.LoadFromFile(hFile); bReturn &= Woman_Skirt_Mat.LoadFromFile(hFile); bReturn &= Child_Coat_Sil.LoadFromFile(hFile); bReturn &= Child_Coat_Sle.LoadFromFile(hFile); bReturn &= Child_Coat_Col.LoadFromFile(hFile); bReturn &= Child_Coat_Mat.LoadFromFile(hFile); bReturn &= Child_Jacket_Sil.LoadFromFile(hFile); bReturn &= Child_Jacket_Sle.LoadFromFile(hFile); bReturn &= Child_Jacket_Col.LoadFromFile(hFile); bReturn &= Child_Jacket_Mat.LoadFromFile(hFile); bReturn &= Child_Jumper_Sil.LoadFromFile(hFile); bReturn &= Child_Jumper_Sle.LoadFromFile(hFile); bReturn &= Child_Jumper_Col.LoadFromFile(hFile); bReturn &= Child_Jumper_Mat.LoadFromFile(hFile); bReturn &= Child_Knit_Sil.LoadFromFile(hFile); bReturn &= Child_Knit_Sle.LoadFromFile(hFile); bReturn &= Child_Knit_Col.LoadFromFile(hFile); bReturn &= Child_Knit_Mat.LoadFromFile(hFile); bReturn &= Child_Shirts_Sil.LoadFromFile(hFile); bReturn &= Child_Shirts_Sle.LoadFromFile(hFile); bReturn &= Child_Shirts_Col.LoadFromFile(hFile); bReturn &= Child_Shirts_Mat.LoadFromFile(hFile); bReturn &= Child_Top_Sil.LoadFromFile(hFile); bReturn &= Child_Top_Sle.LoadFromFile(hFile); bReturn &= Child_Top_Col.LoadFromFile(hFile); bReturn &= Child_Top_Mat.LoadFromFile(hFile); bReturn &= Child_Vest_Sil.LoadFromFile(hFile); bReturn &= Child_Vest_Sle.LoadFromFile(hFile); bReturn &= Child_Vest_Col.LoadFromFile(hFile); bReturn &= Child_Vest_Mat.LoadFromFile(hFile); bReturn &= Child_OnePiece_Sil.LoadFromFile(hFile); bReturn &= Child_OnePiece_Sle.LoadFromFile(hFile); bReturn &= Child_OnePiece_Col.LoadFromFile(hFile); bReturn &= Child_OnePiece_Mat.LoadFromFile(hFile); bReturn &= Child_Blouse_Sil.LoadFromFile(hFile); bReturn &= Child_Blouse_Sle.LoadFromFile(hFile); bReturn &= Child_Blouse_Col.LoadFromFile(hFile); bReturn &= Child_Blouse_Mat.LoadFromFile(hFile); bReturn &= Child_Cape_Sil.LoadFromFile(hFile); bReturn &= Child_Cape_Sle.LoadFromFile(hFile); bReturn &= Child_Cape_Col.LoadFromFile(hFile); bReturn &= Child_Cape_Mat.LoadFromFile(hFile); bReturn &= Child_Pants_Sil.LoadFromFile(hFile); bReturn &= Child_Pants_Belt.LoadFromFile(hFile); bReturn &= Child_Pants_Mat.LoadFromFile(hFile); bReturn &= Child_Skirt_Sil.LoadFromFile(hFile); bReturn &= Child_Skirt_Belt.LoadFromFile(hFile); bReturn &= Child_Skirt_Mat.LoadFromFile(hFile); bReturn &= Baby_Shirts_Sil.LoadFromFile(hFile); bReturn &= Baby_Shirts_Sle.LoadFromFile(hFile); bReturn &= Baby_Shirts_Col.LoadFromFile(hFile); bReturn &= Baby_Shirts_Mat.LoadFromFile(hFile); bReturn &= Baby_OnePiece_Sil.LoadFromFile(hFile); bReturn &= Baby_OnePiece_Sle.LoadFromFile(hFile); bReturn &= Baby_OnePiece_Col.LoadFromFile(hFile); bReturn &= Baby_OnePiece_Mat.LoadFromFile(hFile); bReturn &= Baby_Cape_Sil.LoadFromFile(hFile); bReturn &= Baby_Cape_Sle.LoadFromFile(hFile); bReturn &= Baby_Cape_Col.LoadFromFile(hFile); bReturn &= Baby_Cape_Mat.LoadFromFile(hFile); bReturn &= Baby_Rompers_Sil.LoadFromFile(hFile); bReturn &= Baby_Rompers_Sle.LoadFromFile(hFile); bReturn &= Baby_Rompers_Col.LoadFromFile(hFile); bReturn &= Baby_Rompers_Mat.LoadFromFile(hFile); bReturn &= Baby_Pants_Sil.LoadFromFile(hFile); bReturn &= Baby_Pants_Belt.LoadFromFile(hFile); bReturn &= Baby_Pants_Mat.LoadFromFile(hFile); bReturn &= Baby_Skirt_Sil.LoadFromFile(hFile); bReturn &= Baby_Skirt_Belt.LoadFromFile(hFile); bReturn &= Baby_Skirt_Mat.LoadFromFile(hFile); if (!ReadFile(hFile, &nCellCount, sizeof(int), &dwRead, NULL)) goto fail; // Cell °³¼ö if (!ReadFile(hFile, Man_Coat_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Man_Jacket_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Man_Jumper_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Man_Shirts_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Man_Top_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Man_Vest_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Man_Pants_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Woman_Coat_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Woman_Jacket_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Woman_Jumper_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Woman_Knit_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Woman_Shirts_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Woman_Top_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Woman_Vest_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Woman_OnePiece_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Woman_Blouse_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Woman_Pants_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Woman_Skirt_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Child_Coat_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Child_Jacket_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Child_Jumper_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Child_Knit_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Child_Shirts_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Child_Top_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Child_Vest_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Child_OnePiece_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Child_Blouse_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Child_Cape_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Child_Pants_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Child_Skirt_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Baby_Shirts_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Baby_OnePiece_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Baby_Cape_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Baby_Rompers_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Baby_Pants_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Baby_Skirt_Cell_Order, sizeof(BYTE) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Man_Coat_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Man_Jacket_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Man_Jumper_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Man_Shirts_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Man_Top_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Man_Vest_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Man_Pants_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Woman_Coat_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Woman_Jacket_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Woman_Jumper_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Woman_Knit_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Woman_Shirts_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Woman_Top_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Woman_Vest_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Woman_OnePiece_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Woman_Blouse_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Woman_Pants_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Woman_Skirt_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Child_Coat_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Child_Jacket_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Child_Jumper_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Child_Knit_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Child_Shirts_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Child_Top_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Child_Vest_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Child_OnePiece_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Child_Blouse_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Child_Cape_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Child_Pants_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Child_Skirt_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Baby_Shirts_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Baby_OnePiece_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Baby_Cape_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Baby_Rompers_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Baby_Pants_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, Baby_Skirt_Cell_Visible, sizeof(bool) * nCellCount, &dwRead, NULL)) goto fail; CloseHandle(hFile); } else { bReturn = false; } hFile = NULL; return bReturn; fail: if (hFile) CloseHandle(hFile); hFile = NULL; return false; } #endif // --------------------------------------------------------------------------- #ifdef WORKSHEET bool __fastcall TVecDraw::SaveToCombiItem(String strFileName) { bool bReturn = true; HANDLE hFile = NULL; DWORD dwWrite; int nLen = 0, nCellCount = 0; int nVersion = 101; nCellCount = CELL_COUNT; // ÃʱâÈ­ if ((hFile = CreateFile(strFileName.c_str(), GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE) { // ¹öÀüÀº ¾Æ½±°Ôµµ 3.2 ¹öÀüÀÌ ³ª°£µÚ 2010¿¡¼­ Ãß°¡µÇ¾ú´Ù. - by monkman (2011.03.10) if (!WriteFile(hFile, &nVersion, sizeof(int), &dwWrite, NULL)) goto fail; // Silhouette if (!WriteFile(hFile, &SilhouetteCount, sizeof(int), &dwWrite, NULL)) goto fail; for (int i = 1; i < SilhouetteCount; i++) { nLen = _tcslen(SilhouetteName[i].c_str()); if (!WriteFile(hFile, &nLen, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, SilhouetteName[i].c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; } // Sleeve if (!WriteFile(hFile, &SleeveCount, sizeof(int), &dwWrite, NULL)) goto fail; for (int i = 1; i < SleeveCount; i++) { nLen = _tcslen(SleeveName[i].c_str()); if (!WriteFile(hFile, &nLen, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, SleeveName[i].c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; } // Collar if (!WriteFile(hFile, &CollarCount, sizeof(int), &dwWrite, NULL)) goto fail; for (int i = 1; i < CollarCount; i++) { nLen = _tcslen(CollarName[i].c_str()); if (!WriteFile(hFile, &nLen, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, CollarName[i].c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; } // UpperMaterial if (!WriteFile(hFile, &UpperMaterialCount, sizeof(int), &dwWrite, NULL)) goto fail; for (int i = 1; i < UpperMaterialCount; i++) { nLen = _tcslen(UpperMaterialName[i].c_str()); if (!WriteFile(hFile, &nLen, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, UpperMaterialName[i].c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; } // Pants if (!WriteFile(hFile, &PantsCount, sizeof(int), &dwWrite, NULL)) goto fail; for (int i = 1; i < PantsCount; i++) { nLen = _tcslen(PantsName[i].c_str()); if (!WriteFile(hFile, &nLen, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, PantsName[i].c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; } // Belt if (!WriteFile(hFile, &BeltCount, sizeof(int), &dwWrite, NULL)) goto fail; for (int i = 1; i < BeltCount; i++) { nLen = _tcslen(BeltName[i].c_str()); if (!WriteFile(hFile, &nLen, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, BeltName[i].c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; } // LowerMaterial if (!WriteFile(hFile, &LowerMaterialCount, sizeof(int), &dwWrite, NULL)) goto fail; for (int i = 1; i < LowerMaterialCount; i++) { nLen = _tcslen(LowerMaterialName[i].c_str()); if (!WriteFile(hFile, &nLen, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, LowerMaterialName[i].c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; } // CombiSet Save /* bReturn &= Man.SaveToFile(hFile); bReturn &= Woman.SaveToFile(hFile); bReturn &= Child.SaveToFile(hFile); bReturn &= Baby.SaveToFile(hFile); */ bReturn &= Man_Coat_Sil.SaveToFile(hFile); bReturn &= Man_Coat_Sle.SaveToFile(hFile); bReturn &= Man_Coat_Col.SaveToFile(hFile); bReturn &= Man_Coat_Mat.SaveToFile(hFile); bReturn &= Man_Jacket_Sil.SaveToFile(hFile); bReturn &= Man_Jacket_Sle.SaveToFile(hFile); bReturn &= Man_Jacket_Col.SaveToFile(hFile); bReturn &= Man_Jacket_Mat.SaveToFile(hFile); bReturn &= Man_Jumper_Sil.SaveToFile(hFile); bReturn &= Man_Jumper_Sle.SaveToFile(hFile); bReturn &= Man_Jumper_Col.SaveToFile(hFile); bReturn &= Man_Jumper_Mat.SaveToFile(hFile); bReturn &= Man_Knit_Sil.SaveToFile(hFile); bReturn &= Man_Knit_Sle.SaveToFile(hFile); bReturn &= Man_Knit_Col.SaveToFile(hFile); bReturn &= Man_Knit_Mat.SaveToFile(hFile); bReturn &= Man_Shirts_Sil.SaveToFile(hFile); bReturn &= Man_Shirts_Sle.SaveToFile(hFile); bReturn &= Man_Shirts_Col.SaveToFile(hFile); bReturn &= Man_Shirts_Mat.SaveToFile(hFile); bReturn &= Man_Top_Sil.SaveToFile(hFile); bReturn &= Man_Top_Sle.SaveToFile(hFile); bReturn &= Man_Top_Col.SaveToFile(hFile); bReturn &= Man_Top_Mat.SaveToFile(hFile); bReturn &= Man_Vest_Sil.SaveToFile(hFile); bReturn &= Man_Vest_Sle.SaveToFile(hFile); bReturn &= Man_Vest_Col.SaveToFile(hFile); bReturn &= Man_Vest_Mat.SaveToFile(hFile); bReturn &= Man_Pants_Sil.SaveToFile(hFile); bReturn &= Man_Pants_Belt.SaveToFile(hFile); bReturn &= Man_Pants_Mat.SaveToFile(hFile); bReturn &= Woman_Coat_Sil.SaveToFile(hFile); bReturn &= Woman_Coat_Sle.SaveToFile(hFile); bReturn &= Woman_Coat_Col.SaveToFile(hFile); bReturn &= Woman_Coat_Mat.SaveToFile(hFile); bReturn &= Woman_Jacket_Sil.SaveToFile(hFile); bReturn &= Woman_Jacket_Sle.SaveToFile(hFile); bReturn &= Woman_Jacket_Col.SaveToFile(hFile); bReturn &= Woman_Jacket_Mat.SaveToFile(hFile); bReturn &= Woman_Jumper_Sil.SaveToFile(hFile); bReturn &= Woman_Jumper_Sle.SaveToFile(hFile); bReturn &= Woman_Jumper_Col.SaveToFile(hFile); bReturn &= Woman_Jumper_Mat.SaveToFile(hFile); bReturn &= Woman_Knit_Sil.SaveToFile(hFile); bReturn &= Woman_Knit_Sle.SaveToFile(hFile); bReturn &= Woman_Knit_Col.SaveToFile(hFile); bReturn &= Woman_Knit_Mat.SaveToFile(hFile); bReturn &= Woman_Shirts_Sil.SaveToFile(hFile); bReturn &= Woman_Shirts_Sle.SaveToFile(hFile); bReturn &= Woman_Shirts_Col.SaveToFile(hFile); bReturn &= Woman_Shirts_Mat.SaveToFile(hFile); bReturn &= Woman_Top_Sil.SaveToFile(hFile); bReturn &= Woman_Top_Sle.SaveToFile(hFile); bReturn &= Woman_Top_Col.SaveToFile(hFile); bReturn &= Woman_Top_Mat.SaveToFile(hFile); bReturn &= Woman_Vest_Sil.SaveToFile(hFile); bReturn &= Woman_Vest_Sle.SaveToFile(hFile); bReturn &= Woman_Vest_Col.SaveToFile(hFile); bReturn &= Woman_Vest_Mat.SaveToFile(hFile); bReturn &= Woman_OnePiece_Sil.SaveToFile(hFile); bReturn &= Woman_OnePiece_Sle.SaveToFile(hFile); bReturn &= Woman_OnePiece_Col.SaveToFile(hFile); bReturn &= Woman_OnePiece_Mat.SaveToFile(hFile); bReturn &= Woman_Blouse_Sil.SaveToFile(hFile); bReturn &= Woman_Blouse_Sle.SaveToFile(hFile); bReturn &= Woman_Blouse_Col.SaveToFile(hFile); bReturn &= Woman_Blouse_Mat.SaveToFile(hFile); bReturn &= Woman_Pants_Sil.SaveToFile(hFile); bReturn &= Woman_Pants_Belt.SaveToFile(hFile); bReturn &= Woman_Pants_Mat.SaveToFile(hFile); bReturn &= Woman_Skirt_Sil.SaveToFile(hFile); bReturn &= Woman_Skirt_Belt.SaveToFile(hFile); bReturn &= Woman_Skirt_Mat.SaveToFile(hFile); bReturn &= Child_Coat_Sil.SaveToFile(hFile); bReturn &= Child_Coat_Sle.SaveToFile(hFile); bReturn &= Child_Coat_Col.SaveToFile(hFile); bReturn &= Child_Coat_Mat.SaveToFile(hFile); bReturn &= Child_Jacket_Sil.SaveToFile(hFile); bReturn &= Child_Jacket_Sle.SaveToFile(hFile); bReturn &= Child_Jacket_Col.SaveToFile(hFile); bReturn &= Child_Jacket_Mat.SaveToFile(hFile); bReturn &= Child_Jumper_Sil.SaveToFile(hFile); bReturn &= Child_Jumper_Sle.SaveToFile(hFile); bReturn &= Child_Jumper_Col.SaveToFile(hFile); bReturn &= Child_Jumper_Mat.SaveToFile(hFile); bReturn &= Child_Knit_Sil.SaveToFile(hFile); bReturn &= Child_Knit_Sle.SaveToFile(hFile); bReturn &= Child_Knit_Col.SaveToFile(hFile); bReturn &= Child_Knit_Mat.SaveToFile(hFile); bReturn &= Child_Shirts_Sil.SaveToFile(hFile); bReturn &= Child_Shirts_Sle.SaveToFile(hFile); bReturn &= Child_Shirts_Col.SaveToFile(hFile); bReturn &= Child_Shirts_Mat.SaveToFile(hFile); bReturn &= Child_Top_Sil.SaveToFile(hFile); bReturn &= Child_Top_Sle.SaveToFile(hFile); bReturn &= Child_Top_Col.SaveToFile(hFile); bReturn &= Child_Top_Mat.SaveToFile(hFile); bReturn &= Child_Vest_Sil.SaveToFile(hFile); bReturn &= Child_Vest_Sle.SaveToFile(hFile); bReturn &= Child_Vest_Col.SaveToFile(hFile); bReturn &= Child_Vest_Mat.SaveToFile(hFile); bReturn &= Child_OnePiece_Sil.SaveToFile(hFile); bReturn &= Child_OnePiece_Sle.SaveToFile(hFile); bReturn &= Child_OnePiece_Col.SaveToFile(hFile); bReturn &= Child_OnePiece_Mat.SaveToFile(hFile); bReturn &= Child_Blouse_Sil.SaveToFile(hFile); bReturn &= Child_Blouse_Sle.SaveToFile(hFile); bReturn &= Child_Blouse_Col.SaveToFile(hFile); bReturn &= Child_Blouse_Mat.SaveToFile(hFile); bReturn &= Child_Cape_Sil.SaveToFile(hFile); bReturn &= Child_Cape_Sle.SaveToFile(hFile); bReturn &= Child_Cape_Col.SaveToFile(hFile); bReturn &= Child_Cape_Mat.SaveToFile(hFile); bReturn &= Child_Pants_Sil.SaveToFile(hFile); bReturn &= Child_Pants_Belt.SaveToFile(hFile); bReturn &= Child_Pants_Mat.SaveToFile(hFile); bReturn &= Child_Skirt_Sil.SaveToFile(hFile); bReturn &= Child_Skirt_Belt.SaveToFile(hFile); bReturn &= Child_Skirt_Mat.SaveToFile(hFile); bReturn &= Baby_Shirts_Sil.SaveToFile(hFile); bReturn &= Baby_Shirts_Sle.SaveToFile(hFile); bReturn &= Baby_Shirts_Col.SaveToFile(hFile); bReturn &= Baby_Shirts_Mat.SaveToFile(hFile); bReturn &= Baby_OnePiece_Sil.SaveToFile(hFile); bReturn &= Baby_OnePiece_Sle.SaveToFile(hFile); bReturn &= Baby_OnePiece_Col.SaveToFile(hFile); bReturn &= Baby_OnePiece_Mat.SaveToFile(hFile); bReturn &= Baby_Cape_Sil.SaveToFile(hFile); bReturn &= Baby_Cape_Sle.SaveToFile(hFile); bReturn &= Baby_Cape_Col.SaveToFile(hFile); bReturn &= Baby_Cape_Mat.SaveToFile(hFile); bReturn &= Baby_Rompers_Sil.SaveToFile(hFile); bReturn &= Baby_Rompers_Sle.SaveToFile(hFile); bReturn &= Baby_Rompers_Col.SaveToFile(hFile); bReturn &= Baby_Rompers_Mat.SaveToFile(hFile); bReturn &= Baby_Pants_Sil.SaveToFile(hFile); bReturn &= Baby_Pants_Belt.SaveToFile(hFile); bReturn &= Baby_Pants_Mat.SaveToFile(hFile); bReturn &= Baby_Skirt_Sil.SaveToFile(hFile); bReturn &= Baby_Skirt_Belt.SaveToFile(hFile); bReturn &= Baby_Skirt_Mat.SaveToFile(hFile); if (!WriteFile(hFile, &nCellCount, sizeof(int), &dwWrite, NULL)) goto fail; // Cell °³¼ö if (!WriteFile(hFile, Man_Coat_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Man_Jacket_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Man_Jumper_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Man_Shirts_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Man_Top_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Man_Vest_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Man_Pants_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Woman_Coat_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Woman_Jacket_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Woman_Jumper_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Woman_Knit_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Woman_Shirts_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Woman_Top_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Woman_Vest_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Woman_OnePiece_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Woman_Blouse_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Woman_Pants_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Woman_Skirt_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Child_Coat_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Child_Jacket_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Child_Jumper_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Child_Knit_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Child_Shirts_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Child_Top_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Child_Vest_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Child_OnePiece_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Child_Blouse_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Child_Cape_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Child_Pants_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Child_Skirt_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Baby_Shirts_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Baby_OnePiece_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Baby_Cape_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Baby_Rompers_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Baby_Pants_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Baby_Skirt_Cell_Order, sizeof(BYTE) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Man_Coat_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Man_Jacket_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Man_Jumper_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Man_Shirts_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Man_Top_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Man_Vest_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Man_Pants_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Woman_Coat_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Woman_Jacket_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Woman_Jumper_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Woman_Knit_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Woman_Shirts_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Woman_Top_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Woman_Vest_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Woman_OnePiece_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Woman_Blouse_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Woman_Pants_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Woman_Skirt_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Child_Coat_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Child_Jacket_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Child_Jumper_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Child_Knit_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Child_Shirts_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Child_Top_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Child_Vest_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Child_OnePiece_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Child_Blouse_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Child_Cape_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Child_Pants_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Child_Skirt_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Baby_Shirts_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Baby_OnePiece_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Baby_Cape_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Baby_Rompers_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Baby_Pants_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, Baby_Skirt_Cell_Visible, sizeof(bool) * nCellCount, &dwWrite, NULL)) goto fail; CloseHandle(hFile); } else { bReturn = false; } hFile = NULL; return bReturn; fail: if (hFile) CloseHandle(hFile); hFile = NULL; return false; } #endif // --------------------------------------------------------------------------- ///////////////// ÀÛ¾÷Áö½Ã¼­ ///////////////////////// - by monkman (2010.12.22) #ifdef WORKSHEET __fastcall TCombinationData::TCombinationData() { // Á¤º¸ Division = DV_NONE; Type = TP_NONE; MethodStyle = DH_NONE; UpperStyle = 0; SleeveStyle = 0; CollarStyle = 0; LowerStyle = 0; BeltStyle = 0; // ½ºÅ¸Àϸí UpperWholeStyleID = ""; UpperSilhouetteStyleID = ""; UpperCollarStyleID = ""; UpperSleeveStyleID = ""; LowerWholeStyleID = ""; LowerSilhouetteStyleID = ""; LowerBeltStyleID = ""; // Comment UpperWholeComment = ""; UpperSilhouetteComment = ""; UpperCollarComment = ""; UpperSleeveComment = ""; LowerWholeComment = ""; LowerSilhouetteComment = ""; LowerBeltComment = ""; // ÆÄÀϸí UpperWholeFileName = ""; UpperSilhouetteFileName = ""; UpperSleeveFileName = ""; UpperCollarFileName = ""; LowerWholeFileName = ""; LowerSilhouetteFileName = ""; LowerBeltFileName = ""; // º¤Å͵¥ÀÌÅÍ ¸®½ºÆ® UpperWholeFrontDataList = new TList; UpperWholeBackDataList = new TList; UpperSilhouetteFrontDataList = new TList; UpperSilhouetteBackDataList = new TList; UpperSleeveFrontDataList = new TList; UpperSleeveBackDataList = new TList; UpperCollarFrontDataList = new TList; UpperCollarBackDataList = new TList; LowerWholeFrontDataList = new TList; LowerWholeBackDataList = new TList; LowerSilhouetteFrontDataList = new TList; LowerSilhouetteBackDataList = new TList; LowerBeltFrontDataList = new TList; LowerBeltBackDataList = new TList; // Material for (int i = 0; i < CELL_COUNT; i++) { MaterialStyleID[i] = ""; // ½ºÅ¸Àϸí MaterialComment[i] = ""; // Comment MaterialFileName[i] = ""; // ÆÄÀϸí MaterialDataList[i] = new TList; // º¤ÅÍ µ¥ÀÌÅÍ ¸®½ºÆ®) } memset(MaterialType, 0, sizeof(char) * CELL_COUNT); memset(MaterialLayerOrder, -1, sizeof(char) * CELL_COUNT); } #endif // --------------------------------------------------------------------------- #ifdef WORKSHEET __fastcall TCombinationData::~TCombinationData() { // Á¤º¸ Division = DV_NONE; Type = TP_NONE; MethodStyle = DH_NONE; UpperStyle = 0; SleeveStyle = 0; CollarStyle = 0; LowerStyle = 0; BeltStyle = 0; // ½ºÅ¸Àϸí UpperWholeStyleID = ""; UpperSilhouetteStyleID = ""; UpperCollarStyleID = ""; UpperSleeveStyleID = ""; LowerWholeStyleID = ""; LowerSilhouetteStyleID = ""; LowerBeltStyleID = ""; // Comment UpperWholeComment = ""; UpperSilhouetteComment = ""; UpperCollarComment = ""; UpperSleeveComment = ""; LowerWholeComment = ""; LowerSilhouetteComment = ""; LowerBeltComment = ""; // ÆÄÀϸí UpperWholeFileName = ""; UpperSilhouetteFileName = ""; UpperSleeveFileName = ""; UpperCollarFileName = ""; LowerWholeFileName = ""; LowerSilhouetteFileName = ""; LowerBeltFileName = ""; // º¤Å͵¥ÀÌÅÍ ¸®½ºÆ® VecDraw->ClearDataList(UpperWholeFrontDataList); VecDraw->ClearDataList(UpperWholeBackDataList); VecDraw->ClearDataList(UpperSilhouetteFrontDataList); VecDraw->ClearDataList(UpperSilhouetteBackDataList); VecDraw->ClearDataList(UpperSleeveFrontDataList); VecDraw->ClearDataList(UpperSleeveBackDataList); VecDraw->ClearDataList(UpperCollarFrontDataList); VecDraw->ClearDataList(UpperCollarBackDataList); VecDraw->ClearDataList(LowerWholeFrontDataList); VecDraw->ClearDataList(LowerWholeBackDataList); VecDraw->ClearDataList(LowerSilhouetteFrontDataList); VecDraw->ClearDataList(LowerSilhouetteBackDataList); VecDraw->ClearDataList(LowerBeltFrontDataList); VecDraw->ClearDataList(LowerBeltBackDataList); if (UpperWholeFrontDataList) delete UpperWholeFrontDataList; UpperWholeFrontDataList = NULL; if (UpperWholeBackDataList) delete UpperWholeBackDataList; UpperWholeBackDataList = NULL; if (UpperSilhouetteFrontDataList) delete UpperSilhouetteFrontDataList; UpperSilhouetteFrontDataList = NULL; if (UpperSilhouetteBackDataList) delete UpperSilhouetteBackDataList; UpperSilhouetteBackDataList = NULL; if (UpperSleeveFrontDataList) delete UpperSleeveFrontDataList; UpperSleeveFrontDataList = NULL; if (UpperSleeveBackDataList) delete UpperSleeveBackDataList; UpperSleeveBackDataList = NULL; if (UpperCollarFrontDataList) delete UpperCollarFrontDataList; UpperCollarFrontDataList = NULL; if (UpperCollarBackDataList) delete UpperCollarBackDataList; UpperCollarBackDataList = NULL; if (LowerWholeFrontDataList) delete LowerWholeFrontDataList; LowerWholeFrontDataList = NULL; if (LowerWholeBackDataList) delete LowerWholeBackDataList; LowerWholeBackDataList = NULL; if (LowerSilhouetteFrontDataList) delete LowerSilhouetteFrontDataList; LowerSilhouetteFrontDataList = NULL; if (LowerSilhouetteBackDataList) delete LowerSilhouetteBackDataList; LowerSilhouetteBackDataList = NULL; if (LowerBeltFrontDataList) delete LowerBeltFrontDataList; LowerBeltFrontDataList = NULL; if (LowerBeltBackDataList) delete LowerBeltBackDataList; LowerBeltBackDataList = NULL; // Material for (int i = 0; i < CELL_COUNT; i++) { MaterialStyleID[i] = ""; // ½ºÅ¸Àϸí MaterialComment[i] = ""; // Comment MaterialFileName[i] = ""; // ÆÄÀϸí // º¤ÅÍ µ¥ÀÌÅÍ ¸®½ºÆ® if (MaterialDataList[i]) { VecDraw->ClearDataList(MaterialDataList[i]); delete MaterialDataList[i]; } MaterialDataList[i] = NULL; } } #endif // --------------------------------------------------------------------------- #ifdef WORKSHEET bool __fastcall TCombinationData::CopyFrom(TCombinationData *SrcData) { bool bReturn = false; if (SrcData != NULL) { // Á¤º¸ Division = SrcData->Division; Type = SrcData->Type; MethodStyle = SrcData->MethodStyle; UpperStyle = SrcData->UpperStyle; CollarStyle = SrcData->CollarStyle; SleeveStyle = SrcData->SleeveStyle; LowerStyle = SrcData->LowerStyle; BeltStyle = SrcData->BeltStyle; // ½ºÅ¸Àϸí UpperWholeStyleID = SrcData->UpperWholeStyleID; UpperSilhouetteStyleID = SrcData->UpperSilhouetteStyleID; UpperSleeveStyleID = SrcData->UpperSleeveStyleID; UpperCollarStyleID = SrcData->UpperCollarStyleID; LowerWholeStyleID = SrcData->LowerWholeStyleID; LowerSilhouetteStyleID = SrcData->LowerSilhouetteStyleID; LowerBeltStyleID = SrcData->LowerBeltStyleID; // Comment UpperWholeComment = SrcData->UpperWholeComment; UpperSilhouetteComment = SrcData->UpperSilhouetteComment; UpperSleeveComment = SrcData->UpperSleeveComment; UpperCollarComment = SrcData->UpperCollarComment; LowerWholeComment = SrcData->LowerWholeComment; LowerSilhouetteComment = SrcData->LowerSilhouetteComment; LowerBeltComment = SrcData->LowerBeltComment; // ÆÄÀϸí UpperWholeFileName = SrcData->UpperWholeFileName; UpperSilhouetteFileName = SrcData->UpperSilhouetteFileName; UpperSleeveFileName = SrcData->UpperSleeveFileName; UpperCollarFileName = SrcData->UpperCollarFileName; LowerWholeFileName = SrcData->LowerWholeFileName; LowerSilhouetteFileName = SrcData->LowerSilhouetteFileName; LowerBeltFileName = SrcData->LowerBeltFileName; // º¤Å͵¥ÀÌÅÍ ¸®½ºÆ® if (VecDraw->CopyDataList(UpperWholeFrontDataList, SrcData->UpperWholeFrontDataList, -1, 0) == false) return false; if (VecDraw->CopyDataList(UpperWholeBackDataList, SrcData->UpperWholeBackDataList, -1, 1) == false) return false; if (VecDraw->CopyDataList(UpperSilhouetteFrontDataList, SrcData->UpperSilhouetteFrontDataList, -1, 0) == false) return false; if (VecDraw->CopyDataList(UpperSilhouetteBackDataList, SrcData->UpperSilhouetteBackDataList, -1, 1) == false) return false; if (VecDraw->CopyDataList(UpperSleeveFrontDataList, SrcData->UpperSleeveFrontDataList, -1, 0) == false) return false; if (VecDraw->CopyDataList(UpperSleeveBackDataList, SrcData->UpperSleeveBackDataList, -1, 1) == false) return false; if (VecDraw->CopyDataList(UpperCollarFrontDataList, SrcData->UpperCollarFrontDataList, -1, 0) == false) return false; if (VecDraw->CopyDataList(UpperCollarBackDataList, SrcData->UpperCollarBackDataList, -1, 1) == false) return false; if (VecDraw->CopyDataList(LowerWholeFrontDataList, SrcData->LowerWholeFrontDataList, -1, 0) == false) return false; if (VecDraw->CopyDataList(LowerWholeBackDataList, SrcData->LowerWholeBackDataList, -1, 1) == false) return false; if (VecDraw->CopyDataList(LowerSilhouetteFrontDataList, SrcData->LowerSilhouetteFrontDataList, -1, 0) == false) return false; if (VecDraw->CopyDataList(LowerSilhouetteBackDataList, SrcData->LowerSilhouetteBackDataList, -1, 1) == false) return false; if (VecDraw->CopyDataList(LowerBeltFrontDataList, SrcData->LowerBeltFrontDataList, -1, 0) == false) return false; if (VecDraw->CopyDataList(LowerBeltBackDataList, SrcData->LowerBeltBackDataList, -1, 1) == false) return false; // Material for (int i = 0; i < CELL_COUNT; i++) { MaterialStyleID[i] = SrcData->MaterialStyleID[i]; MaterialComment[i] = SrcData->MaterialComment[i]; MaterialFileName[i] = SrcData->MaterialFileName[i]; if (VecDraw->CopyDataList(MaterialDataList[i], SrcData->MaterialDataList[i], -1, 0) == false) return false; } memcpy(MaterialType, SrcData->MaterialType, sizeof(char) * CELL_COUNT); memcpy(MaterialLayerOrder, SrcData->MaterialLayerOrder, sizeof(char) * CELL_COUNT); bReturn = true; } return bReturn; } #endif // --------------------------------------------------------------------------- #ifdef WORKSHEET bool __fastcall TCombinationData::Equal() { // TODO : ºñ±³ ºÎºÐ ´Ù½Ã Ã¼Å©ÇØ¾ß ÇÔ!!!!! /* HANDLE hFile = NULL; AnsiString strFileName, strStyleID, strComment, strHeaderStyleID, strReturn; ESort Sort; STYLEDATAFILEHEADER header; TVecData *data = NULL; BYTE *StyleData = NULL; DWORD dwPos; DWORD dwDataSize; TList *SrcFrontDataListList = NULL, *SrcBackDataListList = NULL, *DstFrontDataListList = NULL, *DstBackDataListList = NULL; int Version; bool bDiff = false; SrcFrontDataListList = new TList; SrcBackDataListList = new TList; for (int i = 1; i < 8; i++) { if (i == SO_TOPFULL) { strFileName = UpperWholeFileName + ".sty"; strStyleID = ""; strComment = ""; DstFrontDataListList = UpperWholeFrontDataList; DstBackDataListList = UpperWholeBackDataList; } if (i == SO_SILHOUETTE) { strFileName = UpperSilhouetteFileName + ".sty"; strStyleID = UpperSilhouetteStyleID; strComment = UpperSilhouetteComment; DstFrontDataListList = UpperSilhouetteFrontDataList; DstBackDataListList = UpperSilhouetteBackDataList; } if (i == SO_SLEEVE) { strFileName = UpperSleeveFileName + ".sty"; strStyleID = UpperSleeveStyleID; strComment = UpperSleeveComment; DstFrontDataListList = UpperSleeveFrontDataList; DstBackDataListList = UpperSleeveBackDataList; } if (i == SO_COLLAR) { strFileName = UpperCollarFileName + ".sty"; strStyleID = UpperCollarStyleID; strComment = UpperCollarComment; DstFrontDataListList = UpperCollarFrontDataList; DstBackDataListList = UpperCollarBackDataList; } if (i == SO_BOTTOMFULL) { strFileName = LowerSilhouetteFileName + ".sty"; strStyleID = ""; strComment = ""; DstFrontDataListList = LowerWholeFrontDataList; DstBackDataListList = LowerWholeBackDataList; } if (i == SO_PANTS) { strFileName = LowerSilhouetteFileName + ".sty"; strStyleID = LowerSilhouetteStyleID; strComment = LowerSilhouetteComment; DstFrontDataListList = LowerSilhouetteFrontDataList; DstBackDataListList = LowerSilhouetteBackDataList; } if (i == SO_BELT) { strFileName = LowerWholeFileName + ".sty"; strStyleID = LowerBeltStyleID; strComment = LowerBeltComment; DstFrontDataListList = LowerBeltFrontDataList; DstBackDataListList = LowerBeltBackDataList; } if (strFileName.IsEmpty() == false && FileExists(strFileName)) { if ((hFile = CreateFile(strFileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE) { // STY ÆÄÀÏ Àбâ header = VecDraw->ReadSTYFileHeader(hFile, strFileName, &Version); if (!((100 <= Version && Version <= STYSTIFileVersion) || (500 <= Version && Version <= (STYSTIFileVersion+300)))) { // »óÀ§ ¹öÀü üũ - by monkman (2009.05.26) if (hFile) CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE; continue; } if (500 <= Version) { #ifndef NOT_STYLEDATA_LOCK // HASP°ú üũ ÇÑ´Ù if (!VecDraw->CheckSTYLock(hFile, header)) { CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE; continue; } else break; #endif } // STY ÆÄÀÏ µ¥ÀÌÅÍ Àбâ if (Version == 0 || Version == 100) { // Version 100 ÀÏ °æ¿ì ¸ø Àд ¿¡·¯·Î ±ä±ÞÃß°¡ - by monkman (2005.06.10) dwDataSize = GetFileSize(hFile, NULL) - sizeof(OLDSTYLEDATAFILEHEADER); } else { dwDataSize = GetFileSize(hFile, NULL) - sizeof(STYLEDATAFILEHEADER); } if ((StyleData = (BYTE *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwDataSize))==NULL) goto fail; // ÆÄÀÏÅ©±â¸¸Å­ ¸Þ¸ð¸® ÇÒ´ç VecDraw->ReadSTYFileData(hFile, Version, StyleData, header); dwPos = 0; for (int j = 0; j < header.Count1; j++) { if ((data = new TVecData(0))==NULL) goto fail; VecDraw->LoadFromSTYMemory(&StyleData, &dwPos, data, Version); SrcFrontDataListList->Add(data); } for (int j = 0; j < header.Count2; j++) { if ((data = new TVecData(1))==NULL) goto fail; VecDraw->LoadFromSTYMemory(&StyleData, &dwPos, data, Version); SrcBackDataListList->Add(data); } // Á¤º¸ ºñ±³ if (header.Sort == SO_TOPFULL || header.Sort == SO_BOTTOMFULL) { bDiff |= Division != header.Division; bDiff |= Type != header.Type; bDiff |= MethodStyle != header.EMethod; } if (header.Sort == SO_SILHOUETTE) bDiff |= UpperStyle != header.ESilhouette; if (header.Sort == SO_SLEEVE) bDiff |= SleeveStyle != header.ESleeve; if (header.Sort == SO_COLLAR) bDiff |= CollarStyle != header.ECollar; if (header.Sort == SO_PANTS) bDiff |= LowerStyle != header.EPants; if (header.Sort == SO_BELT) bDiff |= BeltStyle != header.EBelt; // ½ºÅ¸ÀÏ À̸§ ºñ±³ if (header.Sort != SO_TOPFULL && header.Sort != SO_BOTTOMFULL) { if (strcmp(header.StyleID, "")) strHeaderStyleID = strHeaderStyleID.sprintf(header.StyleID); else strHeaderStyleID = ""; bDiff |= strStyleID != strHeaderStyleID; } // µ¥ÀÌÅÍ ¸®½ºÆ® ºñ±³ if (bDiff == false) { bDiff |= !EqualDataList(SrcFrontDataListList, DstFrontDataListList, Version); bDiff |= !EqualDataList(SrcBackDataListList, DstBackDataListList, Version); } // TODO : TDW // µ¥ÀÌÅͰ¡ ¼­·Î ´Ù¸¦ °æ¿ì // Message : [ "" ] ÆÄÀÏÀÌ º¯°æµÇ¾ú½À´Ï´Ù. º¯°æµÈ ÆÄÀÏÀ» ºÒ·¯¿À½Ã°Ú½À´Ï±î? if (bDiff == true && MessageDlg("[ " + strFileName + " ]\n" + IDS_ELAND_MESSAGE001, mtConfirmation, TMsgDlgButtons() << mbYes << mbNo, 0) == mrYes) { // Á¤º¸ ¼³Á¤ if (header.Sort == SO_TOPFULL || header.Sort == SO_BOTTOMFULL) { Division = header.Division; Type = header.Type; MethodStyle = header.EMethod; } if (header.Sort == SO_SILHOUETTE) { UpperStyle = header.ESilhouette; if (strcmp(header.StyleID, "")) UpperSilhouetteStyleID = UpperSilhouetteStyleID.sprintf(header.StyleID); else UpperSilhouetteStyleID = ""; if (strcmp(header.Comment, "")) UpperSilhouetteComment = UpperSilhouetteComment.sprintf(header.Comment); else UpperSilhouetteComment = ""; } if (header.Sort == SO_SLEEVE) { SleeveStyle = header.ESleeve; if (strcmp(header.StyleID, "")) UpperSleeveStyleID = UpperSleeveStyleID.sprintf(header.StyleID); else UpperSleeveStyleID = ""; if (strcmp(header.Comment, "")) UpperSleeveComment = UpperSleeveComment.sprintf(header.Comment); else UpperSleeveComment = ""; } if (header.Sort == SO_COLLAR) { CollarStyle = header.ECollar; if (strcmp(header.StyleID, "")) UpperCollarStyleID = UpperCollarStyleID.sprintf(header.StyleID); else UpperCollarStyleID = ""; if (strcmp(header.Comment, "")) UpperCollarComment = UpperCollarComment.sprintf(header.Comment); else UpperCollarComment = ""; } if (header.Sort == SO_PANTS) { LowerStyle = header.EPants; if (strcmp(header.StyleID, "")) LowerSilhouetteStyleID = LowerSilhouetteStyleID.sprintf(header.StyleID); else LowerSilhouetteStyleID = ""; if (strcmp(header.Comment, "")) LowerSilhouetteComment = LowerSilhouetteComment.sprintf(header.Comment); else LowerSilhouetteComment = ""; } if (header.Sort == SO_BELT) { BeltStyle = header.EBelt; if (strcmp(header.StyleID, "")) LowerBeltStyleID = LowerBeltStyleID.sprintf(header.StyleID); else LowerBeltStyleID = ""; if (strcmp(header.Comment, "")) LowerBeltComment = LowerBeltComment.sprintf(header.Comment); else LowerBeltComment = ""; } // º¹»ç CopyDataList(DstFrontDataListList, SrcFrontDataListList); CopyDataList(DstBackDataListList, SrcBackDataListList); } // ÃʱâÈ­ ClearDataList(SrcFrontDataListList); ClearDataList(SrcBackDataListList); if (StyleData) { HeapFree(GetProcessHeap(), 0, StyleData); // ¸Þ¸ð¸® ÇØÁ¦ StyleData = NULL; } CloseHandle(hFile); } } hFile = INVALID_HANDLE_VALUE; bDiff = false; } */ return true; fail: /* if (hFile) CloseHandle(hFile); hFile = NULL; */ return false; } #endif // --------------------------------------------------------------------------- #ifdef WORKSHEET bool __fastcall TCombinationData::EqualDataList(TList *DstList, TList *SrcList, int Version) { TVecData *dataSrc = NULL, *dataDst = NULL; TSWordData *wdSrc = NULL, *wdDst = NULL; BYTE *pSrc = NULL, *pDst = NULL; int nLineCount, nWordCount; bool bReturn = true; if (SrcList && DstList && SrcList->Count == DstList->Count) { for (int i = 0; i < SrcList->Count && bReturn == true; i++) { dataSrc = (TVecData*)SrcList->Items[i]; dataDst = (TVecData*)DstList->Items[i]; // ºñ±³ ½ÃÀÛ (´Ù¸¦ °æ¿ì¿¡´Â bReturnÀÌ false°¡ µÊ) if (bReturn) bReturn &= dataSrc->Kind == dataDst->Kind; if (bReturn) bReturn &= dataSrc->First.x == dataDst->First.x; if (bReturn) bReturn &= dataSrc->First.y == dataDst->First.y; if (bReturn) bReturn &= dataSrc->Second.x == dataDst->Second.x; if (bReturn) bReturn &= dataSrc->Second.y == dataDst->Second.y; // ¿µÇâÀ» ¹Þ´Â µ¥ÀÌÅÍÀ̳ª, VecDraw::SaveToFile()À» ÀÌ¿ëÇϸé TraitSetÀÌ ÀúÀåµÇÁö ¾ÊÀ¸¹Ç·Î ºñ±³ÇÏÁö ¾Ê´Â´Ù // if (bReturn) bReturn &= memcmp(&dataSrc->TraitSet, &dataDst->TraitSet, sizeof(ObjectTraitSet)); if (bReturn && ((205 <= Version && Version < 500) || 505 <= Version)) bReturn &= dataSrc->bAntialiasing == dataDst->bAntialiasing; if (bReturn) { switch(dataSrc->Kind) { case V_LINE: case V_CURVE: if (bReturn) bReturn &= dataSrc->PenStyle == dataDst->PenStyle; if (bReturn) bReturn &= dataSrc->PenThick == dataDst->PenThick; if (bReturn) bReturn &= dataSrc->nCount == dataDst->nCount; if (bReturn) bReturn &= dataSrc->bRound == dataDst->bRound; if (bReturn) bReturn &= dataSrc->bFill == dataDst->bFill; if (bReturn) bReturn &= dataSrc->bWinding == dataDst->bWinding; if (bReturn) bReturn &= dataSrc->Color == dataDst->Color; if (bReturn) bReturn &= dataSrc->Brush == dataDst->Brush; if (bReturn) bReturn &= dataSrc->bClosed == dataDst->bClosed; // GroupIndex´Â ¿µÇâÀÌ ¾øÀ¸¹Ç·Î ºñ±³ÇÏÁö ¾Ê´Â´Ù // if (bReturn) bReturn &= dataSrc->GroupIndex == dataDst->GroupIndex; if (bReturn) { for (int j = 0; j < dataSrc->nCount * 3 + 1; j++) { bReturn &= dataSrc->pList[j].x == dataDst->pList[j].x; bReturn &= dataSrc->pList[j].y == dataDst->pList[j].y; } } if (bReturn && ((205 <= Version && Version < 500) || 505 <= Version)) { // ¿µÇâÀ» ¹Þ´Â µ¥ÀÌÅÍÀ̳ª, Á¤È®ÇÏ°Ô ºñ±³°¡ µÇÁö ¾Ê¾Æ¼­ ÁÖ¼®Ã³¸®Çß´Ù // for (int j = 0; j < 7; j++) { // bReturn &= dataSrc->DashValues[j] == dataDst->DashValues[j]; // } if (bReturn) bReturn &= dataSrc->CapStyle[0] == dataDst->CapStyle[0]; if (bReturn) bReturn &= dataSrc->CapStyle[1] == dataDst->CapStyle[1]; } if (bReturn && ((205 <= Version && Version < 500) || 505 <= Version)) { if (bReturn) bReturn &= dataSrc->bGradientFill == dataDst->bGradientFill; if (bReturn && dataSrc->bGradientFill) { if (bReturn) bReturn &= dataSrc->gradientItem == dataDst->gradientItem; if (bReturn) bReturn &= dataSrc->gAngle == dataDst->gAngle; if (bReturn) bReturn &= dataSrc->gradientColorCount == dataDst->gradientColorCount; if (bReturn) { for (int j = 0; j < dataSrc->gradientColorCount; j++) { bReturn &= dataSrc->gradientColors[j] .rgbRed == dataSrc->gradientColors[j].rgbRed; bReturn &= dataSrc->gradientColors[j] .rgbGreen == dataSrc->gradientColors[j].rgbGreen; bReturn &= dataSrc->gradientColors[j] .rgbBlue == dataSrc->gradientColors[j].rgbBlue; } } } } if (bReturn && ((207 <= Version && Version < 500) || 507 <= Version)) { if (bReturn) bReturn &= dataSrc->bMotive == dataDst->bMotive; if (bReturn && dataSrc->bMotive) { if (bReturn) bReturn &= dataSrc->mode == dataDst->mode; if (bReturn) bReturn &= dataSrc->gap == dataDst->gap; if (bReturn) bReturn &= dataSrc->motivecount == dataDst->motivecount; if (bReturn) bReturn &= dataSrc->proportion == dataDst->proportion; if (bReturn) bReturn &= dataSrc->childwidth == dataDst->childwidth; if (bReturn) bReturn &= dataSrc->childheight == dataDst->childheight; if (bReturn) bReturn &= dataSrc->centerX == dataDst->centerX; if (bReturn) bReturn &= dataSrc->centerY == dataDst->centerY; if (bReturn) bReturn &= dataSrc->ChildCount == dataSrc->ChildCount; if (bReturn) bReturn &= EqualDataList(dataSrc->ChildList, dataDst->ChildList, Version); } } break; /* case V_RECT: case V_ELLIPSE: if (bReturn) bReturn &= dataSrc->PenStyle == dataDst->PenStyle; if (bReturn) bReturn &= dataSrc->PenThick == dataDst->PenThick; if (bReturn) bReturn &= dataSrc->bRound == dataDst->bRound; if (bReturn) bReturn &= dataSrc->bFill == dataDst->bFill; if (bReturn) bReturn &= dataSrc->bWinding == dataDst->bWinding; if (bReturn) bReturn &= dataSrc->Color == dataDst->Color; if (bReturn) bReturn &= dataSrc->Brush == dataDst->Brush; if (bReturn) bReturn &= dataSrc->bPatternFill == dataDst->bPatternFill; if (bReturn && ((205 <= Version && Version < 500) || 505 <= Version)) { if (bReturn) bReturn &= memcmp(dataSrc->DashValues, dataDst->DashValues, sizeof(double)*7); if (bReturn) bReturn &= memcmp(dataSrc->CapStyle, dataDst->CapStyle, sizeof(int)*2); } if (bReturn && ((205 <= Version && Version < 500) || 505 <= Version)) { if (bReturn) bReturn &= dataSrc->bGradientFill == dataDst->bGradientFill; if (bReturn && dataSrc->bGradientFill) { if (bReturn) bReturn &= dataSrc->gradientItem == dataDst->gradientItem; if (bReturn) bReturn &= dataSrc->gAngle == dataDst->gAngle; if (bReturn) bReturn &= dataSrc->gradientColorCount == dataDst->gradientColorCount; if (bReturn) bReturn &= memcmp(dataSrc->gradientColors, dataDst->gradientColors, sizeof(RGBQUAD)*dataSrc->gradientColorCount); } } if (Version && ((207 <= Version && Version < 500) || 507 <= Version)) { if (bReturn) bReturn &= dataSrc->bMotive == dataDst->bMotive; if (bReturn && dataSrc->bMotive) { if (bReturn) bReturn &= dataSrc->mode == dataDst->mode; if (bReturn) bReturn &= dataSrc->gap == dataDst->gap; if (bReturn) bReturn &= dataSrc->motivecount == dataDst->motivecount; if (bReturn) bReturn &= dataSrc->proportion == dataDst->proportion; if (bReturn) bReturn &= dataSrc->childwidth == dataDst->childwidth; if (bReturn) bReturn &= dataSrc->childheight == dataDst->childheight; if (bReturn) bReturn &= dataSrc->centerX == dataDst->centerX; if (bReturn) bReturn &= dataSrc->centerY == dataDst->centerY; if (bReturn) bReturn &= dataSrc->ChildCount == dataDst->ChildCount; if (bReturn) bReturn &= EqualDataList(dataSrc->ChildList, dataDst->ChildList, Version); } } break; case V_TEXT: if (bReturn) bReturn &= dataSrc->Color == dataDst->Color; if (bReturn) bReturn &= memcmp(&dataSrc->Font, &dataDst->Font, sizeof(LOGFONT)); if (bReturn) bReturn &= dataSrc->nCount == dataDst->nCount; if (bReturn) bReturn &= memcmp(dataSrc->TextString.c_str(), dataDst->TextString.c_str(), sizeof(char)*dataSrc->nCount); break; case V_TEXTBOX: if (bReturn) bReturn &= dataSrc->CharH == dataDst->CharH; if (bReturn) bReturn &= dataSrc->CharW == dataDst->CharW; if (bReturn) bReturn &= dataSrc->TextAngle == dataDst->TextAngle; if (bReturn) bReturn &= memcmp(&dataSrc->StartPoint, &dataDst->StartPoint, sizeof(POINT)); if (bReturn) bReturn &= memcmp(&dataSrc->CenterPoint, &dataDst->CenterPoint, sizeof(POINT)); if (bReturn) bReturn &= dataSrc->ListOfAllLine->LineCount == dataDst->ListOfAllLine->LineCount; nLineCount = dataSrc->ListOfAllLine->LineCount; for (int j = 0; j < nLineCount && bReturn == true; j++) { if (bReturn) bReturn &= dataSrc->ListOfAllLine->GetLineTextBox(j)->LineDataList->Count == dataDst->ListOfAllLine->GetLineTextBox(j)->LineDataList->Count; nWordCount = dataSrc->ListOfAllLine->GetLineTextBox(j)->LineDataList->Count; for (int k = 0; k < nWordCount; k++) { wdSrc = (TSWordData *)dataSrc->ListOfAllLine->GetLineTextBox(j)->LineDataList->Items[k]; wdDst = (TSWordData *)dataDst->ListOfAllLine->GetLineTextBox(j)->LineDataList->Items[k]; // Selected´Â ºñ±³ÇÒ Çʿ䰡 ¾ø´Ù //if (bReturn) bReturn &= wdSrc->Selected == wdDst->Selected; if (bReturn) bReturn &= memcmp(&wdSrc->PPoint, &wdDst->PPoint, sizeof(POINT)); if (bReturn) bReturn &= memcmp(&wdSrc->LFont, &wdDst->LFont, sizeof(LOGFONT)); if (bReturn) bReturn &= wdSrc->Word == wdDst->Word; if (bReturn) bReturn &= wdSrc->UsedByte == wdDst->UsedByte; if (bReturn) bReturn &= wdSrc->Color == wdDst->Color; if (bReturn) bReturn &= wdSrc->Interval == wdDst->Interval; if (bReturn) bReturn &= wdSrc->HeightGap == wdDst->HeightGap; if (bReturn) bReturn &= wdSrc->WidthGap == wdDst->WidthGap; // Version 150 Ãß°¡ if (bReturn && ((205 <= Version && Version < 500) || 505 <= Version)){ if (bReturn) bReturn &= wdSrc->bNameChanged == wdDst->bNameChanged; if (bReturn) bReturn &= wdSrc->px == wdDst->px; if (bReturn) bReturn &= wdSrc->py == wdDst->py; if (bReturn) bReturn &= wdSrc->tx == wdDst->tx; if (bReturn) bReturn &= wdSrc->ty == wdDst->ty; if (bReturn) bReturn &= wdSrc->nx == wdDst->nx; if (bReturn) bReturn &= wdSrc->ny == wdDst->ny; } } if (bReturn) bReturn &= dataSrc->ListOfAllLine->GetLineTextBox(j)->lineHeight == dataDst->ListOfAllLine->GetLineTextBox(j)->lineHeight; } if (bReturn) bReturn &= memcmp(dataSrc->pList, dataDst->pList, sizeof(DPOINT)*5); if (bReturn) bReturn &= dataSrc->nCount == dataDst->nCount; break; */ } } } } else { bReturn = false; } return bReturn; } #endif // --------------------------------------------------------------------------- #ifdef WORKSHEET void __fastcall TCombinationData::SetInfoByHeader(STYLEDATAFILEHEADER *pheader, TStringList *FileList) { String strFileName, strExtName; // Á¤º¸ ¼³Á¤ if (Division == DV_NONE && pheader->Division != DV_NONE) Division = pheader->Division; if (Type == TP_NONE && pheader->Type != TP_NONE) Type = pheader->Type; if (MethodStyle == DH_NONE && pheader->EMethod != DH_NONE) MethodStyle = pheader->EMethod; // È®½ÇÇÑ Á¤º¸µé ¹× ½ºÅ¸ÀÏ ¼³Á¤ if (pheader->Sort == SO_SILHOUETTE) { UpperStyle = pheader->ESilhouette; UpperSilhouetteStyleID = String(pheader->StyleID); UpperSilhouetteComment = String(pheader->Comment); } if (pheader->Sort == SO_SLEEVE) { SleeveStyle = pheader->ESleeve; UpperSleeveStyleID = String(pheader->StyleID); UpperSleeveComment = String(pheader->Comment); } if (pheader->Sort == SO_COLLAR) { CollarStyle = pheader->ECollar; UpperCollarStyleID = String(pheader->StyleID); UpperCollarComment = String(pheader->Comment); } if (pheader->Sort == SO_PANTS) { LowerStyle = pheader->EPants; LowerSilhouetteStyleID = String(pheader->StyleID); LowerSilhouetteComment = String(pheader->Comment); } if (pheader->Sort == SO_BELT) { BeltStyle = pheader->EBelt; LowerBeltStyleID = String(pheader->StyleID); LowerBeltComment = String(pheader->Comment); } // ÆÄÀÏ¸í ¼³Á¤ if (FileList) { // pheader->FileIndex´Â ½ÇÁ¦ Index¿¡ 1À» ´õÇÑ °ªÀÌ´Ù. // ±âÁ¸ µ¥ÀÌÅͰ¡ memset()À¸·Î 0À¸·Î ÃʱâÈ­ µÇ¾ú±â¿¡ 0À» ÃʱⰪÀ¸·Î ¼³Á¤ÇÒ ¼ö ¹Û¿¡ ¾ø¾ú´Ù if (0 < pheader->FileIndex && pheader->FileIndex <= FileList->Count) { // ÆÄÀÏÀÌ ÀÖ´Â °æ¿ì strFileName = FileList->Strings[pheader->FileIndex - 1]; // È®ÀåÀÚ Á¦°Å ÀÛ¾÷ strExtName = ExtractFileExt(strFileName); strFileName = strFileName.SubString(1, strFileName.Length() - strExtName.Length()); switch(pheader->Sort) { case SO_TOPFULL: UpperWholeFileName = strFileName; break; case SO_SILHOUETTE: UpperSilhouetteFileName = strFileName; break; case SO_SLEEVE: UpperSleeveFileName = strFileName; break; case SO_COLLAR: UpperCollarFileName = strFileName; break; case SO_BOTTOMFULL: LowerWholeFileName = strFileName; break; case SO_PANTS: LowerSilhouetteFileName = strFileName; break; case SO_BELT: LowerBeltFileName = strFileName; break; } } } } #endif // --------------------------------------------------------------------------- #ifdef WORKSHEET void __fastcall TCombinationData::SetDataListByHeader(ESort Sort, int InstNum, TList *FrontDataListList, TList *BackDataListList) { switch(Sort) { case SO_TOPFULL: if (FrontDataListList != NULL) VecDraw->CopyDataList(UpperWholeFrontDataList, FrontDataListList, InstNum); if (BackDataListList != NULL) VecDraw->CopyDataList(UpperWholeBackDataList, BackDataListList, InstNum); break; case SO_SILHOUETTE: if (FrontDataListList != NULL) VecDraw->CopyDataList(UpperSilhouetteFrontDataList, FrontDataListList, InstNum); if (BackDataListList != NULL) VecDraw->CopyDataList(UpperSilhouetteBackDataList, BackDataListList, InstNum); break; case SO_SLEEVE: if (FrontDataListList != NULL) VecDraw->CopyDataList(UpperSleeveFrontDataList, FrontDataListList, InstNum); if (BackDataListList != NULL) VecDraw->CopyDataList(UpperSleeveBackDataList, BackDataListList, InstNum); break; case SO_COLLAR: if (FrontDataListList != NULL) VecDraw->CopyDataList(UpperCollarFrontDataList, FrontDataListList, InstNum); if (BackDataListList != NULL) VecDraw->CopyDataList(UpperCollarBackDataList, BackDataListList, InstNum); break; case SO_BOTTOMFULL: if (FrontDataListList != NULL) VecDraw->CopyDataList(LowerWholeFrontDataList, FrontDataListList, InstNum); if (BackDataListList != NULL) VecDraw->CopyDataList(LowerWholeBackDataList, BackDataListList, InstNum); break; case SO_PANTS: if (FrontDataListList != NULL) VecDraw->CopyDataList(LowerSilhouetteFrontDataList, FrontDataListList, InstNum); if (BackDataListList != NULL) VecDraw->CopyDataList(LowerSilhouetteBackDataList, BackDataListList, InstNum); break; case SO_BELT: if (FrontDataListList != NULL) VecDraw->CopyDataList(LowerBeltFrontDataList, FrontDataListList, InstNum); if (BackDataListList != NULL) VecDraw->CopyDataList(LowerBeltBackDataList, BackDataListList, InstNum); break; } } #endif // --------------------------------------------------------------------------- #ifdef WORKSHEET void __fastcall TCombinationData::ExchangeMaterialLayerOrder(int nDst, int nSrc) { char cSwap = 0; if (0 <= nSrc && nSrc < CELL_COUNT && 0 <= nDst && nDst < CELL_COUNT) { cSwap = MaterialLayerOrder[nDst]; MaterialLayerOrder[nDst] = MaterialLayerOrder[nSrc]; MaterialLayerOrder[nSrc] = cSwap; } } #endif // --------------------------------------------------------------------------- #ifdef WORKSHEET void __fastcall TCombinationData::InitMaterial(int nIndex) { String strSwap; TList *SwapList = NULL; char cSwap; int nPos = -1; if (0 <= nIndex && nIndex < CELL_COUNT) { MaterialStyleID[nIndex] = ""; MaterialComment[nIndex] = ""; MaterialFileName[nIndex] = ""; VecDraw->ClearDataList(MaterialDataList[nIndex]); MaterialType[nIndex] = 0; // ÃʱâÈ­ ¹× À§Ä¡ ã±â for (int i = 0; i < CELL_COUNT; i++) { if (MaterialLayerOrder[i] == nIndex) { MaterialLayerOrder[i] = -1; nPos = i; break; } } // ´Ù½ÃÁ¤·Ä for (int i = nPos; i < CELL_COUNT - 1; i++) { MaterialLayerOrder[i] = MaterialLayerOrder[i + 1]; } } } #endif // --------------------------------------------------------------------------- #ifdef WORKSHEET bool __fastcall TCombinationData::SaveToFile(HANDLE hFile) { DWORD dwWrite; // nVersion : 100 - ÀÌ·£µå ÀÛ¾÷Áö½Ã¼­ AnsiString ¹öÀü // 101 - ÀÌ·£µå ÀÛ¾÷Áö½Ã¼­ String (UnicodeString) ¹öÀü int nVersion = 101; int nLen; if (hFile != NULL) { // ¹öÀü if (!WriteFile(hFile, &nVersion, sizeof(nVersion), &dwWrite, NULL)) goto fail; // Á¤º¸ if (!WriteFile(hFile, &Division, sizeof(Division), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &Type, sizeof(Type), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &MethodStyle, sizeof(MethodStyle), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &UpperStyle, sizeof(UpperStyle), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &SleeveStyle, sizeof(SleeveStyle), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &CollarStyle, sizeof(CollarStyle), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &LowerStyle, sizeof(LowerStyle), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &BeltStyle, sizeof(BeltStyle), &dwWrite, NULL)) goto fail; // ½ºÅ¸Àϸí nLen = _tcslen(UpperWholeStyleID.c_str()); if (!WriteFile(hFile, &nLen, sizeof(nLen), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, UpperWholeStyleID.c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; nLen = _tcslen(UpperSilhouetteStyleID.c_str()); if (!WriteFile(hFile, &nLen, sizeof(nLen), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, UpperSilhouetteStyleID.c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; nLen = _tcslen(UpperSleeveStyleID.c_str()); if (!WriteFile(hFile, &nLen, sizeof(nLen), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, UpperSleeveStyleID.c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; nLen = _tcslen(UpperCollarStyleID.c_str()); if (!WriteFile(hFile, &nLen, sizeof(nLen), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, UpperCollarStyleID.c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; nLen = _tcslen(LowerWholeStyleID.c_str()); if (!WriteFile(hFile, &nLen, sizeof(nLen), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, LowerWholeStyleID.c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; nLen = _tcslen(LowerSilhouetteStyleID.c_str()); if (!WriteFile(hFile, &nLen, sizeof(nLen), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, LowerSilhouetteStyleID.c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; nLen = _tcslen(LowerBeltStyleID.c_str()); if (!WriteFile(hFile, &nLen, sizeof(nLen), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, LowerBeltStyleID.c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; // Material for (int i = 0; i < CELL_COUNT; i++) { nLen = _tcslen(MaterialStyleID[i].c_str()); if (!WriteFile(hFile, &nLen, sizeof(nLen), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, MaterialStyleID[i].c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; } // Comment nLen = _tcslen(UpperWholeComment.c_str()); if (!WriteFile(hFile, &nLen, sizeof(nLen), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, UpperWholeComment.c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; nLen = _tcslen(UpperSilhouetteComment.c_str()); if (!WriteFile(hFile, &nLen, sizeof(nLen), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, UpperSilhouetteComment.c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; nLen = _tcslen(UpperSleeveComment.c_str()); if (!WriteFile(hFile, &nLen, sizeof(nLen), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, UpperSleeveComment.c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; nLen = _tcslen(UpperCollarComment.c_str()); if (!WriteFile(hFile, &nLen, sizeof(nLen), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, UpperCollarComment.c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; nLen = _tcslen(LowerWholeComment.c_str()); if (!WriteFile(hFile, &nLen, sizeof(nLen), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, LowerWholeComment.c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; nLen = _tcslen(LowerSilhouetteComment.c_str()); if (!WriteFile(hFile, &nLen, sizeof(nLen), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, LowerSilhouetteComment.c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; nLen = _tcslen(LowerBeltComment.c_str()); if (!WriteFile(hFile, &nLen, sizeof(nLen), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, LowerBeltComment.c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; // Material for (int i = 0; i < CELL_COUNT; i++) { nLen = _tcslen(MaterialComment[i].c_str()); if (!WriteFile(hFile, &nLen, sizeof(nLen), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, MaterialComment[i].c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; } // ÆÄÀϸí nLen = _tcslen(UpperWholeFileName.c_str()); if (!WriteFile(hFile, &nLen, sizeof(nLen), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, UpperWholeFileName.c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; nLen = _tcslen(UpperSilhouetteFileName.c_str()); if (!WriteFile(hFile, &nLen, sizeof(nLen), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, UpperSilhouetteFileName.c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; nLen = _tcslen(UpperSleeveFileName.c_str()); if (!WriteFile(hFile, &nLen, sizeof(nLen), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, UpperSleeveFileName.c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; nLen = _tcslen(UpperCollarFileName.c_str()); if (!WriteFile(hFile, &nLen, sizeof(nLen), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, UpperCollarFileName.c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; nLen = _tcslen(LowerWholeFileName.c_str()); if (!WriteFile(hFile, &nLen, sizeof(nLen), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, LowerWholeFileName.c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; nLen = _tcslen(LowerSilhouetteFileName.c_str()); if (!WriteFile(hFile, &nLen, sizeof(nLen), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, LowerSilhouetteFileName.c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; nLen = _tcslen(LowerBeltFileName.c_str()); if (!WriteFile(hFile, &nLen, sizeof(nLen), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, LowerBeltFileName.c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; // Material for (int i = 0; i < CELL_COUNT; i++) { nLen = _tcslen(MaterialFileName[i].c_str()); if (!WriteFile(hFile, &nLen, sizeof(nLen), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, MaterialFileName[i].c_str(), sizeof(Char) * nLen, &dwWrite, NULL)) goto fail; } // º¤ÅÍ µ¥ÀÌÅÍ if (UpperWholeFrontDataList) VecDraw->SaveToFile(hFile, UpperWholeFrontDataList, 1, TexStylistFileVersion, 0); if (UpperWholeBackDataList) VecDraw->SaveToFile(hFile, UpperWholeBackDataList, 1, TexStylistFileVersion, 1); if (UpperSilhouetteFrontDataList) VecDraw->SaveToFile(hFile, UpperSilhouetteFrontDataList, 1, TexStylistFileVersion, 0); if (UpperSilhouetteBackDataList) VecDraw->SaveToFile(hFile, UpperSilhouetteBackDataList, 1, TexStylistFileVersion, 1); if (UpperSleeveFrontDataList) VecDraw->SaveToFile(hFile, UpperSleeveFrontDataList, 1, TexStylistFileVersion, 0); if (UpperSleeveBackDataList) VecDraw->SaveToFile(hFile, UpperSleeveBackDataList, 1, TexStylistFileVersion, 1); if (UpperCollarFrontDataList) VecDraw->SaveToFile(hFile, UpperCollarFrontDataList, 1, TexStylistFileVersion, 0); if (UpperCollarBackDataList) VecDraw->SaveToFile(hFile, UpperCollarBackDataList, 1, TexStylistFileVersion, 1); if (LowerWholeFrontDataList) VecDraw->SaveToFile(hFile, LowerWholeFrontDataList, 1, TexStylistFileVersion, 0); if (LowerWholeBackDataList) VecDraw->SaveToFile(hFile, LowerWholeBackDataList, 1, TexStylistFileVersion, 1); if (LowerSilhouetteFrontDataList) VecDraw->SaveToFile(hFile, LowerSilhouetteFrontDataList, 1, TexStylistFileVersion, 0); if (LowerSilhouetteBackDataList) VecDraw->SaveToFile(hFile, LowerSilhouetteBackDataList, 1, TexStylistFileVersion, 1); if (LowerBeltFrontDataList) VecDraw->SaveToFile(hFile, LowerBeltFrontDataList, 1, TexStylistFileVersion, 0); if (LowerBeltBackDataList) VecDraw->SaveToFile(hFile, LowerBeltBackDataList, 1, TexStylistFileVersion, 1); // Material for (int i = 0; i < CELL_COUNT; i++) { if (MaterialDataList[i]) VecDraw->SaveToFile(hFile, MaterialDataList[i], 1, TexStylistFileVersion, 0); } } return true; fail: return false; } #endif // --------------------------------------------------------------------------- #ifdef WORKSHEET int __fastcall TCombinationData::LoadFromFile(HANDLE hFile) { DWORD dwRead; int nVersion = -1; int nLen; char pName[MAX_PATH]; bool bHasVector = false; if (hFile != NULL) { // ¹öÀü if (!ReadFile(hFile, &nVersion, sizeof(nVersion), &dwRead, NULL)) goto fail; if (100 <= nVersion && nVersion <= 101) { // Á¤º¸ if (!ReadFile(hFile, &Division, sizeof(Division), &dwRead, NULL)) goto fail; if (!ReadFile(hFile, &Type, sizeof(Type), &dwRead, NULL)) goto fail; if (!ReadFile(hFile, &MethodStyle, sizeof(MethodStyle), &dwRead, NULL)) goto fail; if (!ReadFile(hFile, &UpperStyle, sizeof(UpperStyle), &dwRead, NULL)) goto fail; if (!ReadFile(hFile, &SleeveStyle, sizeof(SleeveStyle), &dwRead, NULL)) goto fail; if (!ReadFile(hFile, &CollarStyle, sizeof(CollarStyle), &dwRead, NULL)) goto fail; if (!ReadFile(hFile, &LowerStyle, sizeof(LowerStyle), &dwRead, NULL)) goto fail; if (!ReadFile(hFile, &BeltStyle, sizeof(BeltStyle), &dwRead, NULL)) goto fail; // ½ºÅ¸Àϸí UpperWholeStyleID = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); UpperSilhouetteStyleID = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); UpperSleeveStyleID = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); UpperCollarStyleID = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); LowerWholeStyleID = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); LowerSilhouetteStyleID = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); LowerBeltStyleID = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); // Material for (int i = 0; i < CELL_COUNT; i++) { MaterialStyleID[i] = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); } // Comment UpperWholeComment = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); UpperSilhouetteComment = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); UpperSleeveComment = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); UpperCollarComment = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); LowerWholeComment = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); LowerSilhouetteComment = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); LowerBeltComment = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); // Material for (int i = 0; i < CELL_COUNT; i++) { MaterialComment[i] = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); } // ÆÄÀϸí UpperWholeFileName = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); UpperSilhouetteFileName = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); UpperSleeveFileName = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); UpperCollarFileName = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); LowerWholeFileName = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); LowerSilhouetteFileName = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); LowerBeltFileName = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); // Material for (int i = 0; i < CELL_COUNT; i++) { MaterialFileName[i] = LoadFromFileAnsiStrToUniStr(hFile, nVersion == 100); } // º¤ÅÍ µ¥ÀÌÅÍ if (!ReadFile(hFile, &bHasVector, sizeof(bool), &dwRead, NULL)) goto fail; if (bHasVector == true && UpperWholeFrontDataList) VecDraw->LoadFromFile(hFile, UpperWholeFrontDataList, 0); if (!ReadFile(hFile, &bHasVector, sizeof(bool), &dwRead, NULL)) goto fail; if (bHasVector == true && UpperWholeBackDataList) VecDraw->LoadFromFile(hFile, UpperWholeBackDataList, 1); if (!ReadFile(hFile, &bHasVector, sizeof(bool), &dwRead, NULL)) goto fail; if (bHasVector == true && UpperSilhouetteFrontDataList) VecDraw->LoadFromFile(hFile, UpperSilhouetteFrontDataList, 0); if (!ReadFile(hFile, &bHasVector, sizeof(bool), &dwRead, NULL)) goto fail; if (bHasVector == true && UpperSilhouetteBackDataList) VecDraw->LoadFromFile(hFile, UpperSilhouetteBackDataList, 1); if (!ReadFile(hFile, &bHasVector, sizeof(bool), &dwRead, NULL)) goto fail; if (bHasVector == true && UpperSleeveFrontDataList) VecDraw->LoadFromFile(hFile, UpperSleeveFrontDataList, 0); if (!ReadFile(hFile, &bHasVector, sizeof(bool), &dwRead, NULL)) goto fail; if (bHasVector == true && UpperSleeveBackDataList) VecDraw->LoadFromFile(hFile, UpperSleeveBackDataList, 1); if (!ReadFile(hFile, &bHasVector, sizeof(bool), &dwRead, NULL)) goto fail; if (bHasVector == true && UpperCollarFrontDataList) VecDraw->LoadFromFile(hFile, UpperCollarFrontDataList, 0); if (!ReadFile(hFile, &bHasVector, sizeof(bool), &dwRead, NULL)) goto fail; if (bHasVector == true && UpperCollarBackDataList) VecDraw->LoadFromFile(hFile, UpperCollarBackDataList, 1); if (!ReadFile(hFile, &bHasVector, sizeof(bool), &dwRead, NULL)) goto fail; if (bHasVector == true && LowerWholeFrontDataList) VecDraw->LoadFromFile(hFile, LowerWholeFrontDataList, 0); if (!ReadFile(hFile, &bHasVector, sizeof(bool), &dwRead, NULL)) goto fail; if (bHasVector == true && LowerWholeBackDataList) VecDraw->LoadFromFile(hFile, LowerWholeBackDataList, 1); if (!ReadFile(hFile, &bHasVector, sizeof(bool), &dwRead, NULL)) goto fail; if (bHasVector == true && LowerSilhouetteFrontDataList) VecDraw->LoadFromFile(hFile, LowerSilhouetteFrontDataList, 0); if (!ReadFile(hFile, &bHasVector, sizeof(bool), &dwRead, NULL)) goto fail; if (bHasVector == true && LowerSilhouetteBackDataList) VecDraw->LoadFromFile(hFile, LowerSilhouetteBackDataList, 1); if (!ReadFile(hFile, &bHasVector, sizeof(bool), &dwRead, NULL)) goto fail; if (bHasVector == true && LowerBeltFrontDataList) VecDraw->LoadFromFile(hFile, LowerBeltFrontDataList, 0); if (!ReadFile(hFile, &bHasVector, sizeof(bool), &dwRead, NULL)) goto fail; if (bHasVector == true && LowerBeltBackDataList) VecDraw->LoadFromFile(hFile, LowerBeltBackDataList, 1); // Material for (int i = 0; i < CELL_COUNT; i++) { if (!ReadFile(hFile, &bHasVector, sizeof(bool), &dwRead, NULL)) goto fail; if (bHasVector == true && MaterialDataList[i]) VecDraw->LoadFromFile(hFile, MaterialDataList[i], 1); } // return Equal(); // °Ë»çÇÏ´Â ºÎºÐ¿¡ ¹®Á¦°¡ À־ ÇöÀç´Â °Ë»çÇÏÁö ¾Êµµ·Ï ÇÔ!!!!! return nVersion; } } return nVersion; fail: return nVersion; } #endif // --------------------------------------------------------------------------- void __fastcall TVecDraw::ClipPasteProcessing(String clipText)//window->textile ºÙ¿©³Ö±â ÇÔ¼ö { if (!BeReadyEdit) return; int i; TList *DataList = MainImageForm->V_DATA; if (DataList->Count <= 0 || CurrentTextBox < 0) return; TWordList *WordDataList; TVecData *tData; TSWordData *tsWordData = NULL, *tempWordData; // by maxleo21c (2004.08.07) int ZoomIn = MainImageForm->iMainImage->ZoomIn; int ZoomOut = MainImageForm->iMainImage->ZoomOut; int PositionY = MainImageForm->sbVert->Position; tData = (TVecData *)DataList->Items[CurrentTextBox]; if (tData->Kind != V_TEXTBOX) return; WordDataList = (TWordList *)tData->ListOfAllLine; int FirstY = (tData->StartPoint.y - PositionY) * ZoomIn / ZoomOut ; int sline, tline, rectBottom, IndexInLine, j, Height=0; RECT rect; DeleteCaret(tData); GetRectForMouseMove(tData, rect); rectBottom = rect.bottom; if (ExistSelected) { VecDraw->KeyDownInTextBox(VK_DELETE); FullViewForm->InitForm(MainImageForm->iMainImage); } int a=clipText.Length(); wchar_t *pStr=new wchar_t[a+1];//char -> wchar_t 2014.04.28 by NDJ wcscpy(pStr,clipText.t_str()); for (int i=0; iListOfAllLine->CurveData && tData->ListOfAllLine->CurveData->ParentTextBox && (pStr[i] == '\r' || pStr[i] == '\n'))//ÆÐ½º¹®ÀÚ¿¡ º¹»çÇÒ ¶§ \nÀº ÀúÀåµÇÁö ¾Ê°Ô ÇÑ´Ù. continue; if(pStr[i] == '\n') continue; //ÇÁ·Î±×·¥À¸·Î º¹»çµÉ ¶§ Shift + µå·¡±× Á¤·ÄÀ» Àâ±â À§ÇØ. tsWordData = new TSWordData; VectorForm->AddFontData(tsWordData); tsWordData->Word[0]=(Char)pStr[i]; tsWordData->Word[1] = '\0'; int WordInt = (int)tsWordData->Word[0]; tsWordData->UsedByte = 1; //if(WordInt >= 128) {tsWordData->UsedByte = 2;}//UnicodeÇ¥¸¦ ÀÌ¿ëÇÏ¿© 128 ÀÌÇÏÀ̸é 1¹ÙÀÌÆ®, ÃʰúÀ̸é 2¹ÙÀÌÆ®·Î ±ÔÁ¤ //else{tsWordData->UsedByte=1;} //if (tsWordData->UsedByte == 1) tsWordData->Word[1] = 0; VectorForm->AddTextData(tData, tsWordData, WordDataList); }//2014.04.28 By NDJ ºÙ¿©³Ö±â ÇÑ±Û ±úÁü ¹®Á¦ ÇØ°á(Ansistring -> Widestring) GetTextBoxRect(tData); MakeTextBoxPointList(tData); GetRectForMouseMove(tData, rect); // rect.bottom = rect.bottom > rectBottom ? rect.bottom : rectBottom; // 05.07.28 Ãß°¡ by malxoe21c // ÀÌÀ¯: LineÀ» µû¶ó Text¸¦ ÀÔ·ÂÇÒ¶§ FullViewUpdateÀÌ µÇÁö ¾Ê´Â ¹®Á¦ // top, left°¡ À½¼ö°¡ ³ª¿Í¼­ rectpaintÇÒ¶§ FullViewUpdate°¡ µÇÁö ¾Ê¾Ò´Ù. rect.top = rect.top < 0 ? 0 : rect.top; rect.left = rect.left < 0 ? 0 : rect.left; rect.right = rect.right < 0 ? 0 : rect.right; rect.bottom = rect.bottom > rectBottom ? rect.bottom : rectBottom; MainImageForm->iMainImage->RectPaint(rect); ShiftKeyInitialization(xCaretPoz,yCaretPoz,tData); delete[] pStr; /* case WM_IME_CHAR: if (VecDraw->ExistSelected) { VecDraw->KeyDownInTextBox(VK_DELETE); FullViewForm->InitForm(MainImageForm->iMainImage); } for(i=0; i<(int)LOWORD(msg.LParam); i++) { tsWordData = new TSWordData; tsWordData->Word[0] = (char)(msg.WParam>>8); tsWordData->Word[1] = (char)msg.WParam; tsWordData->Word[2] = '\0'; AddFontData(tsWordData); VecDraw->GetRectForMouseMove(tData, rect); rectBottom = rect.bottom; if (tsWordData->Word[0] == 0) { tsWordData->Word[0] = (char)msg.WParam; tsWordData->Word[1] = '\0'; tsWordData->UsedByte = 1; AddTextData(tData, tsWordData, WordDataList); if (tsWordData->Word[0] == '\r') { VecDraw->GetTextBoxRect(tData); VecDraw->MakeTextBoxPointList(tData); VecDraw->GetRectForMouseMove(tData, rect); MainImageForm->iMainImage->Repaint(); } else { VecDraw->GetTextBoxRect(tData); VecDraw->MakeTextBoxPointList(tData); VecDraw->GetRectForMouseMove(tData, rect); rect.bottom = rect.bottom > rectBottom ? rect.bottom : rectBottom; MainImageForm->iMainImage->RectPaint(rect); } return; } tsWordData->UsedByte = 2; AddTextData(tData, tsWordData, WordDataList); } VecDraw->GetTextBoxRect(tData); VecDraw->MakeTextBoxPointList(tData); VecDraw->GetRectForMouseMove(tData, rect); MainImageForm->iMainImage->RectPaint(rect); break; } */ } //--------------------------------------------------------------------------- void __fastcall TVecDraw::ShiftKeyInitialization(int X,int Y,TVecData *tData) { SelectedWordData=0; SelStart = IndexOfWord; SelEnd = SelStart; LineStart = IndexOfLine; LineEnd = IndexOfLine; SelStartPoz.x = xCaretPoz; SelStartPoz.y = yCaretPoz; TextAngle = tData->TextAngle; TSWordData *tsWordData; for (int k = 0; knCount; k++) { tsWordData = (TSWordData *)tData->ListOfAllLine->Items(k); tsWordData->Selected = false; tsWordData->bNameChanged = false; // 2005 Vector Upgrade 0316 } BeReadyEdit = true; // todo: ij·ÔÀ¸·Î ó¸®Çϱâ À§Çؼ­ CenterPoint.x = tData->CenterPoint.x; CenterPoint.y = tData->CenterPoint.y; } //---------------------------------------------------------------------------