//--------------------------------------------------------------------------- #include #include #pragma hdrstop #include "LogData.h" #include "Draw_F.h" #include "MainImage.h" #include "Palette.h" #include "PenManager.h" #include "Undo.h" #include "MainMenu.h" #include "FullView.h" #include "Define.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "RzEdit" #pragma link "RzSpnEdt" #pragma link "TNumEdit" #pragma link "RzBckgnd" #pragma link "RzButton" #pragma link "RzPanel" #pragma link "RzRadChk" #pragma resource "*.dfm" //--------------------------------------------------------------------------- #define TD_LINE 0 #define TD_SQUR 1 #define TD_RECT 2 #define TD_CIRCLE 3 #define TD_ELLIP 4 #define TD_CURVE 5 #define TD_OUT 6 #define IDS_SOLID StringTable[0] #define IDS_DOT StringTable[1] #define IDS_LASTCENTER StringTable[2] #define IDS_RADIUS StringTable[3] #define IDS_AXIS StringTable[4] #define IDS_DELETEPOINT StringTable[5] #define IDS_TAPERYES StringTable[6] #define IDS_TAPERNO StringTable[7] #define IDS_INPUT_A StringTable[8] #define IDS_INPUT_B StringTable[9] #define IDS_LINE StringTable[10] #define IDS_FIGURE StringTable[11] #define IDS_HORI StringTable[12] #define IDS_VERT StringTable[13] //--------------------------------------------------------------------------- struct TBackupPointData { POINT pt; COLORREF col; int pen_size; //lhskys ÇϳªÀÇ º¯¼ö¸¦ ¸¸µé¾î ÁÂÇ¥°ª°ú Ä®¶ó°ª°ú °°ÀÌ size °ªµµ ¹é¾÷ÇØµÎ±â À§Çؼ­... int DotSolid; int start_size; int end_size; String Dotspace; String Dotlength; double st_rate; double ed_rate; int grade; bool spread; TColor s_color; TColor e_color; }; TDrawForm *DrawForm; //--------------------------------------------------------------------------- __fastcall TDrawForm::TDrawForm(TComponent* Owner) : TForm(Owner) { //======================== 2001.3.27 lhskys FormCreate(TObject *Sender)³»¿ë ¿Å±è //============================================================= StringTable.Create(DirectoryBin, Language, "Draw"); SetSmallFont(Font); SetSmallFont(Label1->Font); rzbtnLType->Hint = IDS_COMMON_SEPARATELINE; rzcbFill->Hint = String(IDS_COMMON_FILL);// + " : " + String(IDS_COMMON_BUTTONNO); imgFill->Hint = IDS_COMMON_FILL; Label1->Caption = IDS_LINE; lLength->Caption = IDS_COMMON_LENGTH; lAngle->Caption = IDS_COMMON_ANGLE; rzcbDot->Caption = IDS_DOT; lDotLength->Caption = IDS_COMMON_LENGTH; lDotSpace->Caption = IDS_COMMON_GAP; rzbtFirst->Caption = IDS_COMMON_FIRSTPOINT; rzbtDelete->Caption = IDS_DELETEPOINT; rzcbPressure->Caption = IDS_TAPERYES; sbInputMode1->Caption = IDS_INPUT_A; sbInputMode2->Caption = IDS_INPUT_B; rzbtnLastCenter->Caption = IDS_LASTCENTER; mnitmSquare->Caption = IDS_COMMON_SQUARE; mnitmRectangle->Caption = IDS_COMMON_RECTANGLE; mnitmCircle->Caption = IDS_COMMON_CIRCLE; mnitmEllipse->Caption = IDS_COMMON_ELLIPSE; mnitmSeparate->Caption = IDS_COMMON_SEPARATELINE; mnitmContinuous->Caption = IDS_COMMON_CONTINUOUSLINE; //============================================================= isTaper = false; StartSize->Value = PenManagerForm->Pen->BasicThick; EndSize->Value = 1; PenManagerForm->rzsePenSize->Value = StartSize->Value; separatel = 0; //lhskys cirlastpoint = true; elliplastpoint = true; //============================= MakeMenuHintByShortcut(); // initialize the GDI+ library (05.03.08) maxleo21c // Gdiplus::GdiplusStartup(&gdp_token_, &Gdiplus::GdiplusStartupInput(), NULL); } //--------------------------------------------------------------------------- __fastcall TDrawForm::~TDrawForm() { // close the GDI+ library (05.03.08) maxleo21c // Gdiplus::GdiplusShutdown(gdp_token_); } //--------------------------------------------------------------------------- void __fastcall TDrawForm::lFillTypeClick(TObject *Sender) { BEGIN_LOG("Draw_F"); iMainImageChange(); if (rzcbFill->Checked) { fill_not = 1; // lFillType->Caption = String(IDS_COMMON_FILL) + " : " + String(IDS_COMMON_BUTTONYES); Ltype[Item].sw = 0; // lDotType->Caption = IDS_SOLID; } else { fill_not = 0; // lFillType->Caption = String(IDS_COMMON_FILL) + " : " + String(IDS_COMMON_BUTTONNO); } InitPointList(); view(); step = 0; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::FunctionClick(TObject *Sender) { bool change = false; int prestep, sx, sy; COLORREF c = PaletteForm->DIB256Palette->GetFGCOLORREF(MainImageForm->iMainImage->uBitmap->BitsPerPixel); iMainImageChange(); InitPointList(); TRzMenuToolbarButton *s = (TRzMenuToolbarButton *)Sender; rzbtFirst->Enabled = true; if (s == sbLine) { // »ç°¢Çü(Á¤»ç°¢Çü/Á÷»ç°¢Çü), ¿ø(Á¤¿ø/Ÿ¿ø)¿¡¼­ ¼±À̳ª °î¼±À¸·Î º¯°æµÇ¾úÀ» ¶§ // stepÀ» ÃʱâÈ­½ÃŲ´Ù - by monkman (2011.04.29) if (Item == TD_RECT || Item == TD_SQUR || Item == TD_ELLIP || Item == TD_CIRCLE) step = 0; // if (Item == TD_CURVE && Line_type == 1 && step < 2) { if (Item == TD_CURVE && Line_type == 1) { if(step ==2) step =1; change = true; prestep = step; if (Ltype[TD_CURVE].sw != Ltype[TD_LINE].sw) { if (Ltype[TD_CURVE].sw == 0) { Tstitch.l[1].sx = Lsx; Tstitch.l[1].sy = Lsy; } else if (Ltype[TD_CURVE].sw == 1) { Lsx = Tstitch.l[1].sx; Lsy = Tstitch.l[1].sy; } } if (step == 1) AddPointList(Lsx, Lsy, c); } Item = TD_LINE; // rzbtFirst->Caption = IDS_COMMON_FIRSTPOINT; StartSize->Value = PenManagerForm->Pen->BasicThick; } else if (s == sbCurve) { // »ç°¢Çü(Á¤»ç°¢Çü/Á÷»ç°¢Çü), ¿ø(Á¤¿ø/Ÿ¿ø)¿¡¼­ ¼±À̳ª °î¼±À¸·Î º¯°æµÇ¾úÀ» ¶§ // stepÀ» ÃʱâÈ­½ÃŲ´Ù - by monkman (2011.04.29) if (Item == TD_RECT || Item == TD_SQUR || Item == TD_ELLIP || Item == TD_CIRCLE) step = 0; curvest = true; //2001.4.10 by lhskys °î¼± ÇÑÁ¡µÚ·Î¿¡¼­ if (Item == TD_LINE && Line_type == 1) { // óÀ½¿¡ undosave°¡ ¾ÈµÇ¼­ üũ ÈÄ undosave ÇßÀ½ change = true; prestep = step; if (Ltype[TD_LINE].sw == 0) { Tstitch.l[1].sx = Lsx; Tstitch.l[1].sy = Lsy; } else if (Ltype[TD_LINE].sw == 1) { Lsx = Tstitch.l[1].sx; Lsy = Tstitch.l[1].sy; } if (step == 1) AddPointList(Lsx, Lsy, c); } Item = TD_CURVE; StartSize->Value = PenManagerForm->Pen->BasicThick; //EndSize->Value = 1; } else if (s == sbRect) { if (pumnRect->Tag == mnitmRectangle->Tag) Item = TD_RECT; else Item = TD_SQUR; step = 0; } else if (s == sbEllip) { if (pumnEllip->Tag == mnitmEllipse->Tag) Item = TD_ELLIP; else Item = TD_CIRCLE; step = 0; } else if (s == sbOut) { Item = TD_OUT; step = 0; } // isw = 0; isHVLine = false; // by celberus hasUserLength = false; isNumberInput = false; Asw = 0; Lsw = 0; Dsw = 0; //Line_type = 1; //Curve_type = 1; view(); if(Item == TD_CIRCLE){ // if(cirlastpoint)rzbtFirst->Enabled = false; }else if(Item == TD_ELLIP){ if(elliplastpoint)rzbtnLastCenter->Enabled = false; } if (change) step = prestep; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::lDotTypeClick(TObject *Sender) { POINT *pt, st; iMainImageChange(); if (rzcbDot->Checked) { Ltype[Item].sw = 1; // lDotType->Caption = IDS_DOT; // lFillType->Caption = String(IDS_COMMON_FILL) + " : " + IDS_COMMON_BUTTONNO; fill_not = 0; } else { Ltype[Item].sw = 0; // lDotType->Caption = IDS_SOLID; } // InitPointList(); // view(); //======================= 2001.5.29 by lhskys ±×¸®±â Á¡¼±°ú ½Ç¼± ¿¬¼Ó... if(step == 1 && (sbCurve->Down || sbLine->Down)){ if(sbCurve->Down){ if (Ltype[TD_CURVE].sw == 0) { Lsx = Tstitch.l[1].sx; Lsy = Tstitch.l[1].sy; } else if (Ltype[TD_CURVE].sw == 1) { Tstitch.l[1].sx = Lsx; Tstitch.l[1].sy = Lsy; } }else if(sbLine->Down){ if (Ltype[TD_LINE].sw == 0) { Lsx = Tstitch.l[1].sx; Lsy = Tstitch.l[1].sy; } else if (Ltype[TD_LINE].sw == 1) { Tstitch.l[1].sx = Lsx; Tstitch.l[1].sy = Lsy; } } eDotLength->Value = Ltype[Item].value[0]; eDotSpace->Value = Ltype[Item].value[1]; //========================================================== // view(); // ÇÑÁ¡µÚ·Î ½Ã¿¡ Á¡¼±/½Ç¼± µ¿½Ã ¾ðµÎ¸¦ À§ÇØ ¸·À½ step = 1; } else { InitPointList(); view(); } //======================== } //--------------------------------------------------------------------------- void __fastcall TDrawForm::EditMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { TNumEdit *s; s = (TNumEdit *)Sender; if (s == eDotLength) { s->SetFocus(); s->SelectAll(); } else if (s == eDotSpace) { s->SetFocus(); s->SelectAll(); } else { // if (Ltype[Item].sw == 0) { if (Item == TD_LINE) { if (step != 0) { s->SetFocus(); s->SelectAll(); } } else if (Item == TD_CURVE) { if (step != 0) { s->SetFocus(); s->SelectAll(); } } else if (Item == TD_SQUR) { if (step == 0) { s->SetFocus(); s->SelectAll(); } } else if (Item == TD_RECT) { if (step == 0) { s->SetFocus(); s->SelectAll(); } } else if (Item == TD_CIRCLE) { if (step == 0) { s->SetFocus(); s->SelectAll(); } } else if (Item == TD_ELLIP) { if (step == 0) { s->SetFocus(); s->SelectAll(); } } // } } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::EditKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { TNumEdit *s; if (Key == VK_RETURN) { iMainImageChange(); s = (TNumEdit *)Sender; if (s == eLength1) { if(eLength1->Value == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); return; } if (Item != TD_LINE) { Lsx = -1; Lex = -1; Lsy = -1; Ley = -1; Csx = -1; Csy = -1; } // isw = 1; hasUserLength = true; // by celberus isNumberInput = false; // by celberus Lsw = 1; InputNumber(); } else if (s == eLength2) { if (Item != TD_LINE) { Lsx = -1; Lex = -1; Lsy = -1; Ley = -1; Csx = -1; Csy = -1; } // isw = 1; hasUserLength = true; // by celberus isNumberInput = false; // by celberus Lsw = 1; InputNumber(); } else if (s == eAngle) { // isw = 1; hasUserLength = true; // by celberus isNumberInput = false; // by celberus Asw = 1; InputNumber(); } else if (s == eDotLength) { Dsw = 1; InputDotNumber(); } else if (s == eDotSpace) { Dsw = 2; InputDotNumber(); } g_FocusControl->SetFocus(); }else { s = (TNumEdit *)Sender; if (s == eLength1 || s == eDotLength || eDotSpace) { swLength = true; } else if (s == eAngle) { swAngle = true; } else if (s == eLength2) { swLength = true; } } } //--------------------------------------------------------------------------- // Private Function //--------------------------------------------------------------------------- void __fastcall TDrawForm::InputDotNumber(void) { if (Dsw == 1) { Ltype[Item].value[0] = eDotLength->IntValue; Dsw = 0; } else if (Dsw == 2) { Ltype[Item].value[1] = eDotSpace->IntValue; Dsw = 0; } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::InputNumber(void) { BEGIN_LOG("Draw_F"); String s; int pw, x, y, ang; double len; TPItemImage *Image = MainImageForm->iMainImage; pw = PenManagerForm->Pen->BasicThick; if (Item == TD_CIRCLE) { //s = eLength1->Text; if (hasUserLength && !isNumberInput) { // by celberus switch (MainImageForm->CurrentUnit) { case uInch : if (eLength1->Value * MainImageForm->CanvasInfor.DotsPerInch + 0.5 > pw) { Radius = eLength1->Value * MainImageForm->CanvasInfor.DotsPerInch + 0.5; }else if(eLength1->Value == 0)Radius=0; break; case uCm : if (eLength1->Value / 2.54 * MainImageForm->CanvasInfor.DotsPerInch + 0.5 > pw) { Radius = eLength1->Value / 2.54 * MainImageForm->CanvasInfor.DotsPerInch + 0.5; }else if(eLength1->Value == 0)Radius=0; break; default : if (eLength1->Value > (pw)) { Radius = eLength1->Value; }else if(eLength1->Value == 0)Radius=0; break; } // ¿øÀ϶§¿¡µµ ±æÀÌ Ç¥Çö eLength2->Value = eLength1->Value; // isw = 2; isNumberInput = true; // by celberus if (Radius > sqrt(Image->uBitmap->Width * Image->uBitmap->Width + Image->uBitmap->Height * Image->uBitmap->Height) / 2.0) { Radius = sqrt(Image->uBitmap->Width * Image->uBitmap->Width + Image->uBitmap->Height * Image->uBitmap->Height) / 2.0; } } } else if (Item == TD_ELLIP) { // if (isw == 1) { if (hasUserLength && !isNumberInput) { // by celberus switch (MainImageForm->CurrentUnit) { case uDot : if (eLength1->IntValue > pw / 2.0) Ell_rx = eLength1->IntValue; else if(eLength1->IntValue == 0) Ell_rx = 0; if (eLength2->IntValue > pw / 2.0) Ell_ry = eLength2->IntValue; else if(eLength2->IntValue == 0) Ell_ry = 0; break; case uInch : if (eLength1->Value * MainImageForm->CanvasInfor.DotsPerInch + 0.5 > pw / 2.0) { Ell_rx = eLength1->Value * MainImageForm->CanvasInfor.DotsPerInch + 0.5; }else if(eLength1->IntValue == 0) Ell_rx = 0; if (eLength2->Value * MainImageForm->CanvasInfor.DotsPerInch + 0.5 > pw / 2.0) { Ell_ry = eLength2->Value * MainImageForm->CanvasInfor.DotsPerInch + 0.5; }else if(eLength2->IntValue == 0) Ell_ry = 0; break; case uCm : if (eLength1->Value * MainImageForm->CanvasInfor.DotsPerInch / 2.54 + 0.5 > pw / 2.0) { Ell_rx = eLength1->Value * MainImageForm->CanvasInfor.DotsPerInch / 2.54 + 0.5; }else if(eLength1->IntValue == 0) Ell_rx = 0; if (eLength2->Value * MainImageForm->CanvasInfor.DotsPerInch / 2.54 + 0.5 > pw / 2.0) { Ell_ry = eLength2->Value * MainImageForm->CanvasInfor.DotsPerInch / 2.54 + 0.5; }else if(eLength2->IntValue == 0) Ell_ry = 0; } // isw = 2; isNumberInput = true; // by celberus x = Image->uBitmap->Width * Image->uBitmap->Width; y = Image->uBitmap->Height * Image->uBitmap->Height; if (Ell_rx > sqrt(x + y)) { Ell_rx = sqrt(x + y); } if (Ell_ry > sqrt(x + y)) { Ell_ry = sqrt(x + y); } } } else if (Item == TD_SQUR) { // if (isw == 1) { if (hasUserLength && !isNumberInput) { // by celberus switch (MainImageForm->CurrentUnit) { case uDot : if (eLength1->IntValue > pw) Sqr_l = eLength1->IntValue; else if(eLength1->IntValue == 0) Sqr_l = 0; break; case uInch : if (eLength1->Value * MainImageForm->CanvasInfor.DotsPerInch + 0.5 > pw) { Sqr_l = eLength1->Value * MainImageForm->CanvasInfor.DotsPerInch + 0.5; }else if(eLength1->IntValue == 0) Sqr_l = 0; break; case uCm : if (eLength1->Value / 2.54 * MainImageForm->CanvasInfor.DotsPerInch + 0.5 > pw) { Sqr_l = eLength1->Value / 2.54 * MainImageForm->CanvasInfor.DotsPerInch + 0.5; }else if(eLength1->IntValue == 0) Sqr_l = 0; } // Á¤»ç°¢ÇüÀ϶§¿¡µµ ±æÀÌ Ç¥Çö eLength2->Value = eLength1->Value; // isw = 2; isNumberInput = true; // by celberus if (Sqr_l > Image->uBitmap->Width) Sqr_l = Image->uBitmap->Width; if (Sqr_l > Image->uBitmap->Height) Sqr_l = Image->uBitmap->Height; } } else if (Item == TD_RECT) { // if (isw == 1) { if (hasUserLength && !isNumberInput) { // by celberus switch (MainImageForm->CurrentUnit) { case uDot : if (eLength1->IntValue > pw) Rec_lx = eLength1->IntValue; else if(eLength1->IntValue == 0) Rec_lx = 0; if (eLength2->IntValue > pw) Rec_ly = eLength2->IntValue; else if(eLength2->IntValue == 0) Rec_ly = 0; break; case uInch : if (eLength1->Value * MainImageForm->CanvasInfor.DotsPerInch + 0.5 > pw) { Rec_lx = eLength1->Value * MainImageForm->CanvasInfor.DotsPerInch + 0.5; }else if(eLength1->Value == 0){ Rec_lx = 0; } if (eLength2->Value * MainImageForm->CanvasInfor.DotsPerInch + 0.5 > pw) { Rec_ly = eLength2->Value * MainImageForm->CanvasInfor.DotsPerInch + 0.5; }else if(eLength2->Value == 0){ Rec_ly = 0; } break; case uCm : if (eLength1->Value / 2.54 * MainImageForm->CanvasInfor.DotsPerInch + 0.5 > pw) { Rec_lx = eLength1->Value / 2.54 * MainImageForm->CanvasInfor.DotsPerInch + 0.5; }else if(eLength1->Value == 0){ Rec_lx = 0; } if (eLength2->Value / 2.54 * MainImageForm->CanvasInfor.DotsPerInch + 0.5 > pw) { Rec_ly = eLength2->Value / 2.54 * MainImageForm->CanvasInfor.DotsPerInch + 0.5; }else if(eLength2->Value == 0){ Rec_ly = 0; } } // isw = 2; isNumberInput = true; // by celberus if (Rec_lx > Image->uBitmap->Width) Rec_lx = Image->uBitmap->Width; if (Rec_ly > Image->uBitmap->Height) Rec_ly = Image->uBitmap->Height; } } else if (Item == TD_LINE) { if (Asw == 1) { ang = eAngle->Value; ang %= 90; Line_angle = ang; Asw = 2; } if (Lsw == 1) { len = eLength1->Value; switch (MainImageForm->CurrentUnit) { case uDot : Line_len = len - pw; break; case uInch : Line_len = len * MainImageForm->CanvasInfor.DotsPerInch - pw; break; case uCm : Line_len = len * MainImageForm->CanvasInfor.DotsPerInch / 2.54 - pw ; } if (Line_len >= 0) { if (Line_len > sqrt(Image->uBitmap->Width * Image->uBitmap->Width + Image->uBitmap->Height * Image->uBitmap->Height)) { Line_len = sqrt(Image->uBitmap->Width * Image->uBitmap->Width + Image->uBitmap->Height * Image->uBitmap->Height); } Lsw = 2; } else Lsw = 0; } } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::Line(COLORREF fc) { BEGIN_LOG("Draw_F"); MainImageForm->line_pen(Lsx, Lsy, Lex, Ley, fc); END_LOG; } //---------------------------------------------------------------------------//k3dogs void __fastcall TDrawForm::TaperLine(int s_size, int e_size, double s_rate, double e_rate, COLORREF fc) { BEGIN_LOG("Draw_F"); double p; int lx, ly, dx, dy; fc = PaletteForm->DIB256Palette->ChoiceIndex; //k3dogs 20010208 PenManagerForm::point_pressure_pen()¿¡¼­ ¿¡·¯°¡ ³ª¼­¸®.. if ( s_rate < 0 ) s_rate = 0; else if ( s_rate > 1 ) s_rate = 1; if ( e_rate < 0 ) e_rate = 0; else if ( e_rate > 1 ) e_rate = 1; //============================================================================= lhskys Taper ¿¡¼­ °¢µµ °è»ê if ((Item == TD_LINE) && (Ltype[Item].sw == 0)) { dx = Lex - Lsx; dy = Ley - Lsy; if (dy < 0) { p = (atan2((double)dy, (double)dx) + 2 * M_PI) * 180.0 / M_PI; } else { if ((dx == 0) && (dy == 0)) p = 0; else p = atan2((double)dy, (double)dx) * 180.0 / M_PI; } eAngle->Value = p; //Format("%3.1f", OPENARRAY(TVarRec, (p))); lx = abs(dx); ly = abs(dy); p = sqrt(lx * lx + ly * ly) + PenManagerForm->Pen->BasicThick; } switch (MainImageForm->CurrentUnit) { case uDot : eLength1->Value = p; break; case uInch: eLength1->Value = p / MainImageForm->CanvasInfor.DotsPerInch;//Format("%.2f", OPENARRAY(TVarRec, (p / MainImageForm->CanvasInfor.DotsPerInch))); break; case uCm : eLength1->Value = p / MainImageForm->CanvasInfor.DotsPerInch * 2.54;//Format("%.2f", OPENARRAY(TVarRec, (p / MainImageForm->CanvasInfor.DotsPerInch * 2.54))); } //============================================================================== PenManagerForm->update=false; PenManagerForm->DrawTaperLine(Lsx, Lsy, Lex, Ley, s_size, e_size, s_rate, e_rate, fc); PenManagerForm->update=true; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::outline_pen(TPBitmap *op, int sx, int sy) { BEGIN_LOG("Draw_F"); int i, j, x, y, r, pw; Byte c; Byte *OP, *BP, *LP; TPItemImage *Image = MainImageForm->iMainImage; c = PaletteForm->DIB256Palette->ChoiceIndex; pw = PenManagerForm->Pen->BasicThick; x = sx - 40; y = sy - 40; r = pw - 1; if (Image->LayerMask) { for (i = 40 - r; i <= 40 + r; i++) { if ((y + i >= 0) && (y + i < Image->uBitmap->Height)) { BP = Image->uBitmap->GetScanLineN(y + i, 1); LP = Image->LayerMask->GetScanLineN(y + i, 1); OP = op->ScanLine(i); for (j = 40 - r; j <= 40 + r; j++) { if ((x + j >= 0) && (x + j < Image->uBitmap->Width)) { if ((OP[j] == 0xFF) && ((BP[x + j] == 0xFF) || (BP[x + j] == 0xFE))) { BP[x + j] = c; LP[x + j] = 0; } } } Image->LayerMask->PutScanLineN(y + i, sx-r ,2*r+1, 1); //by linuxjun Image->uBitmap->PutScanLineN(y + i, sx-r ,2*r+1, 1); //by linuxjun } } } else { for (i = 40 - r; i <= 40 + r; i++) { if ((y + i >= 0) && (y + i < Image->uBitmap->Height)) { BP = Image->uBitmap->GetScanLineN(y + i, 1); OP = op->ScanLine(i); for (j = 40 - r; j <= 40 + r; j++) { if ((x + j >= 0) && (x + j < Image->uBitmap->Width)) { if ((OP[j] == 0xFF) && ((BP[x + j] == 0xFF) || (BP[x + j] == 0xFE))) { BP[x + j] = c; } } } Image->uBitmap->PutScanLineN(y + i, sx-r ,2*r+1, 1); //by linuxjun } } } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::outlinemask_pen(TPBitmap *op, int sx, int sy) { BEGIN_LOG("Draw_F"); int i, j, x, y, r, pw; Byte *OP, *BP, *MP; TPItemImage *Image = MainImageForm->iMainImage; pw = PenManagerForm->Pen->BasicThick; x = sx - 40; y = sy - 40; r = pw - 1; for (i = 40 - r; i <= 40 + r; i++) { if ((y + i >= 0) && (y + i < Image->uBitmap->Height)) { BP = Image->uBitmap->GetScanLineN(y + i, 1); MP = Image->Mask->GetScanLineN(y + i, 1); OP = op->ScanLine(i); for (j = 40 - r; j <= 40 + r; j++) { if ((x + j >= 0) && (x + j < Image->uBitmap->Width)) { if ((OP[j] == 0xFF) && ((BP[x + j] == 0xFF) || (BP[x + j] == 0xFE))) { MP[x + j] = MainImageForm->MaskPixel; } } } Image->Mask->PutScanLineN(y + i, sx-r ,2*r+1, 1); //by linuxjun } } END_LOG; } //--------------------------------------------------------------------------- bool __fastcall TDrawForm::OutRead_none(Byte *p, int x) { return *(p + x) == (Byte)OutColor; } //---------------------------------------------------------------------------- bool __fastcall TDrawForm::OutRead_layer_zero(Byte *p, Byte *lp, int x) { return (*(p + x) == (Byte)OutColor) && (*(lp + x) == 0); } //---------------------------------------------------------------------------- bool __fastcall TDrawForm::OutRead_layer_nonezero(Byte *p, Byte *lp, int x) { return (*(p + x) == (Byte)OutColor) && (*(lp + x) == 0xFF); } //---------------------------------------------------------------------------- void __fastcall TDrawForm::OutSave(Byte *p, int x) { *(p + x) = 0xFF; } //--------------------------------------------------------------------------- bool __fastcall TDrawForm::OutRead_none24(Byte *p, int x) { COLORREF c; p += 3*x; GetPixel24(p, c); return c == OutColor; } //--------------------------------------------------------------------------- bool __fastcall TDrawForm::OutRead_layer24_zero(Byte *p, Byte *lp, int x) { COLORREF c; p += 3*x; GetPixel24(p, c); return (c == OutColor) && ((lp[x >> 3] & (0x80 >> (x & 7))) == 0); } //--------------------------------------------------------------------------- bool __fastcall TDrawForm::OutRead_layer24_nonezero(Byte *p, Byte *lp, int x) { COLORREF c; p += 3*x; GetPixel24(p, c); return (c == OutColor) && ((lp[x >> 3] & (0x80 >> (x & 7))) != 0); } //--------------------------------------------------------------------------- void __fastcall TDrawForm::outline_pen_24(TPBitmap *op, TPBitmap *mask, int sx, int sy, COLORREF dc) { BEGIN_LOG("Draw_F"); int i, j, x, y, r, pw; Byte *OP, *MP, *BBP, *LP; TPItemImage *Image = MainImageForm->iMainImage; pw = PenManagerForm->Pen->BasicThick; x = sx - 40; y = sy - 40; r = pw - 1; if (Image->LayerMask) { for (i = 40 - r; i <= 40 + r; i++) { if ((y + i >= 0) && (y + i < Image->uBitmap->Height)) { BBP = Image->uBitmap->GetScanLineN(y + i, 1) + 3*(x+(40-r)); LP = Image->LayerMask->GetScanLine(y + i); MP = mask->ScanLine(y + i); OP = op->ScanLine(i); for (j = 40 - r; j <= 40 + r; j++, BBP += 3) { if ((x + j >= 0) && (x + j < Image->uBitmap->Width)) { if ((OP[j] == 0xFF) && (*(MP + ((x+j) >> 3)) & (0x80 >> ((x+j) & 7)))) { SetPixel24(BBP, dc); LP[(x + j) >> 3] &= ~(0x80 >> ((x + j) & 7)); } } } Image->LayerMask->PutScanLine(y + i, sx-r ,2*r+1 ); //by linuxjun Image->uBitmap->PutScanLineN(y + i, sx-r ,2*r+1, 1); //by linuxjun } } } else { for (i = 40 - r; i <= 40 + r; i++) { if ((y + i >= 0) && (y + i < Image->uBitmap->Height)) { BBP = Image->uBitmap->GetScanLineN(y + i, 1) + 3*(x+(40-r)); MP = mask->ScanLine(y + i); OP = op->ScanLine(i); for (j = 40 - r; j <= 40 + r; j++, BBP += 3) { if ((x + j >= 0) && (x + j < Image->uBitmap->Width)) { if ((OP[j] == 0xFF) && (*(MP + ((x+j) >> 3)) & (0x80 >> ((x+j) & 7)))) { SetPixel24(BBP, dc); } } } Image->uBitmap->PutScanLineN(y + i, sx-r ,2*r+1 , 1); //by linuxjun } } } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::outlinemask_pen_24(TPBitmap *op, TPBitmap *mask, int sx, int sy) { BEGIN_LOG("Draw_F"); int i, j, x, y, r, pw; Byte *OP, *MP, *BBP; TPItemImage *Image = MainImageForm->iMainImage; pw = PenManagerForm->Pen->BasicThick; x = sx - 40; y = sy - 40; r = pw - 1; for (i = 40 - r; i <= 40 + r; i++) { if ((y + i >= 0) && (y + i < Image->uBitmap->Height)) { BBP = Image->Mask->GetScanLineN(y + i, 1); MP = mask->ScanLine(y + i); OP = op->ScanLine(i); for (j = 40 - r; j <= 40 + r; j++) { if ((x + j >= 0) && (x + j < Image->uBitmap->Width)) { if ((OP[j] == 0xFF) && (*(MP + ((x+j) >> 3)) & (0x80 >> ((x+j) & 7)))) { BBP[(x + j) >> 3] |= MainImageForm->MaskPixel >> ((x + j) & 7); } } } Image->Mask->PutScanLineN(y + i, sx-r ,2*r+1 , 1); //by linuxjun } } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::outlinemaskdelete_pen_24(TPBitmap *op, TPBitmap *mask, int sx, int sy) { BEGIN_LOG("Draw_F"); int i, j, x, y, r, pw; Byte *OP, *MP, *BBP; TPItemImage *Image = MainImageForm->iMainImage; pw = PenManagerForm->Pen->BasicThick; x = sx - 40; y = sy - 40; r = pw - 1; for (i = 40 - r; i <= 40 + r; i++) { if ((y + i >= 0) && (y + i < Image->uBitmap->Height)) { BBP = Image->Mask->GetScanLineN(y + i, 1); MP = mask->ScanLine(y + i); OP = op->ScanLine(i); for (j = 40 - r; j <= 40 + r; j++) { if ((x + j >= 0) && (x + j < Image->uBitmap->Width)) { if ((OP[j] == 0xFF) && (*(MP + ((x+j) >> 3)) & (0x80 >> ((x+j) & 7)))) { BBP[(x + j) >> 3] &= ~(0x80 >> ((x + j) & 7)); } } } Image->Mask->PutScanLineN(y + i, sx-r ,2*r+1 , 1); //by linuxjun } } END_LOG; } //---------------------------------------------------------------------------- bool __fastcall TDrawForm::outline_24(int XD, int YD) { BEGIN_LOG("Draw_F"); int x, y, sx, sy, ex, ey, a, pw, r1, tx, ty, wid, hei, code, i; TPException ec; Extended sqr_x, sqr_y, r; TPoint max, min, size; TPoint *sp = 0, *now = 0; TList *stack = NULL; TCursor OldCursor; COLORREF crrf; Byte *OP = 0, *BP = 0, *NBP = 0, *PBP = 0, *MP = 0, mm; TRect rect; TPBitmap *outpen = NULL, *MaskFF = NULL, *MaskFE = NULL, *MaskFD = NULL; TPItemImage *Image = MainImageForm->iMainImage; // -1- fill¿µ¿ª ±¸Çϱâ if ((MaskFF = new TPBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } OldCursor = Screen->Cursor; Screen->Cursor = crHourGlass; fillstart = Point(XD, YD); OutColor = Image->uBitmap->GetPixelColor(XD, YD); size = Point(Image->uBitmap->Width, Image->uBitmap->Height); if (Image->LayerMask) { if (Image->LayerMask->GetPixelColor(XD, YD)) { if (!(Image->FloodFillMask(fillstart, OutRead_layer24_nonezero, NULL, rect, MaskFF))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if (!(Image->FloodFillMask(fillstart, OutRead_layer24_zero, NULL, rect, MaskFF))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } } else { if (!(Image->uBitmap->FloodFillMask(fillstart, OutRead_none24, NULL, rect, MaskFF))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } min.x = rect.Left; max.x = rect.Right; min.y = rect.Top; max.y = rect.Bottom; if (min.x > 0) sx = min.x; else sx = 1; if (max.x < size.x - 1) ex = max.x; else ex = size.x - 2; if (min.y > 0) sy = min.y; else sy = 1; if (max.y < size.y - 1) ey = max.y; else ey = size.y - 2; // -2- MaskFF¿¡¼­ color °æ°è¼± MaskFE ¸¸µé±â. wid = ex - sx + 3; hei = ey - sy + 3; if ((MaskFE = new TPBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!(MaskFE->Create(wid, hei, 1))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((MaskFD = new TPBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!(MaskFD->Create(wid, hei, 1))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MaskFF->Lock() == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MaskFE->Lock() == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = sy; y <= ey; y++) { BP = MaskFF->ScanLine(y); NBP = MaskFF->ScanLine(y - 1); PBP = MaskFF->ScanLine(y + 1); MP = MaskFE->ScanLine(y - sy); x=sx; mm=0x80; while(1) { if (*(BP + (x >> 3)) & (0x80 >> (x & 7))) { if (!(*(BP + ((x-1) >> 3)) & (0x80 >> ((x-1) & 7))) || !(*(BP + ((x+1) >> 3)) & (0x80 >> ((x+1) & 7))) || !(*(NBP + (x >> 3)) & (0x80 >> (x & 7))) || !(*(PBP + (x >> 3)) & (0x80 >> (x & 7)))) { *MP |= mm; } } x++; if(x > ex) break; if (mm == 1) { MP++; mm = 0x80; *MP = 0; } else mm >>= 1; } } MaskFF->Unlock(); // -3- Search the nearest point from StartPoint. tx = fillstart.x - sx; ty = fillstart.y - sy; code = 1; r = 0.0; while (code == 1) { for (i = 0; i <= 0.75 * r; i++) { x = tx + i; sqr_x = (r * r) - ((tx - x) * (tx - x)); y = ty + sqrt(sqr_x); if ((x >= 0) && (x < wid) && (y >= 0) && (y < hei)) { BP = MaskFE->ScanLine(y); if (*(BP + (x >> 3)) & (0x80 >> (x & 7))) { code = 0; break; } } x = tx - i; if ((x >= 0) && (x < wid) && (y >= 0) && (y < hei)) { BP = MaskFE->ScanLine(y); if (*(BP + (x >> 3)) & (0x80 >> (x & 7))) { code = 0; break; } } x = tx + i; y = ty - sqrt(sqr_x); if ((x >= 0) && (x < wid) && (y >= 0) && (y < hei)) { BP = MaskFE->ScanLine(y); if (*(BP + (x >> 3)) & (0x80 >> (x & 7))) { code = 0; break; } } x = tx - i; if ((x >= 0) && (x < wid) && (y >= 0) && (y < hei)) { BP = MaskFE->ScanLine(y); if (*(BP + (x >> 3)) & (0x80 >> (x & 7))) { code = 0; break; } } y = ty + i; sqr_y = (r * r) - ((ty - y) * (ty - y)); x = tx + sqrt(sqr_y); if ((x >= 0) && (x < wid) && (y >= 0) && (y < hei)) { BP = MaskFE->ScanLine(y); if (*(BP + (x >> 3)) & (0x80 >> (x & 7))) { code = 0; break; } } y = ty - i; if ((x >= 0) && (x < wid) && (y >= 0) && (y < hei)) { BP = MaskFE->ScanLine(y); if (*(BP + (x >> 3)) & (0x80 >> (x & 7))) { code = 0; break; } } y = ty + i; x = tx - sqrt(sqr_y); if ((x >= 0) && (x < wid) && (y >= 0) && (y < hei)) { BP = MaskFE->ScanLine(y); if (*(BP + (x >> 3)) & (0x80 >> (x & 7))) { code = 0; break; } } y = ty - i; if ((x>=0) && (x < wid) && (y >= 0) && (y < hei)) { BP = MaskFE->ScanLine(y); if (*(BP + (x >> 3)) & (0x80 >> (x & 7))) { code = 0; break; } } if ((r > wid) && (r > hei)) { ec = EC_NO_TARGET; goto fail; } r = r + 1; } } // -4- MaskFE¿¡¼­ Ãֿܰû¼± ÃßÃâµÈ MaskFD ¸¸µé±â. if (MaskFD->Lock() == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } MaskFD->Fill(0); now = new TPoint; now->x = x; now->y = y; MP = MaskFD->ScanLine(now->y); *(MP + (now->x >> 3)) |= (0x80 >> (now->x & 7)); if ((stack = new TList) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } stack->Add(now); while (stack->Count) { sp = (TPoint *)(stack->Last()); stack->Remove(sp); sx = sp->x; sy = sp->y; if (sp) delete sp; sp = 0; for (y = sy-1; y <= sy+1; y++) { if (y >=0 && y < hei) { BP = MaskFE->ScanLine(y); MP = MaskFD->ScanLine(y); for (x = sx-1; x <= sx+1; x++) { if(y == sy && x == sx) continue; // by celberus if (x >=0 && x < wid) { now = new TPoint; if (*(BP + (x >> 3)) & (0x80 >> (x & 7))) { *(BP + (x >> 3)) &= ~(0x80 >> (x & 7)); *(MP + (x >> 3)) |= (0x80 >> (x & 7)); now->x = x; now->y = y; stack->Add(now); } else { if (now) delete now; now = 0; } } } } } } if (now) delete now; now =0; while (stack->Count) { sp = (TPoint *)(stack->Last()); stack->Remove(sp); if (sp) delete sp; sp = 0; } if (stack) delete stack; stack = NULL; MaskFD->Unlock(); if (MaskFE) delete MaskFE; MaskFE = NULL; // -5- PenMask ¸¸µé±â. if ((outpen = new TPBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!(outpen->Create(81, 81, 8))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (outpen->Lock() == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } pw = (PenManagerForm->Pen->BasicThick - 1) * 2 + 1; for (y = 0; y <= 80; y++) { OP = outpen->ScanLine(y); for (x = 0; x <= 80; x++) { OP[x] = 0x00; } } if (pw == 1) { OP = outpen->ScanLine(40); OP[40] = 0xFF; } else { if (PenManagerForm->Pen->Shape == 0) { r = pw / 2.0; r1 = r; for (y = 0; y <= r1; y++) { PBP = outpen->ScanLine(40 + y); NBP = outpen->ScanLine(40 - y); x = sqrt(r * r - y * y); for (a = 40 - x; a <= 40 + x; a++) { PBP[a] = 0xFF; NBP[a] = 0xFF; } } } else { r1 = 40 - pw / 2.0; for (y = r1; y <= r1 + pw - 1; y++) { OP = outpen->ScanLine(y); for (x = r1; x <= r1 + pw - 1; x++) { OP[x] = 0xFF; } } } } // -6- Image¿¡ OutLine ±¸ÇöÇϱâ. if (MaskFD->Lock() == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MaskFF->Lock() == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (PenManagerForm->sbMask->Down) { if (!(Image->Mask->StartScanLineN(2))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (PenManagerForm->rzckDelete->Checked) { for (y = min.y; y < max.y; y++) { PBP = Image->Mask->GetScanLine(y); MP = MaskFD->ScanLine(y - min.y); mm = 0x80; for (x = min.x; x < max.x; x++) { if (*MP & mm) { PBP[x >> 3] &= ~(0x80 >> (x & 7)); outlinemaskdelete_pen_24(outpen, MaskFF, x, y); } if (mm == 1) { MP++; mm = 0x80; } else mm >>=1; } Image->Mask->PutScanLine(y, min.x, max.x-min.x); //by linuxjun } } else { for (y = min.y; y < max.y; y++) { PBP = Image->Mask->GetScanLine(y); MP = MaskFD->ScanLine(y - min.y); mm = 0x80; for (x = min.x; x < max.x; x++) { if (*MP & mm) { PBP[x >> 3] |= MainImageForm->MaskPixel >> (x & 7); outlinemask_pen_24(outpen, MaskFF, x, y); } if (mm == 1) { MP++; mm = 0x80; } else mm >>=1; } Image->Mask->PutScanLine(y, min.x, max.x-min.x); } } Image->Mask->StopScanLine(); } else { if (Image->LayerMask) { if (!(Image->uBitmap->StartScanLineN(2))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!Image->LayerMask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } crrf = PaletteForm->DIB256Palette->GetFGCOLORREF(24); for (y = min.y; y < max.y; y++) { PBP = Image->uBitmap->GetScanLine(y) + 3*min.x; MP = MaskFD->ScanLine(y - min.y); mm = 0x80; for (x = min.x; x < max.x; x++, PBP += 3) { if (*MP & mm) { SetPixel24(PBP, crrf); outline_pen_24(outpen, MaskFF, x, y, crrf); } if (mm == 1) { MP++; mm = 0x80; } else mm >>=1; } Image->uBitmap->PutScanLine(y, min.x, max.x-min.x); } Image->LayerMask->StopScanLine(); Image->uBitmap->StopScanLine(); } else { if (!(Image->uBitmap->StartScanLineN(2))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } crrf = PaletteForm->DIB256Palette->GetFGCOLORREF(24); for (y = min.y; y < max.y; y++) { PBP = Image->uBitmap->GetScanLine(y) + 3*min.x; MP = MaskFD->ScanLine(y - min.y); mm = 0x80; for (x = min.x; x < max.x; x++, PBP += 3) { if (*MP & mm) { SetPixel24(PBP, crrf); outline_pen_24(outpen, MaskFF, x, y, crrf); } if (mm == 1) { MP++; mm = 0x80; } else mm >>=1; } Image->uBitmap->PutScanLine(y, min.x, max.x-min.x); } Image->uBitmap->StopScanLine(); } } if (outpen) delete outpen; if (MaskFD) delete MaskFD; if (MaskFF) delete MaskFF; //by jeegeo ::RepaintImage(); Screen->Cursor = OldCursor; END_LOG; return true; fail: if (outpen) delete outpen; if (MaskFE) delete MaskFE; if (MaskFD) delete MaskFD; if (MaskFF) delete MaskFF; if (Image->LayerMask) Image->LayerMask->StopScanLine(); Image->uBitmap->StopScanLine(); //Undo->Read(); //BeConverted by linuxjun Don't Forget!! Undo_Method MainImageForm->Undo->UndoRead(); //BeConverted by linuxjun Don't Forget!! Undo_Method Screen->Cursor = OldCursor; EXCEPTION_MESSAGE_OK(ec); END_LOG; return false; } //--------------------------------------------------------------------------- bool __fastcall TDrawForm::Reflection_outline_24(int XD, int YD) { BEGIN_LOG("Draw_F"); int x, y, sx, sy, ex, ey, a, pw, r1, tx, ty, wid, hei, code, i; TPException ec; Extended sqr_x, sqr_y, r; TPoint max, min, size; TPoint *sp = 0, *now = 0; TList *stack = NULL; TCursor OldCursor; COLORREF crrf; Byte *OP = 0, *BP = 0, *NBP = 0, *PBP = 0, *MP = 0, mm; TRect rect; TPBitmap *outpen = NULL, *MaskFF = NULL, *MaskFE = NULL, *MaskFD = NULL; TPItemImage *Image = MainImageForm->iMainImage; // -1- fill¿µ¿ª ±¸Çϱâ OldCursor = Screen->Cursor; Screen->Cursor = crHourGlass; POINT pt = MainImageForm->reflection->FindOriginalPos(XD, YD); fillstart = Point(pt.x, pt.y); OutColor = Image->uBitmap->GetPixelColor(pt.x, pt.y); size = Point(MainImageForm->reflection->BitmapWidth, MainImageForm->reflection->BitmapHeight); TRect range; range.left = MainImageForm->reflection->BitmapRange.left; range.top = MainImageForm->reflection->BitmapRange.top; range.right = MainImageForm->reflection->BitmapRange.right; range.bottom = MainImageForm->reflection->BitmapRange.bottom; if ((MaskFF = new TPBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Image->LayerMask) { if (Image->LayerMask->GetPixelColor(pt.x, pt.y)) { if (!(Image->FloodFillMask(fillstart, OutRead_layer24_nonezero, NULL, rect, MaskFF, &range))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if (!(Image->FloodFillMask(fillstart, OutRead_layer24_zero, NULL, rect, MaskFF, &range))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } } else { if (!(Image->uBitmap->FloodFillMask(fillstart, OutRead_none24, NULL, rect, MaskFF, &range))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } min.x = rect.Left; max.x = rect.Right; min.y = rect.Top; max.y = rect.Bottom; sx = min.x; sy = min.y; ex = max.x; ey = max.y; if (min.x > range.Left) sx = min.x; else sx = range.Left + 1; if (max.x < size.x + range.Left - 1) ex = max.x; else ex = size.x + range.Left - 2; if (min.y > range.Top) sy = min.y; else sy = range.Top + 1; if (max.y < size.y + range.Top - 1) ey = max.y; else ey = size.y + range.Top - 2; // -2- MaskFF¿¡¼­ color °æ°è¼± MaskFE ¸¸µé±â. wid = ex - sx + 3; hei = ey - sy + 3; if ((MaskFE = new TPBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!(MaskFE->Create(wid, hei, 1))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((MaskFD = new TPBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!(MaskFD->Create(wid, hei, 1))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MaskFF->Lock() == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MaskFE->Lock() == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = sy; y <= ey; y++) { BP = MaskFF->ScanLine(y); NBP = MaskFF->ScanLine(y - 1); PBP = MaskFF->ScanLine(y + 1); MP = MaskFE->ScanLine(y - sy); x=sx; mm=0x80; while(1) { if (*(BP + (x >> 3)) & (0x80 >> (x & 7))) { if (!(*(BP + ((x-1) >> 3)) & (0x80 >> ((x-1) & 7))) || !(*(BP + ((x+1) >> 3)) & (0x80 >> ((x+1) & 7))) || !(*(NBP + (x >> 3)) & (0x80 >> (x & 7))) || !(*(PBP + (x >> 3)) & (0x80 >> (x & 7)))) { *MP |= mm; } } x++; if(x > ex) break; if (mm == 1) { MP++; mm = 0x80; *MP = 0; } else mm >>= 1; } } MaskFF->Unlock(); // -3- Search the nearest point from StartPoint. tx = fillstart.x - sx; ty = fillstart.y - sy; code = 1; r = 0.0; while (code == 1) { for (i = 0; i <= 0.75 * r; i++) { x = tx + i; sqr_x = (r * r) - ((tx - x) * (tx - x)); y = ty + sqrt(sqr_x); if ((x >= 0) && (x < wid) && (y >= 0) && (y < hei)) { BP = MaskFE->ScanLine(y); if (*(BP + (x >> 3)) & (0x80 >> (x & 7))) { code = 0; break; } } x = tx - i; if ((x >= 0) && (x < wid) && (y >= 0) && (y < hei)) { BP = MaskFE->ScanLine(y); if (*(BP + (x >> 3)) & (0x80 >> (x & 7))) { code = 0; break; } } x = tx + i; y = ty - sqrt(sqr_x); if ((x >= 0) && (x < wid) && (y >= 0) && (y < hei)) { BP = MaskFE->ScanLine(y); if (*(BP + (x >> 3)) & (0x80 >> (x & 7))) { code = 0; break; } } x = tx - i; if ((x >= 0) && (x < wid) && (y >= 0) && (y < hei)) { BP = MaskFE->ScanLine(y); if (*(BP + (x >> 3)) & (0x80 >> (x & 7))) { code = 0; break; } } y = ty + i; sqr_y = (r * r) - ((ty - y) * (ty - y)); x = tx + sqrt(sqr_y); if ((x >= 0) && (x < wid) && (y >= 0) && (y < hei)) { BP = MaskFE->ScanLine(y); if (*(BP + (x >> 3)) & (0x80 >> (x & 7))) { code = 0; break; } } y = ty - i; if ((x >= 0) && (x < wid) && (y >= 0) && (y < hei)) { BP = MaskFE->ScanLine(y); if (*(BP + (x >> 3)) & (0x80 >> (x & 7))) { code = 0; break; } } y = ty + i; x = tx - sqrt(sqr_y); if ((x >= 0) && (x < wid) && (y >= 0) && (y < hei)) { BP = MaskFE->ScanLine(y); if (*(BP + (x >> 3)) & (0x80 >> (x & 7))) { code = 0; break; } } y = ty - i; if ((x >= 0) && (x < wid) && (y >= 0) && (y < hei)) { BP = MaskFE->ScanLine(y); if (*(BP + (x >> 3)) & (0x80 >> (x & 7))) { code = 0; break; } } if ((r > wid) && (r > hei)) { ec = EC_NO_TARGET; goto fail; } r = r + 1; } } // -4- MaskFE¿¡¼­ Ãֿܰû¼± ÃßÃâµÈ MaskFD ¸¸µé±â. if (MaskFD->Lock() == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } MaskFD->Fill(0); now = new TPoint; now->x = x; now->y = y; MP = MaskFD->ScanLine(now->y); *(MP + (now->x >> 3)) |= (0x80 >> (now->x & 7)); if ((stack = new TList) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } stack->Add(now); while (stack->Count) { sp = (TPoint *)(stack->Last()); stack->Remove(sp); sx = sp->x; sy = sp->y; if (sp) { delete sp; sp = NULL; } for (y = sy-1; y <= sy+1; y++) { if (y >=0 && y < hei) { BP = MaskFE->ScanLine(y); MP = MaskFD->ScanLine(y); for (x = sx-1; x <= sx+1; x++) { if(y == sy && x == sx) continue; // by celberus if (x >=0 && x < wid) { TPoint *nowp = new TPoint; if (*(BP + (x >> 3)) & (0x80 >> (x & 7))) { *(BP + (x >> 3)) &= ~(0x80 >> (x & 7)); *(MP + (x >> 3)) |= (0x80 >> (x & 7)); nowp->x = x; nowp->y = y; stack->Add(nowp); } else { if (nowp) { delete nowp; nowp = NULL; } } } } } } } //if (now) { delete now; now = NULL; } while (stack->Count) { sp = (TPoint *)(stack->Last()); stack->Remove(sp); if (sp) delete sp; sp = 0; } if (stack) delete stack; stack = NULL; MaskFD->Unlock(); if (MaskFE) delete MaskFE; MaskFE = NULL; // -5- PenMask ¸¸µé±â. if ((outpen = new TPBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!(outpen->Create(81, 81, 8))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (outpen->Lock() == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } pw = (PenManagerForm->Pen->BasicThick - 1) * 2 + 1; for (y = 0; y <= 80; y++) { OP = outpen->ScanLine(y); for (x = 0; x <= 80; x++) { OP[x] = 0x00; } } if (pw == 1) { OP = outpen->ScanLine(40); OP[40] = 0xFF; } else { if (PenManagerForm->Pen->Shape == 0) { r = pw / 2.0; r1 = r; for (y = 0; y <= r1; y++) { PBP = outpen->ScanLine(40 + y); NBP = outpen->ScanLine(40 - y); x = sqrt(r * r - y * y); for (a = 40 - x; a <= 40 + x; a++) { PBP[a] = 0xFF; NBP[a] = 0xFF; } } } else { r1 = 40 - pw / 2.0; for (y = r1; y <= r1 + pw - 1; y++) { OP = outpen->ScanLine(y); for (x = r1; x <= r1 + pw - 1; x++) { OP[x] = 0xFF; } } } } // -6- Image¿¡ OutLine ±¸ÇöÇϱâ. if (MaskFD->Lock() == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MaskFF->Lock() == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (PenManagerForm->sbMask->Down) { if (!(Image->Mask->StartScanLineN(2))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (PenManagerForm->rzckDelete->Checked) { for (y = min.y; y < max.y; y++) { PBP = Image->Mask->GetScanLine(y); MP = MaskFD->ScanLine(y - min.y); mm = 0x80; for (x = min.x; x < max.x; x++) { if (*MP & mm) { PBP[x >> 3] &= ~(0x80 >> (x & 7)); outlinemaskdelete_pen_24(outpen, MaskFF, x, y); } if (mm == 1) { MP++; mm = 0x80; } else mm >>=1; } Image->Mask->PutScanLine(y, min.x, max.x-min.x); //by linuxjun } } else { for (y = min.y; y < max.y; y++) { PBP = Image->Mask->GetScanLine(y); MP = MaskFD->ScanLine(y - min.y); mm = 0x80; for (x = min.x; x < max.x; x++) { if (*MP & mm) { PBP[x >> 3] |= MainImageForm->MaskPixel >> (x & 7); outlinemask_pen_24(outpen, MaskFF, x, y); } if (mm == 1) { MP++; mm = 0x80; } else mm >>=1; } Image->Mask->PutScanLine(y, min.x, max.x-min.x); } } Image->Mask->StopScanLine(); } else { if (Image->LayerMask) { if (!(Image->uBitmap->StartScanLineN(2))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!Image->LayerMask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } crrf = PaletteForm->DIB256Palette->GetFGCOLORREF(24); for (y = min.y; y < max.y; y++) { PBP = Image->uBitmap->GetScanLine(y) + 3*min.x; MP = MaskFD->ScanLine(y - min.y); mm = 0x80; for (x = min.x; x < max.x; x++, PBP += 3) { if (*MP & mm) { SetPixel24(PBP, crrf); outline_pen_24(outpen, MaskFF, x, y, crrf); } if (mm == 1) { MP++; mm = 0x80; } else mm >>=1; } Image->uBitmap->PutScanLine(y, min.x, max.x-min.x); } Image->LayerMask->StopScanLine(); Image->uBitmap->StopScanLine(); } else { if (!(Image->uBitmap->StartScanLineN(2))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } crrf = PaletteForm->DIB256Palette->GetFGCOLORREF(24); for (y = min.y; y < max.y; y++) { PBP = Image->uBitmap->GetScanLine(y) + 3*min.x; MP = MaskFD->ScanLine(y - min.y); mm = 0x80; for (x = min.x; x < max.x; x++, PBP += 3) { if (*MP & mm) { SetPixel24(PBP, crrf); outline_pen_24(outpen, MaskFF, x, y, crrf); } if (mm == 1) { MP++; mm = 0x80; } else mm >>=1; } Image->uBitmap->PutScanLine(y, min.x, max.x-min.x); } Image->uBitmap->StopScanLine(); } } if (outpen) delete outpen; if (MaskFD) delete MaskFD; if (MaskFF) delete MaskFF; //by jeegeo ::RepaintImage(); Screen->Cursor = OldCursor; END_LOG; return true; fail: if (outpen) delete outpen; if (MaskFE) delete MaskFE; if (MaskFD) delete MaskFD; if (MaskFF) delete MaskFF; if (Image->LayerMask) Image->LayerMask->StopScanLine(); Image->uBitmap->StopScanLine(); //Undo->Read(); //BeConverted by linuxjun Don't Forget!! Undo_Method MainImageForm->Undo->UndoRead(); //BeConverted by linuxjun Don't Forget!! Undo_Method Screen->Cursor = OldCursor; EXCEPTION_MESSAGE_OK(ec); END_LOG; return false; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::outline(int XD, int YD) { BEGIN_LOG("Draw_F"); ///* //BeConverted by linuxjun Don't Forget!! Undo_Method RGBQUAD rgb[256]; int x, y, sx, sy, ex, ey, i, code, a, pw, r1; TPException ec; Extended sqr_x, sqr_y, r; TPoint max, min, size; TPoint *sp = 0, *now = 0; TList *stack = NULL; THistoryData *undo = NULL; TCursor OldCursor; TPBitmap *outpen = NULL; Byte c; Byte *OP = 0, *BP = 0, *LP = 0, *NBP = 0, *PBP = 0; TRect rect; TPItemImage *Image = MainImageForm->iMainImage; OldCursor = Screen->Cursor; Screen->Cursor = crHourGlass; fillstart = Point(XD, YD); OutColor = Image->uBitmap->GetPixelColor(XD, YD); size = Point(Image->uBitmap->Width, Image->uBitmap->Height); if (Image->LayerMask) { if (Image->LayerMask->GetPixelColor(XD, YD)) { Image->FloodFill(fillstart, OutRead_layer_nonezero, OutSave, rect); } else { Image->FloodFill(fillstart, OutRead_layer_zero, OutSave, rect); } } else { Image->uBitmap->FloodFill(fillstart, OutRead_none, OutSave, rect); } min.x = rect.Left; max.x = rect.Right; min.y = rect.Top; max.y = rect.Bottom; if (min.x > 0) sx = min.x; else sx = 1; if (max.x < size.x - 1) ex = max.x; else ex = size.x - 2; if (min.y > 0) sy = min.y; else sy = 1; if (max.y < size.y - 1) ey = max.y; else ey = size.y - 2; MainImageForm->Palette->ToRGBQUAD(rgb, 256); Image->uBitmap->PutColors(0, 256, rgb); if (!(Image->uBitmap->StartScanLineN(3))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = sy; y <= ey; y++) { BP = Image->uBitmap->GetScanLine(y); NBP = Image->uBitmap->GetScanLineN(y - 1, 1); PBP = Image->uBitmap->GetScanLineN(y + 1, 2); for (x = sx; x <= ex; x++) { if (BP[x] == 0xFF) { if (((BP[x - 1] & 0xFE) != 0xFE) || ((BP[x + 1] & 0xFE) != 0xFE) || ((NBP[x] & 0xFE) != 0xFE) || ((PBP[x] & 0xFE) != 0xFE)) { BP[x] = 0xFE; } } } Image->uBitmap->PutScanLine(y, sx, ex-sx+1); } x = fillstart.x; y = fillstart.y; code = 1; r = 0.0; while (code == 1) { for (i = 0; i <= 0.75 * r; i++) { x = fillstart.x + i; sqr_x = (r * r) - ((fillstart.x - x) * (fillstart.x - x)); y = fillstart.y + sqrt(sqr_x); if ((x >= 0) && (x < size.x) && (y >= 0) && (y < size.y)) { BP = Image->uBitmap->GetScanLine(y); if (BP[x] == 0xFE) { code = 0; break; } } x = fillstart.x - i; if ((x >= 0) && (x < size.x) && (y >= 0) && (y < size.y)) { BP = Image->uBitmap->GetScanLine(y); if (BP[x] == 0xFE) { code = 0; break; } } x = fillstart.x + i; y = fillstart.y - sqrt(sqr_x); if ((x >= 0) && (x < size.x) && (y >= 0) && (y < size.y)) { BP = Image->uBitmap->GetScanLine(y); if (BP[x] == 0xFE) { code = 0; break; } } x = fillstart.x - i; if ((x >= 0) && (x < size.x) && (y >= 0) && (y < size.y)) { BP = Image->uBitmap->GetScanLine(y); if (BP[x] == 0xFE) { code = 0; break; } } y = fillstart.y + i; sqr_y = (r * r) - ((fillstart.y - y) * (fillstart.y - y)); x = fillstart.x + sqrt(sqr_y); if ((x >= 0) && (x < size.x) && (y >= 0) && (y < size.y)) { BP = Image->uBitmap->GetScanLine(y); if (BP[x] == 0xFE) { code = 0; break; } } y = fillstart.y - i; if ((x >= 0) && (x < size.x) && (y >= 0) && (y < size.y)) { BP = Image->uBitmap->GetScanLine(y); if (BP[x] == 0xFE) { code = 0; break; } } y = fillstart.y + i; x = fillstart.x - sqrt(sqr_y); if ((x >= 0) && (x < size.x) && (y >= 0) && (y < size.y)) { BP = Image->uBitmap->GetScanLine(y); if (BP[x] == 0xFE) { code = 0; break; } } y = fillstart.y - i; if ((x>=0) && (x < size.x) && (y >= 0) && (y < size.y)) { BP = Image->uBitmap->GetScanLine(y); if (BP[x] == 0xFE) { code = 0; break; } } if ((r > size.x) && (r > size.y)) { ec = EC_NO_TARGET; goto fail; } r = r + 1; } } now = new TPoint; now->x = x; now->y = y; BP = Image->uBitmap->GetScanLine(now->y); BP[now->x] = 0xFD; Image->uBitmap->PutScanLine(now->y,now->x,1); //caution!!! if ((stack = new TList) == NULL){ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } stack->Add(now); while (stack->Count) { sp = (TPoint *)(stack->Last()); stack->Remove(sp); sx = sp->x; sy = sp->y; if (sp) delete sp; sp = 0; for (y = sy - 1; y <= sy + 1; y++) { if (y >= 0 && y < Image->uBitmap->Height) { BP = Image->uBitmap->GetScanLine(y, sx - 1, 3); for (x = sx - 1; x <= sx + 1; x++) { if(y == sy && x == sx) continue; if(x >= 0 && x < Image->uBitmap->Width) { now = new TPoint; now->x = x; now->y = y; if (BP[now->x] == 0xFE) { BP[now->x] = 0xFD; stack->Add(now); } else { if (now) delete now; now = 0; } } } Image->uBitmap->PutScanLine(y, sx - 1, 3); } } } if (now) delete now; now = 0; while (stack->Count) { sp = (TPoint *)(stack->Last()); stack->Remove(sp); if (sp) delete sp; sp = 0; } if (stack) delete stack; stack = NULL; if ((outpen = new TPBitmap) == NULL) {ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!(outpen->Create(81, 81, 8))) {ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (outpen->Lock() == NULL) {ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } pw = (PenManagerForm->Pen->BasicThick - 1) * 2 + 1; for (y = 0; y <= 80; y++) { OP = outpen->ScanLine(y); for (x = 0; x <= 80; x++) { OP[x] = 0x00; } } if (pw == 1) { OP = outpen->ScanLine(40); OP[40] = 0xFF; } else { if (PenManagerForm->Pen->Shape == 0) { r = pw / 2.0; r1 = r; for (y = 0; y <= r1; y++) { PBP = outpen->ScanLine(40 + y); NBP = outpen->ScanLine(40 - y); x = sqrt(r * r - y * y); for (a = 40 - x; a <= 40 + x; a++) { PBP[a] = 0xFF; NBP[a] = 0xFF; } } } else { r1 = 40 - pw / 2.0; for (y = r1; y <= r1 + pw; y++) { //for (y = r1; y <= r1 + pw - 1; y++) { OP = outpen->ScanLine(y); for (x = r1; x <= r1 + pw; x++) { //for (x = r1; x <= r1 + pw - 1; x++) { OP[x] = 0xFF; } } } } if (PenManagerForm->sbMask->Down) { Byte *MP = 0; if (!(Image->Mask->StartScanLineN(2))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = min.y; y < max.y; y++) { BP = Image->uBitmap->GetScanLine(y); MP = Image->Mask->GetScanLine(y); for (x = min.x; x < max.x; x++) { if (BP[x] == 0xFD) { MP[x] = MainImageForm->MaskPixel; outlinemask_pen(outpen, x, y); } } Image->Mask->PutScanLine(y, min.x, max.x-min.x); } if (outpen) delete outpen; outpen = NULL; ////////////////////////////////////////////////////////////////////// // if ((undo = Undo->Last) == NULL) { ec = EC_UNDO_NONE; goto fail; } //BeConverted by linuxjun Don't Forget!! Undo_Method if ((undo = MainImageForm->Undo->GetLast()) == NULL) { ec = EC_UNDO_NONE; goto fail; } //BeConverted by linuxjun Don't Forget!! Undo_Method MainImageForm->iMainImage->uBitmap->PartialUndo->LoadLast(undo->FromRgb); if (!(MainImageForm->iMainImage->uBitmap->StartUndoScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = min.y; y < max.y; y++) { BP = Image->uBitmap->GetScanLine(y); OP = MainImageForm->iMainImage->uBitmap->GetUndoScanLine(y); for (x = min.x; x < max.x; x++) { if ((BP[x] == 0xFF) || (BP[x] == 0xFE)) { BP[x] = OP[x]; } } Image->uBitmap->PutScanLine(y, min.x, max.x-min.x); } MainImageForm->iMainImage->uBitmap->StopUndoScanLine(); // undo->Complete(); ////////////////////////////////////////////////////////////////// Image->Mask->StopScanLine(); } else { if (Image->LayerMask) { c = PaletteForm->DIB256Palette->ChoiceIndex; Image->LayerMask->StartScanLineN(2); for (y = min.y; y < max.y; y++) { BP = Image->uBitmap->GetScanLine(y); LP = Image->LayerMask->GetScanLine(y); for (x = min.x; x < max.x; x++) { if (BP[x] == 0xFD) { BP[x] = c; LP[x] = 0; outline_pen(outpen, x, y); } } Image->uBitmap->PutScanLine(y, min.x, max.x-min.x); Image->LayerMask->PutScanLine(y, min.x, max.x-min.x); } Image->LayerMask->StopScanLine(); } else { c = PaletteForm->DIB256Palette->ChoiceIndex; for (y = min.y; y < max.y; y++) { BP = Image->uBitmap->GetScanLine(y); for (x = min.x; x < max.x; x++) { if (BP[x] == 0xFD) { BP[x] = c; outline_pen(outpen, x, y); } } Image->uBitmap->PutScanLine(y, min.x, max.x-min.x); } } if (outpen) delete outpen; outpen = NULL; // if ((undo = Undo->Last) == NULL) { ec = EC_UNDO_NONE; goto fail; } //BeConverted by linuxjun Don't Forget!! Undo_Method if ((undo = MainImageForm->Undo->GetLast()) == NULL) { ec = EC_UNDO_NONE; goto fail; } //BeConverted by linuxjun Don't Forget!! Undo_Method // if ((undo = MainImageForm->Undo->getLastUndoData())==NULL) { ec = EC_NONE; goto fail; } MainImageForm->iMainImage->uBitmap->PartialUndo->LoadLast(undo->FromRgb); // if ((undo = MainImageForm->Undo->GetLast()) == NULL) { ec = EC_UNDO_NONE; goto fail; } if (!(MainImageForm->iMainImage->uBitmap->StartUndoScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = min.y; y < max.y; y++) { BP = Image->uBitmap->GetScanLine(y); OP = MainImageForm->iMainImage->uBitmap->GetUndoScanLine(y); for (x = min.x; x < max.x; x++) { if ((BP[x] == 0xFF) || (BP[x] == 0xFE)) { BP[x] = OP[x]; } } Image->uBitmap->PutScanLine(y, min.x, max.x-min.x); } MainImageForm->iMainImage->uBitmap->StopUndoScanLine(); // undo->Complete(); ////////////////////////////////////////////////////////////////// // undo->Complete(); } //by jeegeo ::RepaintImage(); Image->uBitmap->StopScanLine(); Screen->Cursor = OldCursor; END_LOG; return; fail: if (outpen) delete outpen; if (Image->Mask) Image->Mask->StopScanLine(); // if (undo) undo->uBitmap->StopScanLine(); if (undo) MainImageForm->iMainImage->uBitmap->StopUndoScanLine(); Image->uBitmap->StopScanLine(); // Undo->Read(); ////BeConverted by linuxjun Don't Forget!! Undo_Method MainImageForm->Undo->UndoRead(); ////BeConverted by linuxjun Don't Forget!! Undo_Method Screen->Cursor = OldCursor; EXCEPTION_MESSAGE_OK(ec); END_LOG; //*/ } //--------------------------------------------------------------------------- void __fastcall TDrawForm::Reflection_outline(int XD, int YD) { BEGIN_LOG("Draw_F"); ///* //BeConverted by linuxjun Don't Forget!! Undo_Method RGBQUAD rgb[256]; int x, y, sx, sy, ex, ey, i, code, a, pw, r1; TPException ec; Extended sqr_x, sqr_y, r; TPoint max, min, size; TPoint *sp = 0, *now = 0; TList *stack = NULL; THistoryData *undo = NULL; TCursor OldCursor; TPBitmap *outpen = NULL; Byte c; Byte *OP = 0, *BP = 0, *LP = 0, *NBP = 0, *PBP = 0; TRect rect; TPItemImage *Image = MainImageForm->iMainImage; OldCursor = Screen->Cursor; Screen->Cursor = crHourGlass; POINT pt = MainImageForm->reflection->FindOriginalPos(XD, YD); fillstart = Point(pt.x, pt.y); OutColor = Image->uBitmap->GetPixelColor(pt.x, pt.y); size = Point(MainImageForm->reflection->BitmapWidth, MainImageForm->reflection->BitmapHeight); TRect range; range.left = MainImageForm->reflection->BitmapRange.left; range.top = MainImageForm->reflection->BitmapRange.top; range.right = MainImageForm->reflection->BitmapRange.right; range.bottom = MainImageForm->reflection->BitmapRange.bottom; if (Image->LayerMask) { if (Image->LayerMask->GetPixelColor(pt.x, pt.y)) { Image->FloodFill(fillstart, OutRead_layer_nonezero, OutSave, rect, &range); } else { Image->FloodFill(fillstart, OutRead_layer_zero, OutSave, rect, &range); } } else { Image->uBitmap->FloodFill(fillstart, OutRead_none, OutSave, rect, &range); } min.x = rect.Left; max.x = rect.Right; min.y = rect.Top; max.y = rect.Bottom; sx = min.x; sy = min.y; ex = max.x; ey = max.y; if (min.x > range.Left) sx = min.x; else sx = range.Left + 1; if (max.x < size.x + range.Left - 1) ex = max.x; else ex = size.x + range.Left - 2; if (min.y > range.Top) sy = min.y; else sy = range.Top + 1; if (max.y < size.y + range.Top - 1) ey = max.y; else ey = size.y + range.Top - 2; MainImageForm->Palette->ToRGBQUAD(rgb, 256); Image->uBitmap->PutColors(0, 256, rgb); if (!(Image->uBitmap->StartScanLineN(3))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = sy; y <= ey; y++) { BP = Image->uBitmap->GetScanLine(y); NBP = Image->uBitmap->GetScanLineN(y - 1, 1); PBP = Image->uBitmap->GetScanLineN(y + 1, 2); for (x = sx; x <= ex; x++) { if (BP[x] == 0xFF) { if (((BP[x - 1] & 0xFE) != 0xFE) || ((BP[x + 1] & 0xFE) != 0xFE) || ((NBP[x] & 0xFE) != 0xFE) || ((PBP[x] & 0xFE) != 0xFE)) { BP[x] = 0xFE; } } } Image->uBitmap->PutScanLine(y, sx, ex-sx+1); } x = fillstart.x; y = fillstart.y; code = 1; r = 0.0; while (code == 1) { for (i = 0; i <= 0.75 * r; i++) { x = fillstart.x + i; sqr_x = (r * r) - ((fillstart.x - x) * (fillstart.x - x)); y = fillstart.y + sqrt(sqr_x); if ((x >= range.left) && (x < size.x + range.left) && (y >= range.top) && (y < size.y+range.top)) { BP = Image->uBitmap->GetScanLine(y); if (BP[x] == 0xFE) { code = 0; break; } } x = fillstart.x - i; if ((x >= range.left) && (x < size.x + range.left) && (y >= range.top) && (y < size.y+range.top)) { BP = Image->uBitmap->GetScanLine(y); if (BP[x] == 0xFE) { code = 0; break; } } x = fillstart.x + i; y = fillstart.y - sqrt(sqr_x); if ((x >= range.left) && (x < size.x + range.left) && (y >= range.top) && (y < size.y+range.top)) { BP = Image->uBitmap->GetScanLine(y); if (BP[x] == 0xFE) { code = 0; break; } } x = fillstart.x - i; if ((x >= range.left) && (x < size.x + range.left) && (y >= range.top) && (y < size.y+range.top)) { BP = Image->uBitmap->GetScanLine(y); if (BP[x] == 0xFE) { code = 0; break; } } y = fillstart.y + i; sqr_y = (r * r) - ((fillstart.y - y) * (fillstart.y - y)); x = fillstart.x + sqrt(sqr_y); if ((x >= range.left) && (x < size.x + range.left) && (y >= range.top) && (y < size.y+range.top)) { BP = Image->uBitmap->GetScanLine(y); if (BP[x] == 0xFE) { code = 0; break; } } y = fillstart.y - i; if ((x >= range.left) && (x < size.x + range.left) && (y >= range.top) && (y < size.y+range.top)) { BP = Image->uBitmap->GetScanLine(y); if (BP[x] == 0xFE) { code = 0; break; } } y = fillstart.y + i; x = fillstart.x - sqrt(sqr_y); if ((x >= range.left) && (x < size.x + range.left) && (y >= range.top) && (y < size.y+range.top)) { BP = Image->uBitmap->GetScanLine(y); if (BP[x] == 0xFE) { code = 0; break; } } y = fillstart.y - i; if ((x >= range.left) && (x < size.x + range.left) && (y >= range.top) && (y < size.y+range.top)) { BP = Image->uBitmap->GetScanLine(y); if (BP[x] == 0xFE) { code = 0; break; } } if ((r > size.x+range.left) && (r > size.y+range.top)) { ec = EC_NO_TARGET; goto fail; } r = r + 1; } } now = new TPoint; now->x = x; now->y = y; BP = Image->uBitmap->GetScanLine(now->y); BP[now->x] = 0xFD; Image->uBitmap->PutScanLine(now->y,now->x,1); //caution!!! if ((stack = new TList) == NULL){ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } stack->Add(now); while (stack->Count) { sp = (TPoint *)(stack->Last()); stack->Remove(sp); sx = sp->x; sy = sp->y; if (sp) delete sp; sp = 0; for (y = sy - 1; y <= sy + 1; y++) { if (y >= 0 && y < Image->uBitmap->Height) { BP = Image->uBitmap->GetScanLine(y, sx - 1, 3); for (x = sx - 1; x <= sx + 1; x++) { if(y == sy && x == sx) continue; if(x >= 0 && x < Image->uBitmap->Width) { now = new TPoint; now->x = x; now->y = y; if (BP[now->x] == 0xFE) { BP[now->x] = 0xFD; stack->Add(now); } else { if (now) delete now; now = 0; } } } Image->uBitmap->PutScanLine(y, sx - 1, 3); } } } if (now) delete now; now = 0; while (stack->Count) { sp = (TPoint *)(stack->Last()); stack->Remove(sp); if (sp) delete sp; sp = 0; } if (stack) delete stack; stack = NULL; if ((outpen = new TPBitmap) == NULL) {ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!(outpen->Create(81, 81, 8))) {ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (outpen->Lock() == NULL) {ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } pw = (PenManagerForm->Pen->BasicThick - 1) * 2 + 1; for (y = 0; y <= 80; y++) { OP = outpen->ScanLine(y); for (x = 0; x <= 80; x++) { OP[x] = 0x00; } } if (pw == 1) { OP = outpen->ScanLine(40); OP[40] = 0xFF; } else { if (PenManagerForm->Pen->Shape == 0) { r = pw / 2.0; r1 = r; for (y = 0; y <= r1; y++) { PBP = outpen->ScanLine(40 + y); NBP = outpen->ScanLine(40 - y); x = sqrt(r * r - y * y); for (a = 40 - x; a <= 40 + x; a++) { PBP[a] = 0xFF; NBP[a] = 0xFF; } } } else { r1 = 40 - pw / 2.0; for (y = r1; y <= r1 + pw; y++) { //for (y = r1; y <= r1 + pw - 1; y++) { OP = outpen->ScanLine(y); for (x = r1; x <= r1 + pw; x++) { //for (x = r1; x <= r1 + pw - 1; x++) { OP[x] = 0xFF; } } } } if (PenManagerForm->sbMask->Down) { Byte *MP = 0; if (!(Image->Mask->StartScanLineN(2))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = min.y; y < max.y; y++) { BP = Image->uBitmap->GetScanLine(y); MP = Image->Mask->GetScanLine(y); for (x = min.x; x < max.x; x++) { if (BP[x] == 0xFD) { MP[x] = MainImageForm->MaskPixel; outlinemask_pen(outpen, x, y); } } Image->Mask->PutScanLine(y, min.x, max.x-min.x); } if (outpen) delete outpen; outpen = NULL; ////////////////////////////////////////////////////////////////////// // if ((undo = Undo->Last) == NULL) { ec = EC_UNDO_NONE; goto fail; } //BeConverted by linuxjun Don't Forget!! Undo_Method if ((undo = MainImageForm->Undo->GetLast()) == NULL) { ec = EC_UNDO_NONE; goto fail; } //BeConverted by linuxjun Don't Forget!! Undo_Method MainImageForm->iMainImage->uBitmap->PartialUndo->LoadLast(undo->FromRgb); if (!(MainImageForm->iMainImage->uBitmap->StartUndoScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = min.y; y < max.y; y++) { BP = Image->uBitmap->GetScanLine(y); OP = MainImageForm->iMainImage->uBitmap->GetUndoScanLine(y); for (x = min.x; x < max.x; x++) { if ((BP[x] == 0xFF) || (BP[x] == 0xFE)) { BP[x] = OP[x]; } } Image->uBitmap->PutScanLine(y, min.x, max.x-min.x); } MainImageForm->iMainImage->uBitmap->StopUndoScanLine(); // undo->Complete(); ////////////////////////////////////////////////////////////////// Image->Mask->StopScanLine(); } else { if (Image->LayerMask) { c = PaletteForm->DIB256Palette->ChoiceIndex; Image->LayerMask->StartScanLineN(2); for (y = min.y; y < max.y; y++) { BP = Image->uBitmap->GetScanLine(y); LP = Image->LayerMask->GetScanLine(y); for (x = min.x; x < max.x; x++) { if (BP[x] == 0xFD) { BP[x] = c; LP[x] = 0; outline_pen(outpen, x, y); } } Image->uBitmap->PutScanLine(y, min.x, max.x-min.x); Image->LayerMask->PutScanLine(y, min.x, max.x-min.x); } Image->LayerMask->StopScanLine(); } else { c = PaletteForm->DIB256Palette->ChoiceIndex; for (y = min.y; y < max.y; y++) { BP = Image->uBitmap->GetScanLine(y); for (x = min.x; x < max.x; x++) { if (BP[x] == 0xFD) { BP[x] = c; outline_pen(outpen, x, y); } } Image->uBitmap->PutScanLine(y, min.x, max.x-min.x); } } if (outpen) delete outpen; outpen = NULL; // if ((undo = Undo->Last) == NULL) { ec = EC_UNDO_NONE; goto fail; } //BeConverted by linuxjun Don't Forget!! Undo_Method if ((undo = MainImageForm->Undo->GetLast()) == NULL) { ec = EC_UNDO_NONE; goto fail; } //BeConverted by linuxjun Don't Forget!! Undo_Method // if ((undo = MainImageForm->Undo->getLastUndoData())==NULL) { ec = EC_NONE; goto fail; } MainImageForm->iMainImage->uBitmap->PartialUndo->LoadLast(undo->FromRgb); // if ((undo = MainImageForm->Undo->GetLast()) == NULL) { ec = EC_UNDO_NONE; goto fail; } if (!(MainImageForm->iMainImage->uBitmap->StartUndoScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = min.y; y < max.y; y++) { BP = Image->uBitmap->GetScanLine(y); OP = MainImageForm->iMainImage->uBitmap->GetUndoScanLine(y); for (x = min.x; x < max.x; x++) { if ((BP[x] == 0xFF) || (BP[x] == 0xFE)) { BP[x] = OP[x]; } } Image->uBitmap->PutScanLine(y, min.x, max.x-min.x); } MainImageForm->iMainImage->uBitmap->StopUndoScanLine(); // undo->Complete(); ////////////////////////////////////////////////////////////////// // undo->Complete(); } //by jeegeo ::RepaintImage(); Image->uBitmap->StopScanLine(); Screen->Cursor = OldCursor; END_LOG; return; fail: if (outpen) delete outpen; if (Image->Mask) Image->Mask->StopScanLine(); // if (undo) undo->uBitmap->StopScanLine(); if (undo) MainImageForm->iMainImage->uBitmap->StopUndoScanLine(); Image->uBitmap->StopScanLine(); // Undo->Read(); ////BeConverted by linuxjun Don't Forget!! Undo_Method MainImageForm->Undo->UndoRead(); ////BeConverted by linuxjun Don't Forget!! Undo_Method Screen->Cursor = OldCursor; EXCEPTION_MESSAGE_OK(ec); END_LOG; //*/ } //--------------------------------------------------------------------------- void __fastcall TDrawForm::fit_dot_line(TPenMode ch, int ln, int *value, COLORREF fc) { BEGIN_LOG("Draw_F"); int i, j, k, sx, sy, ex, ey; int cnt, dot, grade, total; double lng, gap; sx = Tstitch.l[ln].sx; sy = Tstitch.l[ln].sy; ex = Tstitch.l[ln].ex; ey = Tstitch.l[ln].ey; lng = (int)(sqrt((double)(ex - sx + 1) * (ex - sx + 1) + (ey - sy + 1) * (ey - sy + 1))); gap = (double)(value[0] + value[1]) * PenManagerForm->Pen->BasicThick; cnt = lng / gap + 1; grade = (value[0] + value[1]) * 2; dot = (value[0] - 1) * 2; total = cnt * grade; for (i = 0; i < cnt; i++) { j = i * grade + 1 + value[1]; k = total - j; Lsx = (double)(sx * k + ex * j) / total + 0.5; Lsy = (double)(sy * k + ey * j) / total + 0.5; j = j + dot; k = k - dot; Lex = (double)(sx * k + ex * j) / total + 0.5; Ley = (double)(sy * k + ey * j) / total + 0.5; Line(fc); } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::fit_dot_line(HDC dc, int x, int y) { BEGIN_LOG("Draw_F"); TPLayerImage *image=MainImageForm->iMainImage; int i, j, k, sx, sy, ex, ey; int cnt, dot, grade, total; double lng, gap; sx = Tstitch.l[1].sx; sy = Tstitch.l[1].sy; ex = Tstitch.l[1].ex; ey = Tstitch.l[1].ey; lng = int(sqrt(double(ex - sx + 1) * (ex - sx + 1) + (ey - sy + 1) * (ey - sy + 1))); gap = double(Ltype[Item].value[0] + Ltype[Item].value[1]) * PenManagerForm->Pen->BasicThick; cnt = lng / gap + 1; grade = (Ltype[Item].value[0] + Ltype[Item].value[1]) * 2; dot = (Ltype[Item].value[0] - 1) * 2; total = cnt * grade; for (i = 0; i < cnt; i++) { j = i * grade + 1 + Ltype[Item].value[1]; k = total - j; Lsx = double(sx * k + ex * j) / total + 0.5; Lsy = double(sy * k + ey * j) / total + 0.5; j = j + dot; k = k - dot; Lex = double(sx * k + ex * j) / total + 0.5; Ley = double(sy * k + ey * j) / total + 0.5; if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); } } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::square(TPenMode ch, COLORREF fc) { BEGIN_LOG("Draw_F"); int sx, sy, ex, ey, lx, ly, pt; int SignX, SignY; Byte *IP; TPItemImage *Image = MainImageForm->iMainImage; TPException ec = EC_NONE; pt = PenManagerForm->Pen->Thick; // if (isw==0) { if (!hasUserLength) { // by celberus sx = Lsx; sy = Lsy; lx = abs(Lex - sx); ly = abs(Ley - sy); if (lx > ly) lx = ly; ex = sx > Lex ? sx - lx : sx + lx; ey = sy > Ley ? sy - lx : sy + lx; if (sx > ex) Swap(sx, ex); if (sy > ey) Swap(sy, ey); } else { lx = Sqr_l - PenManagerForm->Pen->Thick; sx = Csx - lx / 2; sy = Csy - lx / 2; ex = sx + lx; ey = sy + lx; } if (ch == pmXor) { DrawRectangleLocate(Rect(sx, sy, ex+1, ey+1)); if (IsDraw) { IsDraw = false; MainImageForm->iMainImage->OnPaintLocate = NULL;/////////////////by jeegeo } else IsDraw = true; } else if (ch == pmCopy) { if (fill_not == 1) { if (ex - sx - pt > 0 && ey - sy - pt > 0) { FillSquare(sx, sy, ex, ey, fc); } } MainImageForm->line_pen(sx, sy, ex, sy, fc); MainImageForm->line_pen(ex, sy, ex, ey, fc); MainImageForm->line_pen(sx, ey, ex, ey, fc); MainImageForm->line_pen(sx, sy, sx, ey, fc); } lx += PenManagerForm->Pen->BasicThick; switch (MainImageForm->CurrentUnit) { case uDot: eLength1->Value = lx; break; case uInch: eLength1->Value = (double)lx / MainImageForm->CanvasInfor.DotsPerInch; //Format("%.2f", OPENARRAY(TVarRec, ((double)lx / MainImageForm->CanvasInfor.DotsPerInch))); break; case uCm: eLength1->Value = 2.54 * lx / MainImageForm->CanvasInfor.DotsPerInch; //Format("%.2f", OPENARRAY(TVarRec,(2.54 * lx / MainImageForm->CanvasInfor.DotsPerInch))); break; } eLength2->Value = eLength1->Value; END_LOG; return; fail: if (Image->Mask) Image->Mask->StopScanLine(); if (Image->LayerMask) Image->LayerMask->StopScanLine(); Image->uBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::FillSquare(int sx, int sy, int ex, int ey, COLORREF fc) { TPItemImage *Image = MainImageForm->iMainImage; TPException ec = EC_NONE; int pt = PenManagerForm->Pen->Thick; int sr = pt >> 1; int lr = pt - sr; int ssx = sx, ssy = sy, eex = ex, eey = ey; if (Image->Reflection && MainImageForm->reflection){ RECT range; MainImageForm->reflection->ChangeAvailableOriginalRange(Rect(sx, sy, ex, ey), range); ssx = range.left; ssy = range.top; eex = range.right; eey = range.bottom; if (ssx == MainImageForm->reflection->BitmapRange.left) ssx -= pt; if (ssy == MainImageForm->reflection->BitmapRange.top) ssy -= pt; if (eex == MainImageForm->reflection->BitmapRange.right) eex += pt; if (eey == MainImageForm->reflection->BitmapRange.bottom) eey += pt; } if (PenManagerForm->sbMask->Down) { if (!(Image->Mask->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if (!(Image->uBitmap->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Image->LayerMask) { if (!(Image->LayerMask->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } if (MainImageForm->MaskArea) { if (!(Image->Mask->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } } for (int i = ssy + lr; i < eey - sr; i++) { MainImageForm->set_hline(ssx + lr, i, eex - ssx - pt, fc); } if (PenManagerForm->sbMask->Down) { Image->Mask->StopScanLine(); } else { if (MainImageForm->MaskArea) Image->Mask->StopScanLine(); if (Image->LayerMask) Image->LayerMask->StopScanLine(); Image->uBitmap->StopScanLine(); } return; fail: if (Image->Mask) Image->Mask->StopScanLine(); if (Image->LayerMask) Image->LayerMask->StopScanLine(); Image->uBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TDrawForm::dotted_square(TPenMode ch, int *value, COLORREF fc) { BEGIN_LOG("Draw_F"); int sx, sy, ex, ey, lx, ly, lng, l; sx = Tstitch.sx; sy = Tstitch.sy; ex = Tstitch.ex; ey = Tstitch.ey; lx = ex - sx; ly = ey - sy; if (abs(lx) > abs(ly)) lng = ly; else lng = lx; l = abs(lng); if (lx * ly > 0) { Tstitch.l[1].sx = sx; Tstitch.l[1].sy = sy; Tstitch.l[1].ex = sx; Tstitch.l[1].ey = sy + lng; fit_dot_line(ch, 1, value, fc); Tstitch.l[1].ex = sx + lng; Tstitch.l[1].ey = sy; fit_dot_line(ch, 1, value, fc); Tstitch.l[1].sx = sx + lng; Tstitch.l[1].sy = sy + lng; Tstitch.l[1].ex = sx; Tstitch.l[1].ey = sy + lng; fit_dot_line(ch, 1, value, fc); Tstitch.l[1].ex = sx + lng; Tstitch.l[1].ey = sy; fit_dot_line(ch, 1, value, fc); } else { if (lx < 0) l = l * (-1); Tstitch.l[1].sx = sx; Tstitch.l[1].sy = sy; Tstitch.l[1].ex = sx; Tstitch.l[1].ey = sy - l; fit_dot_line(ch, 1, value, fc); Tstitch.l[1].ex = sx + l; Tstitch.l[1].ey = sy; fit_dot_line(ch, 1, value, fc); Tstitch.l[1].sx = sx + l; Tstitch.l[1].sy = sy - l; Tstitch.l[1].ex = sx; Tstitch.l[1].ey = sy - l; fit_dot_line(ch, 1, value, fc); Tstitch.l[1].ex = sx + l; Tstitch.l[1].ey = sy; fit_dot_line(ch, 1, value, fc); } l = abs(l) + PenManagerForm->Pen->BasicThick; switch (MainImageForm->CurrentUnit) { case uDot : eLength1->Value = l; break; case uInch: eLength1->Value = (double)l / MainImageForm->CanvasInfor.DotsPerInch; break; //Format("%.2f", OPENARRAY(TVarRec, ((double)l / MainImageForm->CanvasInfor.DotsPerInch))); break; case uCm : eLength1->Value = (double)l / MainImageForm->CanvasInfor.DotsPerInch * 2.54; break; //Format("%.2f", OPENARRAY(TVarRec, ((double)l / MainImageForm->CanvasInfor.DotsPerInch * 2.54))); } eLength2->Value = eLength1->Value; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::rectangle(TPenMode ch, COLORREF fc) { BEGIN_LOG("Draw_F"); int sx, sy, ex, ey, lx, ly; Byte *IP; TPItemImage *Image = MainImageForm->iMainImage; TPException ec = EC_NONE; int pt = PenManagerForm->Pen->Thick; // if (isw==0) { if (!hasUserLength) { // by celberus sx = Lsx; sy = Lsy; ex = Lex; ey = Ley; if (sx > ex) Swap(sx, ex); if (sy > ey) Swap(sy, ey); lx = ex - sx; ly = ey - sy; } else { lx = Rec_lx - PenManagerForm->Pen->Thick; ly = Rec_ly - PenManagerForm->Pen->Thick; sx = Csx - lx / 2; sy = Csy - ly / 2; } ex = sx + lx; ey = sy + ly; if (ch == pmXor) { DrawRectangleLocate(Rect(sx, sy, ex+1, ey+1)); if (IsDraw) { IsDraw = false; MainImageForm->iMainImage->OnPaintLocate = NULL;/////////////////by jeegeo }else IsDraw = true; } else if (ch == pmCopy) { MainImageForm->line_pen(sx, sy, ex, sy, fc); MainImageForm->line_pen(ex, sy, ex, ey, fc); MainImageForm->line_pen(sx, ey, ex, ey, fc); MainImageForm->line_pen(sx, sy, sx, ey, fc); if (fill_not == 1) { if (ex - sx - pt > 0 && ey - sy - pt > 0) { FillRectangle(sx, sy, ex, ey, fc); } } /* MainImageForm->line_pen(sx, sy, ex - 1, sy, fc); MainImageForm->line_pen(ex - 1, sy, ex - 1, ey - 1, fc); MainImageForm->line_pen(sx, ey - 1, ex - 1, ey - 1, fc); MainImageForm->line_pen(sx, sy, sx, ey - 1, fc); */ //by jeegeo Image->Repaint(); } lx += PenManagerForm->Pen->BasicThick; ly += PenManagerForm->Pen->BasicThick; switch (MainImageForm->CurrentUnit) { case uDot: eLength1->Value = lx; eLength2->Value = ly; break; case uInch: eLength1->Value = (double)lx / MainImageForm->CanvasInfor.DotsPerInch; //Format("%.2f", OPENARRAY(TVarRec, ((double)lx / MainImageForm->CanvasInfor.DotsPerInch))); eLength2->Value = (double)ly / MainImageForm->CanvasInfor.DotsPerInch; //Format("%.2f", OPENARRAY(TVarRec, ((double)ly / MainImageForm->CanvasInfor.DotsPerInch))); break; case uCm: eLength1->Value = 2.54 * lx / MainImageForm->CanvasInfor.DotsPerInch; //Format("%.2f", OPENARRAY(TVarRec, (2.54 * lx / MainImageForm->CanvasInfor.DotsPerInch))); eLength2->Value = 2.54 * ly / MainImageForm->CanvasInfor.DotsPerInch; //Format("%.2f", OPENARRAY(TVarRec, (2.54 * ly / MainImageForm->CanvasInfor.DotsPerInch))); break; } END_LOG; return; fail: if (Image->Mask) Image->Mask->StopScanLine(); if (Image->LayerMask) Image->LayerMask->StopScanLine(); Image->uBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::dotted_rectangle(TPenMode ch, int *value, COLORREF fc) { BEGIN_LOG("Draw_F"); int sx, sy, ex, ey, lx, ly; sx = Tstitch.sx; sy = Tstitch.sy; ex = Tstitch.ex; ey = Tstitch.ey; Tstitch.l[1].sx = sx; Tstitch.l[1].sy = sy; Tstitch.l[1].ex = ex; Tstitch.l[1].ey = sy; fit_dot_line(ch, 1, value, fc); Tstitch.l[1].ex = sx; Tstitch.l[1].ey = ey; fit_dot_line(ch, 1, value, fc); Tstitch.l[1].sx = ex; Tstitch.l[1].sy = ey; Tstitch.l[1].ex = sx; Tstitch.l[1].ey = ey; fit_dot_line(ch, 1, value, fc); Tstitch.l[1].ex = ex; Tstitch.l[1].ey = sy; fit_dot_line(ch, 1, value, fc); lx = abs(ex - sx) + PenManagerForm->Pen->BasicThick; ly = abs(ey - sy) + PenManagerForm->Pen->BasicThick; switch (MainImageForm->CurrentUnit) { case uDot : eLength1->Value = lx; eLength2->Value = ly; break; case uInch: eLength1->Value = (double)lx / MainImageForm->CanvasInfor.DotsPerInch; //Format("%.2f", OPENARRAY(TVarRec, ((double)lx / MainImageForm->CanvasInfor.DotsPerInch))); eLength2->Value = (double)ly / MainImageForm->CanvasInfor.DotsPerInch; //Format("%.2f", OPENARRAY(TVarRec, ((double)ly / MainImageForm->CanvasInfor.DotsPerInch))); break; case uCm : eLength1->Value = (double)lx / MainImageForm->CanvasInfor.DotsPerInch * 2.54; //Format("%.2f", OPENARRAY(TVarRec, ((double)lx / MainImageForm->CanvasInfor.DotsPerInch * 2.54))); eLength2->Value = (double)ly / MainImageForm->CanvasInfor.DotsPerInch * 2.54; //Format("%.2f", OPENARRAY(TVarRec, ((double)ly / MainImageForm->CanvasInfor.DotsPerInch * 2.54))); } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::curve(TPenMode ch, COLORREF fc) { BEGIN_LOG("Draw_F"); int sx, sy, ex, ey, mx, my; double ct, st, ss, theta, alpha, d1, d2, d3; double tx, ty, a, b, x, y, pw, count; pw = PenManagerForm->Pen->BasicThick; sx = Lsx; sy = Lsy; ex = Lex; ey = Ley; mx = Csx; my = Csy; d1 = sqrt((double)(sx - mx) * (sx - mx) + (sy - my) * (sy - my)); d2 = sqrt((double)(ex - mx) * (ex - mx) + (ey - my) * (ey - my)); d3 = sqrt((double)(ex - sx) * (ex - sx) + (ey - sy) * (ey - sy)); if (d1 > d2) { a = d1; b = d2; } else { a = d2; b = d1; } if ((my - sy) * (ex - sx) == (mx - sx) * (ey - sy)) { Line(fc); } else if ((sy == ey) && ((mx - sx) == (ex - mx))) { if (sx > mx) tx = sx - mx; else tx = mx - sx; ty = sy - my; alpha = ty / (tx * tx); count = pw / 10 + 1; Lsx = mx; Lsy = my; x = 0; while (x <= tx) { y = alpha * (x * x); Lex = mx + x; Ley = my + y; Line(fc); Lsx = Lex; Lsy = Ley; x = x + count; } if (sx > ex) Lex = sx; else Lex = ex; Ley = sy; Line(fc); count = pw / 10 + 1; Lsx = mx; Lsy = my; x = 0; while (x <= tx) { y = alpha * (x * x); Lex = mx - x; Ley = my + y; Line(fc); Lsx = Lex; Lsy = Ley; x = x + count; } if (sx < ex) Lex = sx; else Lex = ex; Ley = sy; Line(fc); } else { if ((a > b * 1.8) && (d3 < a)) { d1 = sqrt(d1); d2 = sqrt(d2); } tx = (Lex * d1 + Lsx * d2) / (d1 + d2); ty = (Ley * d1 + Lsy * d2) / (d1 + d2); if (tx == mx) ss = ty - my; else ss = (double)(ty - my) / (tx - mx); theta = M_PI / 2.0 - atan(ss); ct = cos(theta); st = sin(theta); tx = ct * (sx - mx) - st * (sy - my); ty = st * (sx - mx) + ct * (sy - my); alpha = ty / (tx * tx); count = pw / 10 + 1; Lsx = mx; Lsy = my; if (tx < 0) { x = 0; while (x >= tx) { y = alpha * (x * x); Lex = ct * x + st * y + mx; Ley = ct * y - st * x + my; Line(fc); Lsx = Lex; Lsy = Ley; x = x - count; } } else { x = 0; while (x <= tx) { y = alpha * (x * x); Lex = ct * x + st * y + mx; Ley = ct * y - st * x + my; Line(fc); Lsx = Lex; Lsy = Ley; x = x + count; } } Lex = sx; Ley = sy; Line(fc); tx = ct * (ex - mx) - st * (ey - my); ty = st * (ex - mx) + ct * (ey - my); alpha = ty / (tx * tx); count = pw / 10 + 1; Lsx = mx; Lsy = my; if (tx < 0) { x = 0; while (x >= tx) { y = alpha * (x * x); Lex = ct * x + st * y + mx; Ley = ct * y - st * x + my; Line(fc); Lsx = Lex; Lsy = Ley; x = x - count; } } else { x = 0; while (x <= tx) { y = alpha * (x * x); Lex = ct * x + st * y + mx; Ley = ct * y - st * x + my; Line(fc); Lsx = Lex; Lsy = Ley; x = x + count; } } Lex = ex; Ley = ey; Line(fc); } Lsx = sx; Lex = ex; Lsy = sy; Ley = ey; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::TaperCurve(TPenMode ch, COLORREF fc) { BEGIN_LOG("Draw_F"); int sx, sy, ex, ey, mx, my; double ct, st, ss, theta, alpha, d1, d2, d3; double tx, ty, a, b, x, y, pw, count; double s_size, e_size, s_rate, e_rate; s_size = StartSize->Value; e_size = EndSize->Value; pw = PenManagerForm->Pen->BasicThick; sx = Lsx; sy = Lsy; ex = Lex; ey = Ley; mx = Csx; my = Csy; d1 = sqrt((double)(sx - mx) * (sx - mx) + (sy - my) * (sy - my)); d2 = sqrt((double)(ex - mx) * (ex - mx) + (ey - my) * (ey - my)); d3 = sqrt((double)(ex - sx) * (ex - sx) + (ey - sy) * (ey - sy)); if (d1 > d2) { a = d1; b = d2; } else { a = d2; b = d1; } if ((my - sy) * (ex - sx) == (mx - sx) * (ey - sy)) { TaperLine(s_size, e_size, 0, 1, fc); } else if ((sy == ey) && ((mx - sx) == (mx - ex))) { if (sx > mx) tx = sx - mx; else tx = mx - sx; ty = sy - my; alpha = ty / (tx * tx); count = pw / 10 + 1; Lsx = mx; Lsy = my; x = 0; while (x <= tx) { y = alpha * (x * x); Lex = mx + x; Ley = my + y; Line(fc); Lsx = Lex; Lsy = Ley; x = x + count; } if (sx > ex) Lex = sx; else Lex = ex; Ley = sy; Line(fc); count = pw / 10 + 1; Lsx = mx; Lsy = my; x = 0; while (x <= tx) { y = alpha * (x * x); Lex = mx - x; Ley = my + y; Line(fc); Lsx = Lex; Lsy = Ley; x = x + count; } if (sx < ex) Lex = sx; else Lex = ex; Ley = sy; Line(fc); } else { if ((a > b * 1.8) && (d3 < a)) { d1 = sqrt(d1); d2 = sqrt(d2); } tx = (Lex * d1 + Lsx * d2) / (d1 + d2); ty = (Ley * d1 + Lsy * d2) / (d1 + d2); if (tx == mx) ss = ty - my; else ss = (double)(ty - my) / (tx - mx); theta = M_PI / 2.0 - atan(ss); ct = cos(theta); st = sin(theta); tx = ct * (sx - mx) - st * (sy - my); ty = st * (sx - mx) + ct * (sy - my); alpha = ty / (tx * tx); count = pw / 10 + 1; Lsx = mx; Lsy = my; if (tx < 0) { x = 0; while (x >= tx) { y = alpha * (x * x); Lex = ct * x + st * y + mx; Ley = ct * y - st * x + my; s_rate = 0.5 - fabs(x / tx) / 2; e_rate = 0.5 - fabs((x - count) / tx) / 2; TaperLine(s_size, e_size, s_rate, e_rate, fc); Lsx = Lex; Lsy = Ley; x = x - count; } } else { x = 0; while (x <= tx) { y = alpha * (x * x); Lex = ct * x + st * y + mx; Ley = ct * y - st * x + my; s_rate = 0.5 - fabs(x / tx) / 2; e_rate = 0.5 - fabs((x - count) / tx) / 2; TaperLine(s_size, e_size, s_rate, e_rate, fc); Lsx = Lex; Lsy = Ley; x = x + count; } } Lex = sx; Ley = sy; s_rate = 0.5 - fabs(x / tx) / 2; e_rate = 0.5 - fabs((x - count) / tx) / 2; TaperLine(s_size, e_size, s_rate, e_rate, fc); tx = ct * (ex - mx) - st * (ey - my); ty = st * (ex - mx) + ct * (ey - my); alpha = ty / (tx * tx); count = pw / 10 + 1; Lsx = mx; Lsy = my; if (tx < 0) { x = 0; while (x >= tx) { y = alpha * (x * x); Lex = ct * x + st * y + mx; Ley = ct * y - st * x + my; s_rate = 0.5 + fabs(x / tx) / 2; e_rate = 0.5 + fabs((x - count) / tx) / 2; TaperLine(s_size, e_size, s_rate, e_rate, fc); Lsx = Lex; Lsy = Ley; x = x - count; } } else { x = 0; while (x <= tx) { y = alpha * (x * x); Lex = ct * x + st * y + mx; Ley = ct * y - st * x + my; s_rate = 0.5 + fabs(x / tx) / 2; e_rate = 0.5 + fabs((x - count) / tx) / 2; TaperLine(s_size, e_size, s_rate, e_rate, fc); Lsx = Lex; Lsy = Ley; x = x + count; } } Lex = ex; Ley = ey; s_rate = 0.5 + fabs(x / tx) / 2; e_rate = 0.5 + fabs((x + count) / tx) / 2; TaperLine(s_size, e_size, s_rate, e_rate, fc); } Lsx = sx; Lex = ex; Lsy = sy; Ley = ey; END_LOG; } //---------------------------------------------------------------------------- void __fastcall TDrawForm::dot_curve(TPenMode ch, int *value, COLORREF fc) { BEGIN_LOG("Draw_F"); int i, j, k, sx, sy, ex, ey; int ssx, eex, ssy, eey, mx, my; int cnt, dot, grade, total; double x, y, llsx, llsy, llex, lley; double tx, ty, a, b, pw, count; double lng, gap; double ct, st, ss, theta, alpha, d1, d2, d3; pw = PenManagerForm->Pen->BasicThick; sx = Lsx; sy = Lsy; ex = Lex; ey = Ley; mx = Csx; my = Csy; d1 = sqrt((sx - mx) * (sx - mx) + (sy - my) * (sy - my)); d2 = sqrt((ex - mx) * (ex - mx) + (ey - my) * (ey - my)); d3 = sqrt((ex - sx) * (ex - sx) + (ey - sy) * (ey - sy)); if (d1 >= d2) { a = d1; b = d2; } else { a = d2; b = d1; } if ((my - sy) * (ex - sx) == (mx - sx) * (ey - sy)) { Tstitch.l[1].sx = sx; Tstitch.l[1].ex = ex; Tstitch.l[1].sy = sy; Tstitch.l[1].ey = ey; dot_line(ch, 1, value, fc); } else if ((sy == ey) && ((mx - sx) == (mx - ex))) { tx = abs(mx - sx); ty = sy - my; alpha = ty / (tx * tx); count = pw / 10.0 + 1; Lsx = mx; Lsy = my; x = 0; while (x <= tx) { y = alpha * (x * x); Lex = mx + x; Ley = my + y; Line(fc); Lsx = Lex; Lsy = Ley; x = x + count; } if (sx > ex) Lex = sx; else Lex = ex; Ley = sy; Line(fc); count = pw / 10.0 + 1; Lsx = mx; Lsy = my; x = 0; while (x <= tx) { y = alpha * (x * x); Lex = mx - x; Ley = my + y; Line(fc); Lsx = Lex; Lsy = Ley; x = x + count; } if (sx < ex) Lex = sx; else Lex = ex; Ley = sy; Line(fc); } else { if ((a > b * 1.8) && (d3 < a)) { d1 = sqrt(d1); d2 = sqrt(d2); } tx = (Lex * d1 + Lsx * d2) / (d1 + d2); ty = (Ley * d1 + Lsy * d2) / (d1 + d2); if (tx == mx) ss = ty - my; else ss = (ty - my) / (tx - mx); theta = M_PI_2 - atan(ss); ct = cos(theta); st = sin(theta); tx = ct * (sx - mx) - st * (sy - my); ty = st * (sx - mx) + ct * (sy - my); alpha = ty / (tx * tx); ssx = 0; ssy = 0; eex = tx; eey = ty; lng = sqrt((eex - ssx + 1) * (eex - ssx + 1) + (eey - ssy + 1) * (eey - ssy + 1)); gap = (value[0] + value[1]) * PenManagerForm->Pen->BasicThick; cnt = lng / gap + 1; grade = (value[0] + value[1]) * 2; dot = (value[0] - 1) * 2; total = cnt * grade; for (i = 0; i < cnt; i++) { j = i * grade + 1 + value[1]; k = total - j; llsx = double(ssx * k + eex * j) / total; llsy = alpha * llsx * llsx; Lsx = ct * llsx + st * llsy + mx + 0.5; Lsy = ct * llsy - st * llsx + my + 0.5; j = j + dot; k = k - dot; llex = double(ssx * k + eex * j) / total; lley = alpha * llex * llex; Lex = ct * llex + st * lley + mx + 0.5; Ley = ct * lley - st * llex + my + 0.5; Line(fc); } tx = ct * (ex - mx) - st * (ey - my); ty = st * (ex - mx) + ct * (ey - my); alpha = ty / (tx * tx); ssx = 0; ssy = 0; eex = tx; eey = ty; lng = sqrt((eex - ssx + 1) * (eex - ssx + 1) + (eey - ssy + 1) * (eey - ssy + 1)); gap = (value[0] + value[1]) * PenManagerForm->Pen->BasicThick; cnt = lng / gap + 1; grade = (value[0] + value[1]) * 2; dot = (value[0] - 1) * 2; total = cnt * grade; for (i = 0; i < cnt; i++) { j = i * grade + 1 + value[1]; k = total - j; llsx = double(ssx * k + eex * j) / total; llsy = alpha * llsx * llsx; Lsx = ct * llsx + st * llsy + mx + 0.5; Lsy = ct * llsy - st * llsx + my + 0.5; j = j + dot; k = k - dot; llex = double(ssx * k + eex * j) / total; lley = alpha * llex * llex; Lex = ct * llex + st * lley + mx + 0.5; Ley = ct * lley - st * llex + my + 0.5; Line(fc); } } Lsx = sx; Lex = ex; Lsy = sy; Ley = ey; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::circle(TPenMode ch, COLORREF fc) { BEGIN_LOG("Draw_F"); int lx, ly, dia, h; TTexpiaBitmap *tb = NULL; HDC dc = NULL; HPEN hPen = NULL, hOldPen = NULL; int x, y, xx, ls, rs; int drawingDiameter; BYTE *bp; TPItemImage *Image = MainImageForm->iMainImage; TPException ec = EC_NONE; int CenterX = Csx; int CenterY = Csy; if (!hasUserLength) { // by celberus lx = Lsx - Csx; ly = Lsy - Csy; dia = 2 * sqrt(lx * lx + ly * ly) + 1; } else { if(Radius == 0)dia = 13; else dia = Radius; } int posx = 0, posy = 0; if (Image->Reflection && MainImageForm->reflection){ int wx = 0, hy = 0; if (MainImageForm->reflection->WorkSide == D_RIGHT){ wx = MainImageForm->reflection->BitmapWidth; // } else if (MainImageForm->reflection->WorkSide == D_LEFT){ // CenterX = MainImageForm->reflection->BitmapWidth - Csx; } else if (MainImageForm->reflection->WorkSide == D_BOTTOM){ hy = MainImageForm->reflection->BitmapHeight; } // else if (MainImageForm->reflection->WorkSide == D_TOP){ // CenterY = MainImageForm->reflection->BitmapHeight - Csy; // } posx = MainImageForm->reflection->BitmapRange.left - wx; posy = MainImageForm->reflection->BitmapRange.top - hy; } drawingDiameter = dia; if (drawingDiameter < PenManagerForm->Pen->Thick) drawingDiameter = PenManagerForm->Pen->Thick; // by celberus ¹ÝÁö¸§ÀÌ ÀÛÀ»¶§ »ç°¢ÇüÀ¸·Î ±×·ÁÁö´Â ¿À·ù ¶§¹®¿¡.. h = drawingDiameter / 2; if (ch == pmXor) { DrawEllipseLocate(Rect(Csx - h, Csy - h, Csx - h + drawingDiameter + 1, Csy - h + drawingDiameter + 1)); if (IsDraw) { IsDraw = false; MainImageForm->iMainImage->OnPaintLocate = NULL;/////////////////by jeegeo } else IsDraw = true; } else if (ch == pmCopy) { if (PenManagerForm->sbMask->Down) { if (!(Image->Mask->StartScanLine())) {ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail;} } else { if (!(Image->uBitmap->StartScanLine())) {ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail;} if (Image->LayerMask) { if (!(Image->LayerMask->StartScanLine())) {ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail;} if (MainImageForm->bProtect) if (!(Image->BackGround->StartScanLine())) {ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail;} } if (MainImageForm->MaskArea) { if (!(Image->Mask->StartScanLine())) {ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail;} } } ls = PenManagerForm->Pen->Thick >> 1; rs = PenManagerForm->Pen->Thick - ls; if ((tb = new TTexpiaBitmap)==NULL) {ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail;} if (!tb->Create(drawingDiameter, drawingDiameter, 8)) {ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail;} if ((dc = tb->CreateDC())==NULL) {ec = EC_RESOURCE_LACK; SAVE_EXCEPTION(ec); goto fail;} if (fill_not == 0) { SelectObject(dc, GetStockObject(NULL_BRUSH)); } else { SelectObject(dc, GetStockObject(WHITE_BRUSH)); } if ((hPen = CreatePen(PS_SOLID, PenManagerForm->Pen->Thick, clWhite))==NULL) {ec = EC_RESOURCE_LACK; SAVE_EXCEPTION(ec); goto fail;} hOldPen = (HPEN)SelectObject(dc, hPen); Ellipse(dc, ls, ls, drawingDiameter - rs + 1, drawingDiameter - rs + 1); SelectObject(dc, hOldPen); DeleteObject(hPen); hPen = NULL; tb->DeleteDC(dc); dc = NULL; if (!tb->StartScanLine()) {ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail;} for (y = posy; y < drawingDiameter + posy; y++) { bp = tb->GetScanLine(y-posy); for (x = posx; x < drawingDiameter + posx;) { if (bp[x-posx]) { for (xx = x; xx < drawingDiameter + posx; xx++) { if (bp[xx-posx]==0) break; } MainImageForm->set_hline(CenterX - h + x, CenterY - h + y, xx - x, fc); x = xx; } else { x++; } } } tb->StopScanLine(); delete tb; if (PenManagerForm->sbMask->Down) { Image->Mask->StopScanLine(); } else { if (MainImageForm->MaskArea) Image->Mask->StopScanLine(); if (Image->LayerMask) { Image->LayerMask->StopScanLine(); if (MainImageForm->bProtect) Image->BackGround->StopScanLine(); } Image->uBitmap->StopScanLine(); } //by jeegeo Image->Repaint(); } if(Radius == 0) // if(!(isw == 0 && step == 1))return; if(hasUserLength || step != 1) { END_LOG; return; } switch (MainImageForm->CurrentUnit) { case uDot: eLength1->Value = dia; break; case uInch: eLength1->Value = (double)dia / MainImageForm->CanvasInfor.DotsPerInch; //Format("%.2f", OPENARRAY(TVarRec,((double)dia / MainImageForm->CanvasInfor.DotsPerInch))); break; case uCm: eLength1->Value = 2.54 * dia / MainImageForm->CanvasInfor.DotsPerInch; //Format("%.2f", OPENARRAY(TVarRec,(2.54 * dia / MainImageForm->CanvasInfor.DotsPerInch))); break; } eLength2->Value = eLength1->Value; END_LOG; return; fail: if (tb) { if (dc) tb->DeleteDC(dc); delete tb; } if (Image->Mask) Image->Mask->StopScanLine(); if (Image->LayerMask) Image->LayerMask->StopScanLine(); if (MainImageForm->bProtect) Image->BackGround->StopScanLine(); Image->uBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::dot_line(TPenMode ch, int ln, int *value, COLORREF fc) { BEGIN_LOG("Draw_F"); int i, sx, sy, ex, ey, lx, ly; int cnt, dx, dy; double lng, gap, th, ct, st, p; int ccsx, ccsy, ccex, ccey; sx = Tstitch.l[ln].sx; sy = Tstitch.l[ln].sy; ex = Tstitch.l[ln].ex; ey = Tstitch.l[ln].ey; lx = ex - sx; ly = ey - sy; if ((ly == 0) && (lx == 0)) th = 0; else th = atan2(ly, lx); ct = cos(th); st = sin(th); lng = sqrt(lx * lx + ly * ly); gap = (value[0] + value[1]) * PenManagerForm->Pen->BasicThick; cnt = lng / gap + 1; if ((Item == TD_LINE) || (Item == TD_CURVE)) { ccsx = Lsx; ccsy = Lsy; ccex = Lex; ccey = Ley; for (i = 0; i < cnt; i++) { if (gap * i <= lng) { Lsx = (gap * i) * ct + sx + 0.5; Lsy = (gap * i) * st + sy + 0.5; if ((gap * i + ((value[0] - 1) * PenManagerForm->Pen->BasicThick)) <= lng) { Lex = (gap * i + ((value[0] - 1) * PenManagerForm->Pen->BasicThick)) * ct + sx + 0.5; Ley = (gap * i + ((value[0] - 1) * PenManagerForm->Pen->BasicThick)) * st + sy + 0.5; } else { Lex = lng * ct + sx; Ley = lng * st + sy; } Line(fc); } } Lsx = ccsx; Lsy = ccsy; Lex = ccex; Ley = ccey; } else { ccsx = Lsx; ccsy = Lsy; ccex = Lex; ccey = Ley; for (i = 0; i < cnt; i++) { if (gap * i <= lng) { Lsx = (gap * i) * ct + sx + 0.5; Lsy = (gap * i) * st + sy + 0.5; if ((gap * i + ((value[0] - 1) * PenManagerForm->Pen->BasicThick)) <= lng) { Lex = (gap * i + ((value[0] - 1) * PenManagerForm->Pen->BasicThick)) * ct + sx + 0.5; Ley = (gap * i + ((value[0] - 1) * PenManagerForm->Pen->BasicThick)) * st + sy + 0.5; } else { Lex = lng * ct + sx; Ley = lng * st + sy; } Line(fc); } } Lsx = ccsx; Lsy = ccsy; Lex = ccex; Ley = ccey; } dx = Lex - Lsx; dy = Ley - Lsy; if (dy < 0) { p = (atan2(dy, dx) + 2 * M_PI) * 180.0 / M_PI; } else { if ((dx == 0) && (dy == 0)) p = 0; else p = (atan2(dy, dx)) * 180.0 / M_PI; } eAngle->Value = p; //Format("%3.1f", OPENARRAY(TVarRec, (p))); lx = abs(dx) + 1; ly = abs(dy) + 1; p = sqrt(lx * lx + ly * ly) + PenManagerForm->Pen->BasicThick; switch (MainImageForm->CurrentUnit) { case uDot : eLength1->Value = p; break; case uInch: eLength1->Value = p / MainImageForm->CanvasInfor.DotsPerInch; break; //Format("%.2f", OPENARRAY(TVarRec, (p / MainImageForm->CanvasInfor.DotsPerInch))); break; case uCm : eLength1->Value = p / MainImageForm->CanvasInfor.DotsPerInch * 2.54; break; //Format("%.2f", OPENARRAY(TVarRec, (p / MainImageForm->CanvasInfor.DotsPerInch * 2.54))); } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::dot_line_mark(int len, Byte *bb, int *value) { BEGIN_LOG("Draw_F"); int i, j, k, l, sx, ex; int cnt, dot, grade, total, ls, le; double lng, gap; lng = len; sx = 0; ex = lng; lng = lng+1; gap = (double)(value[0]+value[1])*PenManagerForm->Pen->BasicThick; cnt = lng / gap + 1; grade = (value[0]+value[1])*2; dot = (value[0]-1)*2; total = cnt * grade; for (i=0; iiMainImage; c = PaletteForm->DIB256Palette->GetFGCOLORREF(Image->uBitmap->BitsPerPixel); pw = PenManagerForm->Pen->BasicThick; lr = abs(Csx - Lsx) - pw / 2.0; sr = abs(Csy - Lsy) - pw / 2.0; r = sqrt(lr * lr + sr * sr); l = 2 * M_PI * r + 0.5; dc = new Byte[l+10]; memset(dc, 0, l+10); dot_line_mark(l, dc, value); Image->uBitmap->StartScanLine(); if (Image->LayerMask) Image->LayerMask->StartScanLine(); if (Image->Mask) Image->Mask->StartScanLine(); i = 0; while (i < r * 0.75) { j = sqrt(r * r - i * i) + 0.5; x = i; y = j; len = dot_pos(x, y, r); if (dc[len]) { Lsx = Csx + i; Lsy = Csy + j; MainImageForm->dotted_pen(Lsx, Lsy, Csx, Csy, c); } len = dot_pos(x, -y, r); if (dc[len]) { Lsx = Csx + i; Lsy = Csy - j; MainImageForm->dotted_pen(Lsx, Lsy, Csx, Csy, c); } len = dot_pos(-x, y, r); if (dc[len]) { Lsx = Csx - i; Lsy = Csy + j; MainImageForm->dotted_pen(Lsx, Lsy, Csx, Csy, c); } len = dot_pos(-x, -y, r); if (dc[len]) { Lsx = Csx - i; Lsy = Csy - j; MainImageForm->dotted_pen(Lsx, Lsy, Csx, Csy, c); } len = dot_pos(y, x, r); if (dc[len]) { Lsx = Csx + j; Lsy = Csy + i; MainImageForm->dotted_pen(Lsx, Lsy, Csx, Csy, c); } len = dot_pos(y, -x, r); if (dc[len]) { Lsx = Csx + j; Lsy = Csy - i; MainImageForm->dotted_pen(Lsx, Lsy, Csx, Csy, c); } len = dot_pos(-y, x, r); if (dc[len]) { Lsx = Csx - j; Lsy = Csy + i; MainImageForm->dotted_pen(Lsx, Lsy, Csx, Csy, c); } len = dot_pos(-y, -x, r); if (dc[len]) { Lsx = Csx - j; Lsy = Csy - i; MainImageForm->dotted_pen(Lsx, Lsy, Csx, Csy, c); } i++; // Image->Repaint(); //////////////////////////////////test } if (dc) { delete[] dc; dc = 0; } if (Image->Mask) Image->Mask->StopScanLine(); if (Image->LayerMask) Image->LayerMask->StopScanLine(); Image->uBitmap->StopScanLine(); //by jeegeo Image->Repaint(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::ellipse(TPenMode ch, COLORREF fc) { BEGIN_LOG("Draw_F"); int i, j, sx, la, sa, lb, sb, lb2, sb2, a, b, pw; int lx, ly, dia, hx, hy; TTexpiaBitmap *tb = NULL; HDC dc = NULL; HPEN hPen = NULL; int x, y, xx, ls, rs; BYTE *bp; TPItemImage *Image = MainImageForm->iMainImage; TPException ec = EC_NONE; int CenterX = Csx; int CenterY = Csy; if (!hasUserLength) { a = 2 * abs(Lsx - CenterX) + 1; b = 2 * abs(Lsy - CenterY) + 1; } else { if(Ell_rx == 0)a = 13; else a = Ell_rx; if(Ell_ry == 0)b = 13; else b = Ell_ry; } int posx = 0, posy = 0; if (Image->Reflection && MainImageForm->reflection){ int wx = 0, hy = 0; if (MainImageForm->reflection->WorkSide == D_RIGHT){ wx = MainImageForm->reflection->BitmapWidth; // } else if (MainImageForm->reflection->WorkSide == D_LEFT){ // CenterX = MainImageForm->reflection->BitmapWidth - CenterX; } else if (MainImageForm->reflection->WorkSide == D_BOTTOM){ hy = MainImageForm->reflection->BitmapHeight; } // else if (MainImageForm->reflection->WorkSide == D_TOP){ // CenterY = MainImageForm->reflection->BitmapHeight - CenterY; // } posx = MainImageForm->reflection->BitmapRange.left - wx; posy = MainImageForm->reflection->BitmapRange.top - hy; } if (a < PenManagerForm->Pen->Thick) a = PenManagerForm->Pen->Thick; // by celberus ¹ÝÁö¸§ÀÌ ÀÛÀ»¶§ »ç°¢ÇüÀ¸·Î ±×·ÁÁö´Â ¿À·ù ¶§¹®¿¡.. if (b < PenManagerForm->Pen->Thick) b = PenManagerForm->Pen->Thick; // by celberus ¹ÝÁö¸§ÀÌ ÀÛÀ»¶§ »ç°¢ÇüÀ¸·Î ±×·ÁÁö´Â ¿À·ù ¶§¹®¿¡.. hx = a / 2; hy = b / 2; if (ch == pmXor) { DrawEllipseLocate(Rect(Csx - hx, Csy - hy, Csx - hx + a + 1, Csy - hy + b + 1)); if (IsDraw) {IsDraw = false; MainImageForm->iMainImage->OnPaintLocate = NULL;/////////////////by jeegeo }else IsDraw = true; } else if (ch == pmCopy) { if (PenManagerForm->sbMask->Down) { if (!(Image->Mask->StartScanLine())) {ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail;} } else { if (!(Image->uBitmap->StartScanLine())) {ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail;} if (Image->LayerMask) { if (!(Image->LayerMask->StartScanLine())) {ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail;} if (MainImageForm->bProtect) if (!(Image->BackGround->StartScanLine())) {ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail;} } if (MainImageForm->MaskArea) { if (!(Image->Mask->StartScanLine())) {ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail;} } } ls = PenManagerForm->Pen->BasicThick >> 1; rs = PenManagerForm->Pen->BasicThick - ls; if ((tb = new TTexpiaBitmap)==NULL) {ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail;} if (!tb->Create(a, b, 8)) {ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail;} if ((dc = tb->CreateDC())==NULL) {ec = EC_RESOURCE_LACK; SAVE_EXCEPTION(ec); goto fail;} if (fill_not == 0) { SelectObject(dc, GetStockObject(NULL_BRUSH)); } else { SelectObject(dc, GetStockObject(WHITE_BRUSH)); } if ((hPen = CreatePen(PS_SOLID, PenManagerForm->Pen->BasicThick, clWhite))==NULL) {ec = EC_RESOURCE_LACK; SAVE_EXCEPTION(ec); goto fail;} SelectObject(dc, hPen); Ellipse(dc, ls, ls, a - rs + 1, b - rs + 1); DeleteObject(hPen); hPen = NULL; tb->DeleteDC(dc); dc = NULL; if (!tb->StartScanLine()) {ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail;} for (y = posy; y < b + posy; y++) { bp = tb->GetScanLine(y-posy); for (x = posx; x < a + posx;) { if (bp[x-posx]) { for (xx = x; xx < a + posx; xx++) { if (bp[xx-posx]==0) break; } MainImageForm->set_hline(CenterX - hx + x, CenterY - hy + y, xx - x, fc); x = xx; } else { x++; } } } tb->StopScanLine(); delete tb; if (PenManagerForm->sbMask->Down) { Image->Mask->StopScanLine(); } else { if (MainImageForm->MaskArea) Image->Mask->StopScanLine(); if (Image->LayerMask) { Image->LayerMask->StopScanLine(); if (MainImageForm->bProtect) Image->BackGround->StopScanLine(); } Image->uBitmap->StopScanLine(); } //by jeegeo Image->Repaint(); } if(Ell_rx == 0) // if(!(isw == 0 && step == 1))goto next; if(hasUserLength || step != 1)goto next; switch (MainImageForm->CurrentUnit) { case uDot : eLength1->Value = a; break; case uInch: eLength1->Value = (double)a / MainImageForm->CanvasInfor.DotsPerInch; //Format("%.2f", OPENARRAY(TVarRec, ((double)a / MainImageForm->CanvasInfor.DotsPerInch))); break; case uCm : eLength1->Value = 2.54 * a / MainImageForm->CanvasInfor.DotsPerInch; //Format("%.2f", OPENARRAY(TVarRec, (2.54 * a / MainImageForm->CanvasInfor.DotsPerInch))); } next: if(Ell_ry == 0) // if(!(isw == 0 && step == 1))return; if(hasUserLength || step != 1) { END_LOG; return; } switch (MainImageForm->CurrentUnit) { case uDot : eLength2->Value = b; break; case uInch: eLength2->Value = (double)b / MainImageForm->CanvasInfor.DotsPerInch; //Format("%.2f", OPENARRAY(TVarRec, ((double)b / MainImageForm->CanvasInfor.DotsPerInch))); break; case uCm : eLength2->Value = 2.54 * b / MainImageForm->CanvasInfor.DotsPerInch; //Format("%.2f", OPENARRAY(TVarRec, (2.54 * b / MainImageForm->CanvasInfor.DotsPerInch))); } END_LOG; return; fail: if (tb) { if (dc) tb->DeleteDC(dc); delete tb; } if (Image->Mask) Image->Mask->StopScanLine(); if (Image->LayerMask) Image->LayerMask->StopScanLine(); if (MainImageForm->bProtect) Image->BackGround->StopScanLine(); Image->uBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::dotted_ellipse(TPenMode ch, int *value) { BEGIN_LOG("Draw_F"); Byte *de = 0; int i, g, a, b, a1, b1, pw; double ratio, cmp; COLORREF c; TPItemImage *Image = MainImageForm->iMainImage; c = PaletteForm->DIB256Palette->GetFGCOLORREF(Image->uBitmap->BitsPerPixel); pw = PenManagerForm->Pen->BasicThick; a = abs(Lsx - Csx) - pw / 2.0; b = abs(Lsy - Csy) - pw / 2.0; if (a <= 0) a = 1; // by celberus a, b°¡ À½¼ö°¡ ³ª¿À´Â ¿¡·¯ ¶§¹®¿¡.. divide by zero µµ.. if (b <= 0) b = 1; // by celberus a, b°¡ À½¼ö°¡ ³ª¿À´Â ¿¡·¯ ¶§¹®¿¡.. // if (a == 0 && b == 0) return; Image->uBitmap->StartScanLine(); if (Image->LayerMask) Image->LayerMask->StartScanLine(); if (Image->Mask) Image->Mask->StartScanLine(); double len = a*2.0*M_PI*((double)(b+a)/(double)(2*a)); de = new Byte[len + 10]; memset(de, 0, len + 10); dot_line_mark(len, de, value); i = 0; while (i < len) { if (de[i]) { Lsx = Csx + a*cos(i/len*2.0*M_PI) + 0.5; Lsy = Csy - b*sin(i/len*2.0*M_PI) + 0.5; MainImageForm->dotted_pen(Lsx, Lsy, Csx, Csy, c); } i++; } if (Image->Mask) Image->Mask->StopScanLine(); if (Image->LayerMask) Image->LayerMask->StopScanLine(); Image->uBitmap->StopScanLine(); if (de) { delete[] de; de = NULL; } //by jeegeo Image->Repaint(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::LenAng_check(int x, int y) { BEGIN_LOG("Draw_F"); double dx, dy, alpha, length; TPItemImage *Image = MainImageForm->iMainImage; //============================================================================== if(Ltype[TD_LINE].sw == 0){ //½Ç¼±À϶§.// dx = x - Lsx; dy = y - Lsy; if ((Asw == 2) && (Lsw == 0)) { length = sqrt(dx * dx + dy * dy); if (x > Lsx) { if (y > Lsy) { //I alpha = Line_angle * (M_PI / 180.0); Lex = Lsx + length * cos(alpha); Ley = Lsy + length * sin(alpha); if (Lex >= Image->uBitmap->Width) { Lex = Image->uBitmap->Width - 1; Ley = Lsy + (Lex - Lsx) * tan(alpha); } if (Ley >= Image->uBitmap->Height) { Ley = Image->uBitmap->Height - 1; Lex = Lsx + (Ley - Lsy) / tan(alpha); } } else { //IV alpha = (Line_angle + 270.0) * (M_PI / 180.0); Lex = Lsx + length * cos(alpha) + 0.5; Ley = Lsy + length * sin(alpha); if (Lex >= Image->uBitmap->Width) { Lex = Image->uBitmap->Width - 1; Ley = Lsy + (Lex - Lsx) * tan(alpha); } if (Ley < 0) { Ley = 0; Lex = Lsx + (Ley - Lsy) / tan(alpha); } } } else { if (y > Lsy) { //II alpha = (Line_angle + 90) * (M_PI / 180.0); Lex = Lsx + length * cos(alpha); Ley = Lsy + length * sin(alpha); if (Lex < 0) { Lex = 0; Ley = Lsy + (Lex - Lsx) * tan(alpha); } if (Ley >= Image->uBitmap->Height) { Ley = Image->uBitmap->Height - 1; Lex = Lsx + (Ley - Lsy) / tan(alpha); } } else { //III alpha = (Line_angle + 180.0) * (M_PI / 180.0); Lex = Lsx + length * cos(alpha); Ley = Lsy + length * sin(alpha); if (Lex < 0) { Lex = 0; Ley = Lsy + (Lex - Lsx) * tan(alpha); } if (Ley < 0) { Ley = 0; Lex = Lsx + (Ley - Lsy) / tan(alpha); } } } } else if ((Asw == 0) && (Lsw == 2)) { if ((dy == 0) && (dx == 0)) alpha = M_PI_2; else alpha = atan2(dy, dx); Lex = Lsx + Line_len * cos(alpha) + 0.5; Ley = Lsy + Line_len * sin(alpha) + 0.5; if (x > Lsx) { if (y > Lsy) { //I if (Lex >= Image->uBitmap->Width) { Lex = Image->uBitmap->Width - 1; Ley = Lsy + (Lex - Lsx) * tan(alpha); } if (Ley >= Image->uBitmap->Height) { Ley = Image->uBitmap->Height - 1; Lex = Lsx + (Ley - Lsy) / tan(alpha); } } else { //IV if (Lex >= Image->uBitmap->Width) { Lex = Image->uBitmap->Width - 1; Ley = Lsy + (Lex - Lsx) * tan(alpha); } if (Ley < 0) { Ley = 0; Lex = Lsx + (Ley - Lsy) / tan(alpha); } } } else { if (y > Lsy) { //II if (Lex < 0) { Lex = 0; Ley = Lsy + (Lex - Lsx + 1) * tan(alpha); } if (Ley >= Image->uBitmap->Height) { Ley = Image->uBitmap->Height - 1; Lex = Lsx + (Ley - Lsy) / tan(alpha); } } else { //III if (Lex < 0) { Lex = 0; Ley = Lsy + (Lex - Lsx) * tan(alpha); } if (Ley < 0) { Ley = 0; Lex = Lsx + (Ley - Lsy) / tan(alpha); } } } } else if ((Asw == 2) && (Lsw == 2)) { if (x > Lsx) { if (y > Lsy) { //I alpha = Line_angle * (M_PI / 180.0); Lex = Lsx + Line_len * cos(alpha) + 0.5; Ley = Lsy + Line_len * sin(alpha) + 0.5; if (Lex >= Image->uBitmap->Width) { Lex = Image->uBitmap->Width - 1; Ley = Lsy + (Lex - Lsx) * tan(alpha); } if (Ley >= Image->uBitmap->Height) { Ley = Image->uBitmap->Height - 1; Lex = Lsx + (Ley - Lsy) / tan(alpha); } } else { //IV alpha = (Line_angle + 270.0) * (M_PI / 180.0); Lex = Lsx + Line_len * cos(alpha) + 0.5; Ley = Lsy + Line_len * sin(alpha) + 0.5; if (Lex >= Image->uBitmap->Width) { Lex = Image->uBitmap->Width - 1; Ley = Lsy + (Lex - Lsx) * tan(alpha); } if (Ley < 0) { Ley = 0; Lex = Lsx + (Ley - Lsy) / tan(alpha); } } } else { if (y > Lsy) { //II alpha = (Line_angle + 90.0) * (M_PI / 180.0); Lex = Lsx + Line_len * cos(alpha) + 0.5; Ley = Lsy + Line_len * sin(alpha) + 0.5; if (Lex < 0) { Lex = 0; Ley = Lsy + (Lex - Lsx) * tan(alpha); } if (Ley >= Image->uBitmap->Height) { Ley = Image->uBitmap->Height - 1; Lex = Lsx + (Ley - Lsy) / tan(alpha); } } else { //III alpha = (Line_angle + 180.0) * (M_PI / 180.0); Lex = Lsx + Line_len * cos(alpha) + 0.5; Ley = Lsy + Line_len * sin(alpha) + 0.5; if (Lex < 0) { Lex = 0; Ley = Lsy + (Lex - Lsx) * tan(alpha); } if (Ley < 0) { Ley = 0; Lex = Lsx + (Ley - Lsy) / tan(alpha); } } } } //============================================================================== }else if(Ltype[TD_LINE].sw == 1){ //Á¡¼±À϶§.// dx = x - Tstitch.l[1].sx; dy = y - Tstitch.l[1].sy; if ((Asw == 2) && (Lsw == 0)) { length = sqrt(dx * dx + dy * dy); if (x > Tstitch.l[1].sx) { if (y > Tstitch.l[1].sy) { //I alpha = Line_angle * (M_PI / 180.0); Tstitch.l[1].ex = Tstitch.l[1].sx + length * cos(alpha); Tstitch.l[1].ey = Tstitch.l[1].sy + length * sin(alpha); if (Tstitch.l[1].ex >= Image->uBitmap->Width) { Tstitch.l[1].ex = Image->uBitmap->Width - 1; Tstitch.l[1].ey = Tstitch.l[1].sy + (Tstitch.l[1].ex - Tstitch.l[1].sx) * tan(alpha); } if (Tstitch.l[1].ey >= Image->uBitmap->Height) { Tstitch.l[1].ey = Image->uBitmap->Height - 1; Tstitch.l[1].ex = Tstitch.l[1].sx + (Tstitch.l[1].ey - Tstitch.l[1].sy) / tan(alpha); } } else { //IV alpha = (Line_angle + 270.0) * (M_PI / 180.0); Tstitch.l[1].ex = Tstitch.l[1].sx + length * cos(alpha) + 0.5; Tstitch.l[1].ey = Tstitch.l[1].sy + length * sin(alpha); if (Tstitch.l[1].ex >= Image->uBitmap->Width) { Tstitch.l[1].ex = Image->uBitmap->Width - 1; Tstitch.l[1].ey = Tstitch.l[1].sy + (Tstitch.l[1].ex - Tstitch.l[1].sx) * tan(alpha); } if (Tstitch.l[1].ey < 0) { Tstitch.l[1].ey = 0; Tstitch.l[1].ex = Tstitch.l[1].sx + (Tstitch.l[1].ey - Tstitch.l[1].sy) / tan(alpha); } } } else { if (y > Tstitch.l[1].sy) { //II alpha = (Line_angle + 90) * (M_PI / 180.0); Tstitch.l[1].ex = Tstitch.l[1].sx + length * cos(alpha); Tstitch.l[1].ey = Tstitch.l[1].sy + length * sin(alpha); if (Tstitch.l[1].ex < 0) { Tstitch.l[1].ex = 0; Tstitch.l[1].ey = Tstitch.l[1].sy + (Tstitch.l[1].ex - Tstitch.l[1].sx) * tan(alpha); } if (Tstitch.l[1].ey >= Image->uBitmap->Height) { Tstitch.l[1].ey = Image->uBitmap->Height - 1; Tstitch.l[1].ex = Tstitch.l[1].sx + (Tstitch.l[1].ey - Tstitch.l[1].sy) / tan(alpha); } } else { //III alpha = (Line_angle + 180.0) * (M_PI / 180.0); Tstitch.l[1].ex = Tstitch.l[1].sx + length * cos(alpha); Tstitch.l[1].ey = Tstitch.l[1].sy + length * sin(alpha); if (Tstitch.l[1].ex < 0) { Tstitch.l[1].ex = 0; Tstitch.l[1].ey = Tstitch.l[1].sy + (Tstitch.l[1].ex - Tstitch.l[1].sx) * tan(alpha); } if (Tstitch.l[1].ey < 0) { Tstitch.l[1].ey = 0; Tstitch.l[1].ex = Tstitch.l[1].sx + (Tstitch.l[1].ey - Tstitch.l[1].sy) / tan(alpha); } } } } else if ((Asw == 0) && (Lsw == 2)) { if ((dy == 0) && (dx == 0)) alpha = M_PI_2; else alpha = atan2(dy, dx); Tstitch.l[1].ex = Tstitch.l[1].sx + Line_len * cos(alpha) + 0.5; Tstitch.l[1].ey = Tstitch.l[1].sy + Line_len * sin(alpha) + 0.5; if (x > Tstitch.l[1].sx) { if (y > Tstitch.l[1].sy) { //I if (Lex >= Image->uBitmap->Width) { Tstitch.l[1].ex = Image->uBitmap->Width - 1; Tstitch.l[1].ey = Tstitch.l[1].sy + (Tstitch.l[1].ex - Tstitch.l[1].sx) * tan(alpha); } if (Tstitch.l[1].ey >= Image->uBitmap->Height) { Tstitch.l[1].ey = Image->uBitmap->Height - 1; Tstitch.l[1].ex = Tstitch.l[1].sx + (Tstitch.l[1].ey - Tstitch.l[1].sy) / tan(alpha); } } else { //IV if (Tstitch.l[1].ex >= Image->uBitmap->Width) { Tstitch.l[1].ex = Image->uBitmap->Width - 1; Tstitch.l[1].ey = Tstitch.l[1].sy + (Tstitch.l[1].ex - Tstitch.l[1].sx) * tan(alpha); } if (Tstitch.l[1].ey < 0) { Tstitch.l[1].ey = 0; Tstitch.l[1].ex = Tstitch.l[1].sx + (Tstitch.l[1].ey - Tstitch.l[1].sy) / tan(alpha); } } } else { if (y > Tstitch.l[1].sy) { //II if (Tstitch.l[1].ex < 0) { Tstitch.l[1].ex = 0; Tstitch.l[1].ey = Tstitch.l[1].sy + (Tstitch.l[1].ex - Tstitch.l[1].sx + 1) * tan(alpha); } if (Tstitch.l[1].ey >= Image->uBitmap->Height) { Tstitch.l[1].ey = Image->uBitmap->Height - 1; Tstitch.l[1].ex = Tstitch.l[1].sx + (Tstitch.l[1].ey - Tstitch.l[1].sy) / tan(alpha); } } else { //III if (Tstitch.l[1].ex < 0) { Tstitch.l[1].ex = 0; Tstitch.l[1].ey = Tstitch.l[1].sy + (Tstitch.l[1].ex - Tstitch.l[1].sx) * tan(alpha); } if (Tstitch.l[1].ey < 0) { Tstitch.l[1].ey = 0; Tstitch.l[1].ex = Tstitch.l[1].sx + (Tstitch.l[1].ey - Tstitch.l[1].sy) / tan(alpha); } } } } else if ((Asw == 2) && (Lsw == 2)) { if (x > Tstitch.l[1].sx) { if (y > Tstitch.l[1].sy) { //I alpha = Line_angle * (M_PI / 180.0); Tstitch.l[1].ex = Tstitch.l[1].sx + Line_len * cos(alpha) + 0.5; Tstitch.l[1].ey = Tstitch.l[1].sy + Line_len * sin(alpha) + 0.5; if (Tstitch.l[1].ex >= Image->uBitmap->Width) { Tstitch.l[1].ex = Image->uBitmap->Width - 1; Tstitch.l[1].ey = Tstitch.l[1].sy + (Tstitch.l[1].ex - Tstitch.l[1].sx) * tan(alpha); } if (Tstitch.l[1].ey >= Image->uBitmap->Height) { Tstitch.l[1].ey = Image->uBitmap->Height - 1; Tstitch.l[1].ex = Tstitch.l[1].sx + (Tstitch.l[1].ey - Tstitch.l[1].sy) / tan(alpha); } } else { //IV alpha = (Line_angle + 270.0) * (M_PI / 180.0); Tstitch.l[1].ex = Tstitch.l[1].sx + Line_len * cos(alpha) + 0.5; Tstitch.l[1].ey = Tstitch.l[1].sy + Line_len * sin(alpha) + 0.5; if (Tstitch.l[1].ex >= Image->uBitmap->Width) { Tstitch.l[1].ex = Image->uBitmap->Width - 1; Tstitch.l[1].ey = Tstitch.l[1].sy + (Tstitch.l[1].ex - Tstitch.l[1].sx) * tan(alpha); } if (Tstitch.l[1].ey < 0) { Tstitch.l[1].ey = 0; Tstitch.l[1].ex = Tstitch.l[1].sx + (Tstitch.l[1].ey - Tstitch.l[1].sy) / tan(alpha); } } } else { if (y > Tstitch.l[1].sy) { //II alpha = (Line_angle + 90.0) * (M_PI / 180.0); Tstitch.l[1].ex = Tstitch.l[1].sx + Line_len * cos(alpha) + 0.5; Tstitch.l[1].ey = Tstitch.l[1].sy + Line_len * sin(alpha) + 0.5; if (Tstitch.l[1].ex < 0) { Tstitch.l[1].ex = 0; Tstitch.l[1].ey = Tstitch.l[1].sy + (Tstitch.l[1].ex - Tstitch.l[1].sx) * tan(alpha); } if (Tstitch.l[1].ey >= Image->uBitmap->Height) { Tstitch.l[1].ey = Image->uBitmap->Height - 1; Tstitch.l[1].ex = Tstitch.l[1].sx + (Tstitch.l[1].ey - Tstitch.l[1].sy) / tan(alpha); } } else { //III alpha = (Line_angle + 180.0) * (M_PI / 180.0); Tstitch.l[1].ex = Tstitch.l[1].sx + Line_len * cos(alpha) + 0.5; Tstitch.l[1].ey = Tstitch.l[1].sy + Line_len * sin(alpha) + 0.5; if (Tstitch.l[1].ex < 0) { Tstitch.l[1].ex = 0; Tstitch.l[1].ey = Tstitch.l[1].sy + (Tstitch.l[1].ex - Tstitch.l[1].sx) * tan(alpha); } if (Tstitch.l[1].ey < 0) { Tstitch.l[1].ey = 0; Tstitch.l[1].ex = Tstitch.l[1].sx + (Tstitch.l[1].ey - Tstitch.l[1].sy) / tan(alpha); } } } } } END_LOG; //============================================================================== } //---------------------------------------------------------------------------- void __fastcall TDrawForm::DotLineLocate(HDC dc, int x, int y, void *pData) { BEGIN_LOG("Draw_F"); TPLayerImage *image=MainImageForm->iMainImage; int i, sx, sy, ex, ey, lx, ly; int cnt, dx, dy; double lng, gap, th, ct, st, p; int ccsx, ccsy, ccex, ccey; HPEN hPen = NULL, hOldPen; if (image->ZoomIn <= image->ZoomOut) { hPen = CreatePen(PS_SOLID, DrawLocate[Item].szPen*image->ZoomIn/image->ZoomOut+0.5, DrawLocate[Item].clPen); } else { hPen = CreatePen(PS_SOLID, DrawLocate[Item].szPen, DrawLocate[Item].clPen); } // by celberus zoomIn ÇßÀ»¶§ ²ÞƲ°Å¸®´Â ¹®Á¦ ¶§¹®¿¡.. if (hPen!=NULL) { hOldPen = (HPEN)SelectObject(dc, hPen); sx = Tstitch.l[1].sx; sy = Tstitch.l[1].sy; ex = Tstitch.l[1].ex; ey = Tstitch.l[1].ey; lx = ex - sx; ly = ey - sy; if ((ly == 0) && (lx == 0)) th = 0; else th = atan2(ly, lx); ct = cos(th); st = sin(th); lng = sqrt(lx * lx + ly * ly); gap = (Ltype[Item].value[0] + Ltype[Item].value[1]) * PenManagerForm->Pen->BasicThick; cnt = lng / gap + 1; if ((Item == TD_LINE) || (Item == TD_CURVE)) { ccsx = Lsx; ccsy = Lsy; ccex = Lex; ccey = Ley; for (i = 0; i < cnt; i++) { if (gap * i <= lng) { Lsx = (gap * i) * ct + sx + 0.5; Lsy = (gap * i) * st + sy + 0.5; if ((gap * i + ((Ltype[Item].value[0] - 1) * PenManagerForm->Pen->BasicThick)) <= lng) { Lex = (gap * i + ((Ltype[Item].value[0] - 1) * PenManagerForm->Pen->BasicThick)) * ct + sx + 0.5; Ley = (gap * i + ((Ltype[Item].value[0] - 1) * PenManagerForm->Pen->BasicThick)) * st + sy + 0.5; } else { Lex = lng * ct + sx; Ley = lng * st + sy; } if(Lsx < Lex)Lex += 1; else if(Lsx > Lex)Lex -= 1; if(Lsy < Ley)Ley += 1; else if(Lsy > Ley)Ley -= 1; if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); } } } Lsx = ccsx; Lsy = ccsy; Lex = ccex; Ley = ccey; } else { ccsx = Lsx; ccsy = Lsy; ccex = Lex; ccey = Ley; for (i = 0; i < cnt; i++) { if (gap * i <= lng) { Lsx = (gap * i) * ct + sx + 0.5; Lsy = (gap * i) * st + sy + 0.5; if ((gap * i + ((Ltype[Item].value[0] - 1) * PenManagerForm->Pen->BasicThick)) <= lng) { Lex = (gap * i + ((Ltype[Item].value[0] - 1) * PenManagerForm->Pen->BasicThick)) * ct + sx + 0.5; Ley = (gap * i + ((Ltype[Item].value[0] - 1) * PenManagerForm->Pen->BasicThick)) * st + sy + 0.5; } else { Lex = lng * ct + sx; Ley = lng * st + sy; } if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); } } } Lsx = ccsx; Lsy = ccsy; Lex = ccex; Ley = ccey; } SelectObject(dc, hOldPen); DeleteObject(hPen); } END_LOG; } //---------------------------------------------------------------------------- void __fastcall TDrawForm::Reflection_DotLineLocate(HDC dc, int x, int y, void *pData) { BEGIN_LOG("Draw_F"); TPLayerImage *image=MainImageForm->iMainImage; int i, sx, sy, ex, ey, lx, ly; int cnt, dx, dy; double lng, gap, th, ct, st, p; int ccsx, ccsy, ccex, ccey; HPEN hPen = NULL, hOldPen; if (image->ZoomIn <= image->ZoomOut) { hPen = CreatePen(PS_SOLID, DrawLocate[Item].szPen*image->ZoomIn/image->ZoomOut+0.5, DrawLocate[Item].clPen); } else { hPen = CreatePen(PS_SOLID, DrawLocate[Item].szPen, DrawLocate[Item].clPen); } // by celberus zoomIn ÇßÀ»¶§ ²ÞƲ°Å¸®´Â ¹®Á¦ ¶§¹®¿¡.. if (hPen!=NULL) { hOldPen = (HPEN)SelectObject(dc, hPen); sx = Tstitch.l[1].sx; sy = Tstitch.l[1].sy; ex = Tstitch.l[1].ex; ey = Tstitch.l[1].ey; lx = ex - sx; ly = ey - sy; if ((ly == 0) && (lx == 0)) th = 0; else th = atan2(ly, lx); ct = cos(th); st = sin(th); lng = sqrt(lx * lx + ly * ly); gap = (Ltype[Item].value[0] + Ltype[Item].value[1]) * PenManagerForm->Pen->BasicThick; cnt = lng / gap + 1; if ((Item == TD_LINE) || (Item == TD_CURVE)) { ccsx = Lsx; ccsy = Lsy; ccex = Lex; ccey = Ley; for (i = 0; i < cnt; i++) { if (gap * i <= lng) { Lsx = (gap * i) * ct + sx + 0.5; Lsy = (gap * i) * st + sy + 0.5; if ((gap * i + ((Ltype[Item].value[0] - 1) * PenManagerForm->Pen->BasicThick)) <= lng) { Lex = (gap * i + ((Ltype[Item].value[0] - 1) * PenManagerForm->Pen->BasicThick)) * ct + sx + 0.5; Ley = (gap * i + ((Ltype[Item].value[0] - 1) * PenManagerForm->Pen->BasicThick)) * st + sy + 0.5; } else { Lex = lng * ct + sx; Ley = lng * st + sy; } if(Lsx < Lex)Lex += 1; else if(Lsx > Lex)Lex -= 1; if(Lsy < Ley)Ley += 1; else if(Lsy > Ley)Ley -= 1; POINT pts, pte; pts = MainImageForm->reflection->FindScreenReflectionPos(Lsx, Lsy); pte = MainImageForm->reflection->FindScreenReflectionPos(Lex, Ley); if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); MoveToEx(dc, image->BitmapToCanvasX(pts.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(pts.y) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(pte.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(pte.y) - image->BitmapToCanvasY(y)); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); MoveToEx(dc, pts.x - x, pts.y - y, NULL); LineTo(dc, pte.x - x, pte.y - y); } } } Lsx = ccsx; Lsy = ccsy; Lex = ccex; Ley = ccey; } else { ccsx = Lsx; ccsy = Lsy; ccex = Lex; ccey = Ley; for (i = 0; i < cnt; i++) { if (gap * i <= lng) { Lsx = (gap * i) * ct + sx + 0.5; Lsy = (gap * i) * st + sy + 0.5; if ((gap * i + ((Ltype[Item].value[0] - 1) * PenManagerForm->Pen->BasicThick)) <= lng) { Lex = (gap * i + ((Ltype[Item].value[0] - 1) * PenManagerForm->Pen->BasicThick)) * ct + sx + 0.5; Ley = (gap * i + ((Ltype[Item].value[0] - 1) * PenManagerForm->Pen->BasicThick)) * st + sy + 0.5; } else { Lex = lng * ct + sx; Ley = lng * st + sy; } POINT pts, pte; pts = MainImageForm->reflection->FindScreenReflectionPos(Lsx, Lsy); pte = MainImageForm->reflection->FindScreenReflectionPos(Lex, Ley); if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); MoveToEx(dc, image->BitmapToCanvasX(pts.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(pts.y) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(pte.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(pte.y) - image->BitmapToCanvasY(y)); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); MoveToEx(dc, pts.x - x, pts.y - y, NULL); LineTo(dc, pte.x - x, pte.y - y); } } } Lsx = ccsx; Lsy = ccsy; Lex = ccex; Ley = ccey; } SelectObject(dc, hOldPen); DeleteObject(hPen); } END_LOG; } //---------------------------------------------------------------------------- void __fastcall TDrawForm::DrawDotLineLocate(POINT First, POINT Second) { BEGIN_LOG("Draw_F"); RECT rt, Src, Dst; int ls, rs; TPItemImage *Image = MainImageForm->iMainImage; ls = PenManagerForm->Pen->BasicThick >> 1; rs = PenManagerForm->Pen->BasicThick - ls; if (ls == 0) ls = 1; if (rs == 0) rs = 1; rt.left = min(First.x, Second.x) - 1; rt.top = min(First.y, Second.y) - 1; rt.right = max(First.x, Second.x) + 1; rt.bottom = max(First.y, Second.y) + 1; Src.left = rt.left - ls * 2; Src.top = rt.top - ls * 2; Src.right = rt.right + rs * 2; Src.bottom = rt.bottom + rs * 2; if (Image->Reflection && MainImageForm->reflection){ POINT st, et; st = MainImageForm->reflection->FindScreenReflectionPos(First.x, First.y); et = MainImageForm->reflection->FindScreenReflectionPos(Second.x, Second.y); RECT Ref; Ref.left = min(Src.left, min(st.x, et.x)) - rs*2; Ref.top = min(Src.top, min(st.y, et.y)) - rs*2; Ref.right = max(Src.right, max(st.x, et.x)) + ls*2; Ref.bottom = max(Src.bottom, max(st.y, et.y)) + ls*2; UnionRect(&Dst, &Ref, &DrawLocate[Item].rtInvalidate); DrawLocate[Item].szPen = PenManagerForm->Pen->BasicThick; DrawLocate[Item].clPen = MainImageForm->Palette->Color[PaletteForm->DIB256Palette->ChoiceIndex]; DrawLocate[Item].ptFirst.x = rt.left; DrawLocate[Item].ptFirst.y = rt.top; DrawLocate[Item].ptSecond.x = rt.right; DrawLocate[Item].ptSecond.y = rt.bottom; Image->RectEditPaint(Dst, Reflection_DotLineLocate, NULL); DrawLocate[Item].rtInvalidate = Ref; } else { UnionRect(&Dst, &Src, &DrawLocate[Item].rtInvalidate); DrawLocate[Item].szPen = PenManagerForm->Pen->BasicThick; DrawLocate[Item].clPen = MainImageForm->Palette->Color[PaletteForm->DIB256Palette->ChoiceIndex]; DrawLocate[Item].ptFirst.x = rt.left; DrawLocate[Item].ptFirst.y = rt.top; DrawLocate[Item].ptSecond.x = rt.right; DrawLocate[Item].ptSecond.y = rt.bottom; Image->RectEditPaint(Dst, DotLineLocate, NULL); DrawLocate[Item].rtInvalidate = Src; } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::LineLocate(HDC dc, int x, int y, void *pData) { BEGIN_LOG("Draw_F"); TPLayerImage *image=MainImageForm->iMainImage; HPEN hPen = NULL, hOldPen; LOGBRUSH lb; // ·Î±× ºê·¯½¬. ExtCreatePen Çϱâ À§ÇÏ¿© by tmddn85 lb.lbColor = DrawLocate[Item].clPen; lb.lbStyle = BS_SOLID; // Start: ±âÁ¸ ±×¸®±â¿¡¼­´Â ¸¶¿ì½º Æ÷ÀÎÅ͸¦ À̹ÌÁö¿¡ Âï¾úÀ» Àû¿¡ µ¿±×¶ó¹Ì°¡ ±×·ÁÁö°í ±× ´ÙÀ½¿¡ ¸¶¿ì½º¸¦ ³õ¾ÒÀ» ¶§ // ³×¸ð°¡ ±×·ÁÁ³´Ù. ExtCreatePenÀ» »ç¿ëÇÏ¿© ENDCAP_SQUARE±â´ÉÀ» ÀÌ¿ëÇØ º¸°íÀÚ ÇÑ´Ù. by tmddn85 if (image->ZoomIn <= image->ZoomOut) { // hPen = CreatePen(PS_SOLID, DrawLocate[Item].szPen*image->ZoomIn/image->ZoomOut+0.5, DrawLocate[Item].clPen); // ±âÁ¸ ÆæÀ» È®À寿À¸·Î ´ëü if (PenManagerForm->Pen->Shape == 0){ // PenManger¿¡¼­ Á¤º¸¸¦ ¾ò¾î¿Í¼­ RoundÀÎÁö SquareÀÎÁö °áÁ¤ÇÑ´Ù. by tmddn85 hPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_ROUND, DrawLocate[Item].szPen*image->ZoomIn/image->ZoomOut+0.5, &lb, 0, NULL); } else if (PenManagerForm->Pen->Shape == 1){ hPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_SQUARE, DrawLocate[Item].szPen*image->ZoomIn/image->ZoomOut+0.5, &lb, 0, NULL); } } else { // hPen = CreatePen(PS_SOLID, DrawLocate[Item].szPen, DrawLocate[Item].clPen); // ±âÁ¸ ÆæÀ» È®À寿À¸·Î ´ëü if (PenManagerForm->Pen->Shape == 0){ hPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_ROUND, DrawLocate[Item].szPen, &lb, 0, NULL); } else if (PenManagerForm->Pen->Shape ==1){ hPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_SQUARE, DrawLocate[Item].szPen, &lb, 0, NULL); } } // by celberus zoomIn ÇßÀ»¶§ ²ÞƲ°Å¸®´Â ¹®Á¦ ¶§¹®¿¡.. if (hPen!=NULL) { hOldPen = (HPEN)SelectObject(dc, hPen); if(DrawLocate[Item].ptFirst.x < DrawLocate[Item].ptSecond.x)DrawLocate[Item].ptSecond.x += 1; else if(DrawLocate[Item].ptFirst.x > DrawLocate[Item].ptSecond.x)DrawLocate[Item].ptSecond.x -= 1; if(DrawLocate[Item].ptFirst.y < DrawLocate[Item].ptSecond.y)DrawLocate[Item].ptSecond.y += 1; else if(DrawLocate[Item].ptFirst.y > DrawLocate[Item].ptSecond.y)DrawLocate[Item].ptSecond.y -= 1; if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(DrawLocate[Item].ptFirst.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(DrawLocate[Item].ptFirst.y) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(DrawLocate[Item].ptSecond.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(DrawLocate[Item].ptSecond.y) - image->BitmapToCanvasY(y) ); } else { MoveToEx(dc, DrawLocate[Item].ptFirst.x - x, DrawLocate[Item].ptFirst.y - y, NULL); LineTo(dc, DrawLocate[Item].ptSecond.x - x, DrawLocate[Item].ptSecond.y - y); } SelectObject(dc, hOldPen); DeleteObject(hPen); } END_LOG; } //---------------------------------------------------------------------------- void __fastcall TDrawForm::Reflection_LineLocate(HDC dc, int x, int y, void *pData) { BEGIN_LOG("Draw_F"); TPLayerImage *image=MainImageForm->iMainImage; HPEN hPen = NULL, hOldPen; LOGBRUSH lb; // ·Î±× ºê·¯½¬. ExtCreatePen Çϱâ À§ÇÏ¿© by tmddn85 lb.lbColor = DrawLocate[Item].clPen; lb.lbStyle = BS_SOLID; if (image->ZoomIn <= image->ZoomOut) { if (PenManagerForm->Pen->Shape == 0){ // PenManger¿¡¼­ Á¤º¸¸¦ ¾ò¾î¿Í¼­ RoundÀÎÁö SquareÀÎÁö °áÁ¤ÇÑ´Ù. by tmddn85 hPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_ROUND, DrawLocate[Item].szPen*image->ZoomIn/image->ZoomOut+0.5, &lb, 0, NULL); } else if (PenManagerForm->Pen->Shape == 1){ hPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_SQUARE, DrawLocate[Item].szPen*image->ZoomIn/image->ZoomOut+0.5, &lb, 0, NULL); } } else { if (PenManagerForm->Pen->Shape == 0){ hPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_ROUND, DrawLocate[Item].szPen, &lb, 0, NULL); } else if (PenManagerForm->Pen->Shape ==1){ hPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_SQUARE, DrawLocate[Item].szPen, &lb, 0, NULL); } } // by celberus zoomIn ÇßÀ»¶§ ²ÞƲ°Å¸®´Â ¹®Á¦ ¶§¹®¿¡.. if (hPen!=NULL) { hOldPen = (HPEN)SelectObject(dc, hPen); if(DrawLocate[Item].ptFirst.x < DrawLocate[Item].ptSecond.x)DrawLocate[Item].ptSecond.x += 1; else if(DrawLocate[Item].ptFirst.x > DrawLocate[Item].ptSecond.x)DrawLocate[Item].ptSecond.x -= 1; if(DrawLocate[Item].ptFirst.y < DrawLocate[Item].ptSecond.y)DrawLocate[Item].ptSecond.y += 1; else if(DrawLocate[Item].ptFirst.y > DrawLocate[Item].ptSecond.y)DrawLocate[Item].ptSecond.y -= 1; POINT st, et; st = MainImageForm->reflection->FindScreenReflectionPos(DrawLocate[Item].ptFirst.x, DrawLocate[Item].ptFirst.y); et = MainImageForm->reflection->FindScreenReflectionPos(DrawLocate[Item].ptSecond.x, DrawLocate[Item].ptSecond.y); if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(DrawLocate[Item].ptFirst.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(DrawLocate[Item].ptFirst.y) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(DrawLocate[Item].ptSecond.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(DrawLocate[Item].ptSecond.y) - image->BitmapToCanvasY(y) ); MoveToEx(dc, image->BitmapToCanvasX(st.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(st.y) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(et.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(et.y) - image->BitmapToCanvasY(y) ); } else { MoveToEx(dc, DrawLocate[Item].ptFirst.x - x, DrawLocate[Item].ptFirst.y - y, NULL); LineTo(dc, DrawLocate[Item].ptSecond.x - x, DrawLocate[Item].ptSecond.y - y); MoveToEx(dc, st.x - x, st.y - y, NULL); LineTo(dc, et.x - x, et.y - y); } SelectObject(dc, hOldPen); DeleteObject(hPen); } END_LOG; } //---------------------------------------------------------------------------- void __fastcall TDrawForm::DrawLineLocate(POINT First, POINT Second) { BEGIN_LOG("Draw_F"); RECT Src, Dst; int ls, rs; TPItemImage *Image = MainImageForm->iMainImage; ls = PenManagerForm->Pen->BasicThick >> 1; rs = PenManagerForm->Pen->BasicThick - ls; Src.left = min(First.x, Second.x) - ls * 2; Src.top = min(First.y, Second.y) - ls * 2; Src.right = max(First.x, Second.x) + rs * 2; Src.bottom = max(First.y, Second.y) + rs * 2; if (Image->Reflection && MainImageForm->reflection){ POINT st, et; st = MainImageForm->reflection->FindScreenReflectionPos(First.x, First.y); et = MainImageForm->reflection->FindScreenReflectionPos(Second.x, Second.y); RECT Ref; Ref.left = min(Src.left, min(st.x, et.x)) - rs*2; Ref.top = min(Src.top, min(st.y, et.y)) - rs*2; Ref.right = max(Src.right, max(st.x, et.x)) + ls*2; Ref.bottom = max(Src.bottom, max(st.y, et.y)) + ls*2; UnionRect(&Dst, &Ref, &DrawLocate[Item].rtInvalidate); if (isTaper) { ////////k3dogs DrawLocate[Item].szPen = StartSize->Value; ////// if (PenManagerForm->aspread) DrawLocate[Item].clPen = PenManagerForm->shFirst->Brush->Color; ////// else DrawLocate[Item].clPen = MainImageForm->Palette->Color[PaletteForm->DIB256Palette->ChoiceIndex];////// } else { DrawLocate[Item].szPen = PenManagerForm->Pen->BasicThick; DrawLocate[Item].clPen = MainImageForm->Palette->Color[PaletteForm->DIB256Palette->ChoiceIndex]; } DrawLocate[Item].ptFirst.x = First.x; DrawLocate[Item].ptFirst.y = First.y; DrawLocate[Item].ptSecond.x = Second.x; DrawLocate[Item].ptSecond.y = Second.y; Image->RectEditPaint(Dst, Reflection_LineLocate, NULL); DrawLocate[Item].rtInvalidate = Ref; } else { UnionRect(&Dst, &Src, &DrawLocate[Item].rtInvalidate); if (isTaper) { ////////k3dogs DrawLocate[Item].szPen = StartSize->Value; ////// if (PenManagerForm->aspread) DrawLocate[Item].clPen = PenManagerForm->shFirst->Brush->Color; ////// else DrawLocate[Item].clPen = MainImageForm->Palette->Color[PaletteForm->DIB256Palette->ChoiceIndex];////// } else { DrawLocate[Item].szPen = PenManagerForm->Pen->BasicThick; DrawLocate[Item].clPen = MainImageForm->Palette->Color[PaletteForm->DIB256Palette->ChoiceIndex]; } DrawLocate[Item].ptFirst.x = First.x; DrawLocate[Item].ptFirst.y = First.y; DrawLocate[Item].ptSecond.x = Second.x; DrawLocate[Item].ptSecond.y = Second.y; Image->RectEditPaint(Dst, LineLocate, NULL); DrawLocate[Item].rtInvalidate = Src; } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::CurveLocate(HDC dc, int x, int y, void *pData) { BEGIN_LOG("Draw_F"); TPLayerImage *image=MainImageForm->iMainImage; int sx, sy, ex, ey, mx, my; double ct, st, ss, theta, alpha, d1, d2, d3; double tx, ty, a, b, xx, yy, pw, count; RECT rt; int ls, rs; HPEN hPen = NULL, hOldPen; LOGBRUSH lb; // ·Î±× ºê·¯½¬. ExtCreatePen Çϱâ À§ÇÏ¿© by tmddn85 lb.lbColor = DrawLocate[Item].clPen; lb.lbStyle = BS_SOLID; // Start: ±âÁ¸ ±×¸®±â¿¡¼­´Â ¸¶¿ì½º Æ÷ÀÎÅ͸¦ À̹ÌÁö¿¡ Âï¾úÀ» Àû¿¡ µ¿±×¶ó¹Ì°¡ ±×·ÁÁö°í ±× ´ÙÀ½¿¡ ¸¶¿ì½º¸¦ ³õ¾ÒÀ» ¶§ // ³×¸ð°¡ ±×·ÁÁ³´Ù. ExtCreatePenÀ» »ç¿ëÇÏ¿© ENDCAP_SQUARE±â´ÉÀ» ÀÌ¿ëÇØ º¸°íÀÚ ÇÑ´Ù. by tmddn85 if (image->ZoomIn <= image->ZoomOut) { // hPen = CreatePen(PS_SOLID, DrawLocate[Item].szPen*image->ZoomIn/image->ZoomOut+0.5, DrawLocate[Item].clPen); // ±âÁ¸ ÆæÀ» È®À寿À¸·Î ´ëü if (PenManagerForm->Pen->Shape == 0){ // PenManger¿¡¼­ Á¤º¸¸¦ ¾ò¾î¿Í¼­ RoundÀÎÁö SquareÀÎÁö °áÁ¤ÇÑ´Ù. by tmddn85 hPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_ROUND, DrawLocate[Item].szPen*image->ZoomIn/image->ZoomOut+0.5, &lb, 0, NULL); } else if (PenManagerForm->Pen->Shape == 1){ hPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_SQUARE, DrawLocate[Item].szPen*image->ZoomIn/image->ZoomOut+0.5, &lb, 0, NULL); } } else { // hPen = CreatePen(PS_SOLID, DrawLocate[Item].szPen, DrawLocate[Item].clPen); // ±âÁ¸ ÆæÀ» È®À寿À¸·Î ´ëü if (PenManagerForm->Pen->Shape == 0){ hPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_ROUND, DrawLocate[Item].szPen, &lb, 0, NULL); } else if (PenManagerForm->Pen->Shape ==1){ hPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_SQUARE, DrawLocate[Item].szPen, &lb, 0, NULL); } } // by celberus zoomIn ÇßÀ»¶§ ²ÞƲ°Å¸®´Â ¹®Á¦ ¶§¹®¿¡.. if (hPen!=NULL) { if (isTaper) { ////////////////////////////////////k3dogs if (PenManagerForm->aspread){ DeleteObject(hPen); // if (image->ZoomIn <= image->ZoomOut) { hPen = CreatePen(PS_SOLID, StartSize->Value*image->ZoomIn/image->ZoomOut+0.5, DrawLocate[Item].clPen); } else { hPen = CreatePen(PS_SOLID, StartSize->Value, DrawLocate[Item].clPen); } if (hPen == NULL) { END_LOG; return; } // } // } hOldPen = (HPEN)SelectObject(dc, hPen); ls = PenManagerForm->Pen->BasicThick / 2.0; rs = PenManagerForm->Pen->BasicThick - ls; pw = PenManagerForm->Pen->BasicThick; sx = Lsx; sy = Lsy; ex = Lex; ey = Ley; mx = Csx; my = Csy; d1 = sqrt((double)(sx - mx) * (sx - mx) + (sy - my) * (sy - my)); d2 = sqrt((double)(ex - mx) * (ex - mx) + (ey - my) * (ey - my)); d3 = sqrt((double)(ex - sx) * (ex - sx) + (ey - sy) * (ey - sy)); if (d1 > d2) { a = d1; b = d2; } else { a = d2; b = d1; } if ((my - sy) * (ex - sx) == (mx - sx) * (ey - sy)) { if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); } } else if ((sy == ey) && ((mx - sx) == (mx - ex))) { if (sx > mx) tx = sx - mx; else tx = mx - sx; if (tx==0) tx = 1; ty = sy - my; alpha = ty / (tx * tx); count = pw / 10 + 1; Lsx = mx; Lsy = my; xx = 0; while (xx <= tx) { yy = alpha * (xx * xx); Lex = mx + xx; Ley = my + yy; if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); } rt.left = min(Lsx, Lex) - 1; rt.top = min(Lsy, Ley) - 1; rt.right = max(Lsx, Lex) + 1; rt.bottom = max(Lsy, Ley) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); Lsx = Lex; Lsy = Ley; xx = xx + count; } if (sx > ex) Lex = sx; else Lex = ex; Ley = sy; if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); } rt.left = min(Lsx, Lex) - 1; rt.top = min(Lsy, Ley) - 1; rt.right = max(Lsx, Lex) + 1; rt.bottom = max(Lsy, Ley) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); count = pw / 10 + 1; Lsx = mx; Lsy = my; xx = 0; while (xx <= tx) { yy = alpha * (xx * xx); Lex = mx - xx; Ley = my + yy; if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); } rt.left = min(Lsx, Lex) - 1; rt.top = min(Lsy, Ley) - 1; rt.right = max(Lsx, Lex) + 1; rt.bottom = max(Lsy, Ley) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); Lsx = Lex; Lsy = Ley; xx = xx + count; } if (sx < ex) Lex = sx; else Lex = ex; Ley = sy; if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); } rt.left = min(Lsx, Lex) - 1; rt.top = min(Lsy, Ley) - 1; rt.right = max(Lsx, Lex) + 1; rt.bottom = max(Lsy, Ley) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); } else { if ((a > b * 1.8) && (d3 < a)) { d1 = sqrt(d1); d2 = sqrt(d2); } tx = (Lex * d1 + Lsx * d2) / (d1 + d2); ty = (Ley * d1 + Lsy * d2) / (d1 + d2); if ((tx - mx) == 0) ss = (double)(ty - my); else ss = (double)(ty - my) / (tx - mx); theta = M_PI / 2.0 - atan(ss); ct = cos(theta); st = sin(theta); tx = ct * (sx - mx) - st * (sy - my); ty = st * (sx - mx) + ct * (sy - my); if (tx==0) tx = 1; alpha = ty / (tx * tx); count = pw / 10 + 1; Lsx = mx; Lsy = my; if (tx < 0) { xx = 0; while (xx >= tx) { yy = alpha * (xx * xx); Lex = ct * xx + st * yy + mx; Ley = ct * yy - st * xx + my; if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); } rt.left = min(Lsx, Lex) - 1; rt.top = min(Lsy, Ley) - 1; rt.right = max(Lsx, Lex) + 1; rt.bottom = max(Lsy, Ley) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); Lsx = Lex; Lsy = Ley; xx = xx - count; } } else { xx = 0; while (xx <= tx) { yy = alpha * (xx * xx); Lex = ct * xx + st * yy + mx; Ley = ct * yy - st * xx + my; if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); } rt.left = min(Lsx, Lex) - 1; rt.top = min(Lsy, Ley) - 1; rt.right = max(Lsx, Lex) + 1; rt.bottom = max(Lsy, Ley) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); Lsx = Lex; Lsy = Ley; xx = xx + count; } } Lex = sx; Ley = sy; if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); } rt.left = min(Lsx, Lex) - 1; rt.top = min(Lsy, Ley) - 1; rt.right = max(Lsx, Lex) + 1; rt.bottom = max(Lsy, Ley) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); tx = ct * (ex - mx) - st * (ey - my); ty = st * (ex - mx) + ct * (ey - my); if (tx==0) tx = 1; alpha = ty / (tx * tx); count = pw / 10 + 1; Lsx = mx; Lsy = my; if (tx < 0) { xx = 0; while (xx >= tx) { yy = alpha * (xx * xx); Lex = ct * xx + st * yy + mx; Ley = ct * yy - st * xx + my; if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); } rt.left = min(Lsx, Lex) - 1; rt.top = min(Lsy, Ley) - 1; rt.right = max(Lsx, Lex) + 1; rt.bottom = max(Lsy, Ley) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); Lsx = Lex; Lsy = Ley; xx = xx - count; } } else { xx = 0; while (xx <= tx) { yy = alpha * (xx * xx); Lex = ct * xx + st * yy + mx; Ley = ct * yy - st * xx + my; if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); } rt.left = min(Lsx, Lex) - 1; rt.top = min(Lsy, Ley) - 1; rt.right = max(Lsx, Lex) + 1; rt.bottom = max(Lsy, Ley) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); Lsx = Lex; Lsy = Ley; xx = xx + count; } } Lex = ex; Ley = ey; if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); } rt.left = min(Lsx, Lex) - 1; rt.top = min(Lsy, Ley) - 1; rt.right = max(Lsx, Lex) + 1; rt.bottom = max(Lsy, Ley) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); } Lsx = sx; Lex = ex; Lsy = sy; Ley = ey; DrawLocate[Item].Src.left -= ls; DrawLocate[Item].Src.top -= ls; DrawLocate[Item].Src.right += rs; DrawLocate[Item].Src.bottom += rs; SelectObject(dc, hOldPen); DeleteObject(hPen); } END_LOG; } //---------------------------------------------------------------------------- void __fastcall TDrawForm::Reflection_CurveLocate(HDC dc, int x, int y, void *pData) { BEGIN_LOG("Draw_F"); TPLayerImage *image=MainImageForm->iMainImage; int sx, sy, ex, ey, mx, my; double ct, st, ss, theta, alpha, d1, d2, d3; double tx, ty, a, b, xx, yy, pw, count; RECT rt; int ls, rs; HPEN hPen = NULL, hOldPen; LOGBRUSH lb; // ·Î±× ºê·¯½¬. ExtCreatePen Çϱâ À§ÇÏ¿© by tmddn85 lb.lbColor = DrawLocate[Item].clPen; lb.lbStyle = BS_SOLID; // Start: ±âÁ¸ ±×¸®±â¿¡¼­´Â ¸¶¿ì½º Æ÷ÀÎÅ͸¦ À̹ÌÁö¿¡ Âï¾úÀ» Àû¿¡ µ¿±×¶ó¹Ì°¡ ±×·ÁÁö°í ±× ´ÙÀ½¿¡ ¸¶¿ì½º¸¦ ³õ¾ÒÀ» ¶§ // ³×¸ð°¡ ±×·ÁÁ³´Ù. ExtCreatePenÀ» »ç¿ëÇÏ¿© ENDCAP_SQUARE±â´ÉÀ» ÀÌ¿ëÇØ º¸°íÀÚ ÇÑ´Ù. by tmddn85 if (image->ZoomIn <= image->ZoomOut) { // hPen = CreatePen(PS_SOLID, DrawLocate[Item].szPen*image->ZoomIn/image->ZoomOut+0.5, DrawLocate[Item].clPen); // ±âÁ¸ ÆæÀ» È®À寿À¸·Î ´ëü if (PenManagerForm->Pen->Shape == 0){ // PenManger¿¡¼­ Á¤º¸¸¦ ¾ò¾î¿Í¼­ RoundÀÎÁö SquareÀÎÁö °áÁ¤ÇÑ´Ù. by tmddn85 hPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_ROUND, DrawLocate[Item].szPen*image->ZoomIn/image->ZoomOut+0.5, &lb, 0, NULL); } else if (PenManagerForm->Pen->Shape == 1){ hPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_SQUARE, DrawLocate[Item].szPen*image->ZoomIn/image->ZoomOut+0.5, &lb, 0, NULL); } } else { // hPen = CreatePen(PS_SOLID, DrawLocate[Item].szPen, DrawLocate[Item].clPen); // ±âÁ¸ ÆæÀ» È®À寿À¸·Î ´ëü if (PenManagerForm->Pen->Shape == 0){ hPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_ROUND, DrawLocate[Item].szPen, &lb, 0, NULL); } else if (PenManagerForm->Pen->Shape ==1){ hPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_SQUARE, DrawLocate[Item].szPen, &lb, 0, NULL); } } // by celberus zoomIn ÇßÀ»¶§ ²ÞƲ°Å¸®´Â ¹®Á¦ ¶§¹®¿¡.. if (hPen!=NULL) { if (isTaper) { ////////////////////////////////////k3dogs if (PenManagerForm->aspread){ DeleteObject(hPen); // if (image->ZoomIn <= image->ZoomOut) { hPen = CreatePen(PS_SOLID, StartSize->Value*image->ZoomIn/image->ZoomOut+0.5, DrawLocate[Item].clPen); } else { hPen = CreatePen(PS_SOLID, StartSize->Value, DrawLocate[Item].clPen); } if (hPen == NULL) { END_LOG; return; } // } // } hOldPen = (HPEN)SelectObject(dc, hPen); ls = PenManagerForm->Pen->BasicThick / 2.0; rs = PenManagerForm->Pen->BasicThick - ls; pw = PenManagerForm->Pen->BasicThick; sx = Lsx; sy = Lsy; ex = Lex; ey = Ley; mx = Csx; my = Csy; d1 = sqrt((double)(sx - mx) * (sx - mx) + (sy - my) * (sy - my)); d2 = sqrt((double)(ex - mx) * (ex - mx) + (ey - my) * (ey - my)); d3 = sqrt((double)(ex - sx) * (ex - sx) + (ey - sy) * (ey - sy)); if (d1 > d2) { a = d1; b = d2; } else { a = d2; b = d1; } if ((my - sy) * (ex - sx) == (mx - sx) * (ey - sy)) { POINT st, et; st = MainImageForm->reflection->FindScreenReflectionPos(Lsx, Lsy); et = MainImageForm->reflection->FindScreenReflectionPos(Lex, Ley); if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); MoveToEx(dc, image->BitmapToCanvasX(st.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(st.y) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(et.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(et.y) - image->BitmapToCanvasY(y) ); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); MoveToEx(dc, st.x - x, st.y - y, NULL); LineTo(dc, et.x - x, et.y - y); } } else if ((sy == ey) && ((mx - sx) == (mx - ex))) { if (sx > mx) tx = sx - mx; else tx = mx - sx; if (tx==0) tx = 1; ty = sy - my; alpha = ty / (tx * tx); count = pw / 10 + 1; Lsx = mx; Lsy = my; xx = 0; while (xx <= tx) { yy = alpha * (xx * xx); Lex = mx + xx; Ley = my + yy; POINT st, et; st = MainImageForm->reflection->FindScreenReflectionPos(Lsx, Lsy); et = MainImageForm->reflection->FindScreenReflectionPos(Lex, Ley); if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); MoveToEx(dc, image->BitmapToCanvasX(st.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(st.y) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(et.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(et.y) - image->BitmapToCanvasY(y) ); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); MoveToEx(dc, st.x - x, st.y - y, NULL); LineTo(dc, et.x - x, et.y - y); } rt.left = min(min(Lsx, Lex), min(st.x, et.x)) - 1; rt.top = min(min(Lsy, Ley), min(st.y, et.y)) - 1; rt.right = max(max(Lsx, Lex), max(st.x, et.x)) + 1; rt.bottom = max(max(Lsy, Ley), max(st.y, et.y)) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); Lsx = Lex; Lsy = Ley; xx = xx + count; } if (sx > ex) Lex = sx; else Lex = ex; Ley = sy; POINT st, et; st = MainImageForm->reflection->FindScreenReflectionPos(Lsx, Lsy); et = MainImageForm->reflection->FindScreenReflectionPos(Lex, Ley); if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); MoveToEx(dc, image->BitmapToCanvasX(st.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(st.y) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(et.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(et.y) - image->BitmapToCanvasY(y) ); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); MoveToEx(dc, st.x - x, st.y - y, NULL); LineTo(dc, et.x - x, et.y - y); } rt.left = min(min(Lsx, Lex), min(st.x, et.x)) - 1; rt.top = min(min(Lsy, Ley), min(st.y, et.y)) - 1; rt.right = max(max(Lsx, Lex), max(st.x, et.x)) + 1; rt.bottom = max(max(Lsy, Ley), max(st.y, et.y)) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); count = pw / 10 + 1; Lsx = mx; Lsy = my; xx = 0; while (xx <= tx) { yy = alpha * (xx * xx); Lex = mx - xx; Ley = my + yy; POINT st, et; st = MainImageForm->reflection->FindScreenReflectionPos(Lsx, Lsy); et = MainImageForm->reflection->FindScreenReflectionPos(Lex, Ley); if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); MoveToEx(dc, image->BitmapToCanvasX(st.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(st.y) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(et.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(et.y) - image->BitmapToCanvasY(y) ); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); MoveToEx(dc, st.x - x, st.y - y, NULL); LineTo(dc, et.x - x, et.y - y); } rt.left = min(min(Lsx, Lex), min(st.x, et.x)) - 1; rt.top = min(min(Lsy, Ley), min(st.y, et.y)) - 1; rt.right = max(max(Lsx, Lex), max(st.x, et.x)) + 1; rt.bottom = max(max(Lsy, Ley), max(st.y, et.y)) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); Lsx = Lex; Lsy = Ley; xx = xx + count; } if (sx < ex) Lex = sx; else Lex = ex; Ley = sy; //POINT st, et; st = MainImageForm->reflection->FindScreenReflectionPos(Lsx, Lsy); et = MainImageForm->reflection->FindScreenReflectionPos(Lex, Ley); if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); MoveToEx(dc, image->BitmapToCanvasX(st.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(st.y) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(et.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(et.y) - image->BitmapToCanvasY(y) ); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); MoveToEx(dc, st.x - x, st.y - y, NULL); LineTo(dc, et.x - x, et.y - y); } rt.left = min(min(Lsx, Lex), min(st.x, et.x)) - 1; rt.top = min(min(Lsy, Ley), min(st.y, et.y)) - 1; rt.right = max(max(Lsx, Lex), max(st.x, et.x)) + 1; rt.bottom = max(max(Lsy, Ley), max(st.y, et.y)) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); } else { if ((a > b * 1.8) && (d3 < a)) { d1 = sqrt(d1); d2 = sqrt(d2); } tx = (Lex * d1 + Lsx * d2) / (d1 + d2); ty = (Ley * d1 + Lsy * d2) / (d1 + d2); if ((tx - mx) == 0) ss = (double)(ty - my); else ss = (double)(ty - my) / (tx - mx); theta = M_PI / 2.0 - atan(ss); ct = cos(theta); st = sin(theta); tx = ct * (sx - mx) - st * (sy - my); ty = st * (sx - mx) + ct * (sy - my); if (tx==0) tx = 1; alpha = ty / (tx * tx); count = pw / 10 + 1; Lsx = mx; Lsy = my; if (tx < 0) { xx = 0; while (xx >= tx) { yy = alpha * (xx * xx); Lex = ct * xx + st * yy + mx; Ley = ct * yy - st * xx + my; POINT st, et; st = MainImageForm->reflection->FindScreenReflectionPos(Lsx, Lsy); et = MainImageForm->reflection->FindScreenReflectionPos(Lex, Ley); if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); MoveToEx(dc, image->BitmapToCanvasX(st.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(st.y) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(et.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(et.y) - image->BitmapToCanvasY(y) ); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); MoveToEx(dc, st.x - x, st.y - y, NULL); LineTo(dc, et.x - x, et.y - y); } rt.left = min(min(Lsx, Lex), min(st.x, et.x)) - 1; rt.top = min(min(Lsy, Ley), min(st.y, et.y)) - 1; rt.right = max(max(Lsx, Lex), max(st.x, et.x)) + 1; rt.bottom = max(max(Lsy, Ley), max(st.y, et.y)) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); Lsx = Lex; Lsy = Ley; xx = xx - count; } } else { xx = 0; while (xx <= tx) { yy = alpha * (xx * xx); Lex = ct * xx + st * yy + mx; Ley = ct * yy - st * xx + my; POINT st, et; st = MainImageForm->reflection->FindScreenReflectionPos(Lsx, Lsy); et = MainImageForm->reflection->FindScreenReflectionPos(Lex, Ley); if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); MoveToEx(dc, image->BitmapToCanvasX(st.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(st.y) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(et.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(et.y) - image->BitmapToCanvasY(y) ); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); MoveToEx(dc, st.x - x, st.y - y, NULL); LineTo(dc, et.x - x, et.y - y); } rt.left = min(min(Lsx, Lex), min(st.x, et.x)) - 1; rt.top = min(min(Lsy, Ley), min(st.y, et.y)) - 1; rt.right = max(max(Lsx, Lex), max(st.x, et.x)) + 1; rt.bottom = max(max(Lsy, Ley), max(st.y, et.y)) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); Lsx = Lex; Lsy = Ley; xx = xx + count; } } Lex = sx; Ley = sy; POINT spt, ept; spt = MainImageForm->reflection->FindScreenReflectionPos(Lsx, Lsy); ept = MainImageForm->reflection->FindScreenReflectionPos(Lex, Ley); if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); MoveToEx(dc, image->BitmapToCanvasX(spt.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(spt.y) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(ept.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(ept.y) - image->BitmapToCanvasY(y) ); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); MoveToEx(dc, spt.x - x, spt.y - y, NULL); LineTo(dc, ept.x - x, ept.y - y); } rt.left = min(min(Lsx, Lex), min(spt.x, ept.x)) - 1; rt.top = min(min(Lsy, Ley), min(spt.y, ept.y)) - 1; rt.right = max(max(Lsx, Lex), max(spt.x, ept.x)) + 1; rt.bottom = max(max(Lsy, Ley), max(spt.y, ept.y)) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); tx = ct * (ex - mx) - st * (ey - my); ty = st * (ex - mx) + ct * (ey - my); if (tx==0) tx = 1; alpha = ty / (tx * tx); count = pw / 10 + 1; Lsx = mx; Lsy = my; if (tx < 0) { xx = 0; while (xx >= tx) { yy = alpha * (xx * xx); Lex = ct * xx + st * yy + mx; Ley = ct * yy - st * xx + my; POINT st, et; st = MainImageForm->reflection->FindScreenReflectionPos(Lsx, Lsy); et = MainImageForm->reflection->FindScreenReflectionPos(Lex, Ley); if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); MoveToEx(dc, image->BitmapToCanvasX(st.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(st.y) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(et.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(et.y) - image->BitmapToCanvasY(y) ); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); MoveToEx(dc, st.x - x, st.y - y, NULL); LineTo(dc, et.x - x, et.y - y); } rt.left = min(min(Lsx, Lex), min(st.x, et.x)) - 1; rt.top = min(min(Lsy, Ley), min(st.y, et.y)) - 1; rt.right = max(max(Lsx, Lex), max(st.x, et.x)) + 1; rt.bottom = max(max(Lsy, Ley), max(st.y, et.y)) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); Lsx = Lex; Lsy = Ley; xx = xx - count; } } else { xx = 0; while (xx <= tx) { yy = alpha * (xx * xx); Lex = ct * xx + st * yy + mx; Ley = ct * yy - st * xx + my; POINT st, et; st = MainImageForm->reflection->FindScreenReflectionPos(Lsx, Lsy); et = MainImageForm->reflection->FindScreenReflectionPos(Lex, Ley); if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); MoveToEx(dc, image->BitmapToCanvasX(st.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(st.y) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(et.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(et.y) - image->BitmapToCanvasY(y) ); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); MoveToEx(dc, st.x - x, st.y - y, NULL); LineTo(dc, et.x - x, et.y - y); } rt.left = min(min(Lsx, Lex), min(st.x, et.x)) - 1; rt.top = min(min(Lsy, Ley), min(st.y, et.y)) - 1; rt.right = max(max(Lsx, Lex), max(st.x, et.x)) + 1; rt.bottom = max(max(Lsy, Ley), max(st.y, et.y)) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); Lsx = Lex; Lsy = Ley; xx = xx + count; } } Lex = ex; Ley = ey; POINT st, et; st = MainImageForm->reflection->FindScreenReflectionPos(Lsx, Lsy); et = MainImageForm->reflection->FindScreenReflectionPos(Lex, Ley); if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); MoveToEx(dc, image->BitmapToCanvasX(st.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(st.y) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(et.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(et.y) - image->BitmapToCanvasY(y) ); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); MoveToEx(dc, st.x - x, st.y - y, NULL); LineTo(dc, et.x - x, et.y - y); } rt.left = min(min(Lsx, Lex), min(st.x, et.x)) - 1; rt.top = min(min(Lsy, Ley), min(st.y, et.y)) - 1; rt.right = max(max(Lsx, Lex), max(st.x, et.x)) + 1; rt.bottom = max(max(Lsy, Ley), max(st.y, et.y)) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); } Lsx = sx; Lex = ex; Lsy = sy; Ley = ey; DrawLocate[Item].Src.left -= ls; DrawLocate[Item].Src.top -= ls; DrawLocate[Item].Src.right += rs; DrawLocate[Item].Src.bottom += rs; SelectObject(dc, hOldPen); DeleteObject(hPen); } END_LOG; } //---------------------------------------------------------------------------- void __fastcall TDrawForm::DrawCurveLocate(POINT First, POINT Second, POINT Third) { BEGIN_LOG("Draw_F"); RECT rt, dist; int ls, rs; TPItemImage *Image = MainImageForm->iMainImage; ls = PenManagerForm->Pen->BasicThick >> 1; rs = PenManagerForm->Pen->BasicThick - ls; if (Image->Reflection && MainImageForm->reflection){ POINT st, et, ct; st = MainImageForm->reflection->FindScreenReflectionPos(First.x, First.y); et = MainImageForm->reflection->FindScreenReflectionPos(Second.x, Second.y); ct = MainImageForm->reflection->FindScreenReflectionPos(Third.x, Third.y); rt.left = min(st.x, et.x) - 1; rt.top = min(st.y, et.y) - 1; rt.right = max(st.x, et.x) + 1; rt.bottom = max(st.y, et.y) + 1; if (ct.x < rt.left) dist.left = rt.left - ct.x; else dist.left = ls; if (ct.x > rt.right) dist.right = ct.x - rt.right; else dist.right = rs; if (ct.y < rt.top) dist.top = rt.top - ct.y; else dist.top = ls; if (ct.y > rt.bottom) dist.bottom = ct.y - rt.bottom; else dist.bottom = rs; rt.left = min(rt.left, ct.x) - 1; rt.top = min(rt.top, ct.y) - 1; rt.right = max(rt.right, ct.x) + 1; rt.bottom = max(rt.bottom, ct.y) + 1; DrawLocate[Item].Src.left = rt.left - dist.left; DrawLocate[Item].Src.top = rt.top - dist.top; DrawLocate[Item].Src.right = rt.right + dist.right; DrawLocate[Item].Src.bottom = rt.bottom + dist.bottom; UnionRect(&DrawLocate[Item].Dst, &DrawLocate[Item].Src, &DrawLocate[Item].rtInvalidate); if (isTaper) { //////k3dogs DrawLocate[Item].szPen = StartSize->Value; ////// if (PenManagerForm->aspread) DrawLocate[Item].clPen = PenManagerForm->shFirst->Brush->Color; ////// else DrawLocate[Item].clPen = MainImageForm->Palette->Color[PaletteForm->DIB256Palette->ChoiceIndex];////// } else { DrawLocate[Item].szPen = PenManagerForm->Pen->BasicThick; DrawLocate[Item].clPen = MainImageForm->Palette->Color[PaletteForm->DIB256Palette->ChoiceIndex]; } DrawLocate[Item].ptFirst.x = rt.left; DrawLocate[Item].ptFirst.y = rt.top; DrawLocate[Item].ptSecond.x = rt.right; DrawLocate[Item].ptSecond.y = rt.bottom; Image->RectEditPaint(DrawLocate[Item].Dst, Reflection_CurveLocate, NULL); DrawLocate[Item].rtInvalidate = DrawLocate[Item].Src; } else { rt.left = min(First.x, Second.x) - 1; rt.top = min(First.y, Second.y) - 1; rt.right = max(First.x, Second.x) + 1; rt.bottom = max(First.y, Second.y) + 1; if (Third.x < rt.left) dist.left = rt.left - Third.x; else dist.left = ls; if (Third.x > rt.right) dist.right = Third.x - rt.right; else dist.right = rs; if (Third.y < rt.top) dist.top = rt.top - Third.y; else dist.top = ls; if (Third.y > rt.bottom) dist.bottom = Third.y - rt.bottom; else dist.bottom = rs; rt.left = min(rt.left, Third.x) - 1; rt.top = min(rt.top, Third.y) - 1; rt.right = max(rt.right, Third.x) + 1; rt.bottom = max(rt.bottom, Third.y) + 1; DrawLocate[Item].Src.left = rt.left - dist.left; DrawLocate[Item].Src.top = rt.top - dist.top; DrawLocate[Item].Src.right = rt.right + dist.right; DrawLocate[Item].Src.bottom = rt.bottom + dist.bottom; UnionRect(&DrawLocate[Item].Dst, &DrawLocate[Item].Src, &DrawLocate[Item].rtInvalidate); if (isTaper) { //////k3dogs DrawLocate[Item].szPen = StartSize->Value; ////// if (PenManagerForm->aspread) DrawLocate[Item].clPen = PenManagerForm->shFirst->Brush->Color; ////// else DrawLocate[Item].clPen = MainImageForm->Palette->Color[PaletteForm->DIB256Palette->ChoiceIndex];////// } else { DrawLocate[Item].szPen = PenManagerForm->Pen->BasicThick; DrawLocate[Item].clPen = MainImageForm->Palette->Color[PaletteForm->DIB256Palette->ChoiceIndex]; } DrawLocate[Item].ptFirst.x = rt.left; DrawLocate[Item].ptFirst.y = rt.top; DrawLocate[Item].ptSecond.x = rt.right; DrawLocate[Item].ptSecond.y = rt.bottom; Image->RectEditPaint(DrawLocate[Item].Dst, CurveLocate, NULL); DrawLocate[Item].rtInvalidate = DrawLocate[Item].Src; } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::DotCurveLocate(HDC dc, int x, int y, void *pData) { BEGIN_LOG("Draw_F"); TPLayerImage *image=MainImageForm->iMainImage; int i, j, k, sx, sy, ex, ey; int ssx, eex, ssy, eey, mx, my; int cnt, dot, grade, total; double xx, yy, llsx, llsy, llex, lley; double tx, ty, a, b, pw, count; double lng, gap; double ct, st, ss, theta, alpha, d1, d2, d3; HPEN hPen = NULL, hOldPen; RECT rt; int ls, rs; if (image->ZoomIn <= image->ZoomOut) { hPen = CreatePen(PS_SOLID, DrawLocate[Item].szPen*image->ZoomIn/image->ZoomOut+0.5, DrawLocate[Item].clPen); } else { hPen = CreatePen(PS_SOLID, DrawLocate[Item].szPen, DrawLocate[Item].clPen); } // by celberus zoomIn ÇßÀ»¶§ ²ÞƲ°Å¸®´Â ¹®Á¦ ¶§¹®¿¡.. if (hPen!=NULL) { hOldPen = (HPEN)SelectObject(dc, hPen); ls = PenManagerForm->Pen->BasicThick >> 1; rs = PenManagerForm->Pen->BasicThick - ls; pw = PenManagerForm->Pen->BasicThick; sx = Lsx; sy = Lsy; ex = Lex; ey = Ley; mx = Csx; my = Csy; d1 = sqrt((sx - mx) * (sx - mx) + (sy - my) * (sy - my)); d2 = sqrt((ex - mx) * (ex - mx) + (ey - my) * (ey - my)); d3 = sqrt((ex - sx) * (ex - sx) + (ey - sy) * (ey - sy)); if (d1 >= d2) { a = d1; b = d2; } else { a = d2; b = d1; } if ((my - sy) * (ex - sx) == (mx - sx) * (ey - sy)) { Tstitch.l[1].sx = sx; Tstitch.l[1].ex = ex; Tstitch.l[1].sy = sy; Tstitch.l[1].ey = ey; DotLineLocate(dc, x, y, NULL); } else if ((sy == ey) && ((mx - sx) == (mx - ex))) { tx = abs(mx - sx); if (tx==0) tx = 1; ty = sy - my; alpha = ty / (tx * tx); count = pw / 10.0 + 1; Lsx = mx; Lsy = my; xx = 0; while (xx <= tx) { yy = alpha * (xx * xx); Lex = mx + xx; Ley = my + yy; if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); } rt.left = min(Lsx, Lex) - 1; rt.top = min(Lsy, Ley) - 1; rt.right = max(Lsx, Lex) + 1; rt.bottom = max(Lsy, Ley) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); Lsx = Lex; Lsy = Ley; xx = xx + count; } if (sx > ex) Lex = sx; else Lex = ex; Ley = sy; if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); } rt.left = min(Lsx, Lex) - 1; rt.top = min(Lsy, Ley) - 1; rt.right = max(Lsx, Lex) + 1; rt.bottom = max(Lsy, Ley) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); count = pw / 10.0 + 1; Lsx = mx; Lsy = my; xx = 0; while (xx <= tx) { yy = alpha * (xx * xx); Lex = mx - xx; Ley = my + yy; if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); } rt.left = min(Lsx, Lex) - 1; rt.top = min(Lsy, Ley) - 1; rt.right = max(Lsx, Lex) + 1; rt.bottom = max(Lsy, Ley) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); Lsx = Lex; Lsy = Ley; xx = xx + count; } if (sx < ex) Lex = sx; else Lex = ex; Ley = sy; if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); } rt.left = min(Lsx, Lex) - 1; rt.top = min(Lsy, Ley) - 1; rt.right = max(Lsx, Lex) + 1; rt.bottom = max(Lsy, Ley) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); } else { if ((a > b * 1.8) && (d3 < a)) { d1 = sqrt(d1); d2 = sqrt(d2); } tx = (Lex * d1 + Lsx * d2) / (d1 + d2); ty = (Ley * d1 + Lsy * d2) / (d1 + d2); if (tx == mx) ss = ty - my; else ss = (ty - my) / (tx - mx); theta = M_PI_2 - atan(ss); ct = cos(theta); st = sin(theta); tx = ct * (sx - mx) - st * (sy - my); ty = st * (sx - mx) + ct * (sy - my); alpha = ty / (tx * tx); ssx = 0; ssy = 0; eex = tx; eey = ty; lng = sqrt((eex - ssx + 1) * (eex - ssx + 1) + (eey - ssy + 1) * (eey - ssy + 1)); gap = (Ltype[Item].value[0] + Ltype[Item].value[1]) * PenManagerForm->Pen->BasicThick; cnt = lng / gap + 1; grade = (Ltype[Item].value[0] + Ltype[Item].value[1]) * 2; dot = (Ltype[Item].value[0] - 1) * 2; total = cnt * grade; for (i = 0; i < cnt; i++) { j = i * grade + 1 + Ltype[Item].value[1]; k = total - j; llsx = double(ssx * k + eex * j) / total; llsy = alpha * llsx * llsx; Lsx = ct * llsx + st * llsy + mx + 0.5; Lsy = ct * llsy - st * llsx + my + 0.5; j = j + dot; k = k - dot; llex = double(ssx * k + eex * j) / total; lley = alpha * llex * llex; Lex = ct * llex + st * lley + mx + 0.5; Ley = ct * lley - st * llex + my + 0.5; if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); } rt.left = min(Lsx, Lex) - 1; rt.top = min(Lsy, Ley) - 1; rt.right = max(Lsx, Lex) + 1; rt.bottom = max(Lsy, Ley) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); } tx = ct * (ex - mx) - st * (ey - my); ty = st * (ex - mx) + ct * (ey - my); alpha = ty / (tx * tx); ssx = 0; ssy = 0; eex = tx; eey = ty; lng = sqrt((eex - ssx + 1) * (eex - ssx + 1) + (eey - ssy + 1) * (eey - ssy + 1)); gap = (Ltype[Item].value[0] + Ltype[Item].value[1]) * PenManagerForm->Pen->BasicThick; cnt = lng / gap + 1; grade = (Ltype[Item].value[0] + Ltype[Item].value[1]) * 2; dot = (Ltype[Item].value[0] - 1) * 2; total = cnt * grade; for (i = 0; i < cnt; i++) { j = i * grade + 1 + Ltype[Item].value[1]; k = total - j; llsx = double(ssx * k + eex * j) / total; llsy = alpha * llsx * llsx; Lsx = ct * llsx + st * llsy + mx + 0.5; Lsy = ct * llsy - st * llsx + my + 0.5; j = j + dot; k = k - dot; llex = double(ssx * k + eex * j) / total; lley = alpha * llex * llex; Lex = ct * llex + st * lley + mx + 0.5; Ley = ct * lley - st * llex + my + 0.5; if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); } rt.left = min(Lsx, Lex) - 1; rt.top = min(Lsy, Ley) - 1; rt.right = max(Lsx, Lex) + 1; rt.bottom = max(Lsy, Ley) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); } } Lsx = sx; Lex = ex; Lsy = sy; Ley = ey; DrawLocate[Item].Src.left -= ls; DrawLocate[Item].Src.top -= ls; DrawLocate[Item].Src.right += rs; DrawLocate[Item].Src.bottom += rs; SelectObject(dc, hOldPen); DeleteObject(hPen); } END_LOG; } //---------------------------------------------------------------------------- void __fastcall TDrawForm::Reflection_DotCurveLocate(HDC dc, int x, int y, void *pData) { BEGIN_LOG("Draw_F"); TPLayerImage *image=MainImageForm->iMainImage; int i, j, k, sx, sy, ex, ey; int ssx, eex, ssy, eey, mx, my; int cnt, dot, grade, total; double xx, yy, llsx, llsy, llex, lley; double tx, ty, a, b, pw, count; double lng, gap; double ct, st, ss, theta, alpha, d1, d2, d3; HPEN hPen = NULL, hOldPen; RECT rt; int ls, rs; if (image->ZoomIn <= image->ZoomOut) { hPen = CreatePen(PS_SOLID, DrawLocate[Item].szPen*image->ZoomIn/image->ZoomOut+0.5, DrawLocate[Item].clPen); } else { hPen = CreatePen(PS_SOLID, DrawLocate[Item].szPen, DrawLocate[Item].clPen); } // by celberus zoomIn ÇßÀ»¶§ ²ÞƲ°Å¸®´Â ¹®Á¦ ¶§¹®¿¡.. if (hPen!=NULL) { hOldPen = (HPEN)SelectObject(dc, hPen); ls = PenManagerForm->Pen->BasicThick >> 1; rs = PenManagerForm->Pen->BasicThick - ls; pw = PenManagerForm->Pen->BasicThick; sx = Lsx; sy = Lsy; ex = Lex; ey = Ley; mx = Csx; my = Csy; d1 = sqrt((sx - mx) * (sx - mx) + (sy - my) * (sy - my)); d2 = sqrt((ex - mx) * (ex - mx) + (ey - my) * (ey - my)); d3 = sqrt((ex - sx) * (ex - sx) + (ey - sy) * (ey - sy)); if (d1 >= d2) { a = d1; b = d2; } else { a = d2; b = d1; } if ((my - sy) * (ex - sx) == (mx - sx) * (ey - sy)) { Tstitch.l[1].sx = sx; Tstitch.l[1].ex = ex; Tstitch.l[1].sy = sy; Tstitch.l[1].ey = ey; DotLineLocate(dc, x, y, NULL); } else if ((sy == ey) && ((mx - sx) == (mx - ex))) { tx = abs(mx - sx); if (tx==0) tx = 1; ty = sy - my; alpha = ty / (tx * tx); count = pw / 10.0 + 1; Lsx = mx; Lsy = my; xx = 0; while (xx <= tx) { yy = alpha * (xx * xx); Lex = mx + xx; Ley = my + yy; POINT pts, pte; pts = MainImageForm->reflection->FindScreenReflectionPos(Lsx, Lsy); pte = MainImageForm->reflection->FindScreenReflectionPos(Lex, Ley); if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); MoveToEx(dc, image->BitmapToCanvasX(pts.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(pts.y) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(pte.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(pte.y) - image->BitmapToCanvasY(y)); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); MoveToEx(dc, pts.x - x, pts.y - y, NULL); LineTo(dc, pte.x - x, pte.y - y); } rt.left = min(min(pts.x, pte.x), min(Lsx, Lex)) - 1; rt.top = min(min(pts.y, pte.y), min(Lsy, Ley)) - 1; rt.right = max(max(pts.x, pte.x), max(Lsx, Lex)) + 1; rt.bottom = max(max(pts.y, pte.y), max(Lsy, Ley)) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); Lsx = Lex; Lsy = Ley; xx = xx + count; } if (sx > ex) Lex = sx; else Lex = ex; Ley = sy; POINT pts, pte; pts = MainImageForm->reflection->FindScreenReflectionPos(Lsx, Lsy); pte = MainImageForm->reflection->FindScreenReflectionPos(Lex, Ley); if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); MoveToEx(dc, image->BitmapToCanvasX(pts.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(pts.y) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(pte.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(pte.y) - image->BitmapToCanvasY(y)); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); MoveToEx(dc, pts.x - x, pts.y - y, NULL); LineTo(dc, pte.x - x, pte.y - y); } rt.left = min(min(pts.x, pte.x), min(Lsx, Lex)) - 1; rt.top = min(min(pts.y, pte.y), min(Lsy, Ley)) - 1; rt.right = max(max(pts.x, pte.x), max(Lsx, Lex)) + 1; rt.bottom = max(max(pts.y, pte.y), max(Lsy, Ley)) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); count = pw / 10.0 + 1; Lsx = mx; Lsy = my; xx = 0; while (xx <= tx) { yy = alpha * (xx * xx); Lex = mx - xx; Ley = my + yy; POINT pts, pte; pts = MainImageForm->reflection->FindScreenReflectionPos(Lsx, Lsy); pte = MainImageForm->reflection->FindScreenReflectionPos(Lex, Ley); if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); MoveToEx(dc, image->BitmapToCanvasX(pts.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(pts.y) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(pte.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(pte.y) - image->BitmapToCanvasY(y)); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); MoveToEx(dc, pts.x - x, pts.y - y, NULL); LineTo(dc, pte.x - x, pte.y - y); } rt.left = min(min(pts.x, pte.x), min(Lsx, Lex)) - 1; rt.top = min(min(pts.y, pte.y), min(Lsy, Ley)) - 1; rt.right = max(max(pts.x, pte.x), max(Lsx, Lex)) + 1; rt.bottom = max(max(pts.y, pte.y), max(Lsy, Ley)) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); Lsx = Lex; Lsy = Ley; xx = xx + count; } if (sx < ex) Lex = sx; else Lex = ex; Ley = sy; //POINT pts, pte; pts = MainImageForm->reflection->FindScreenReflectionPos(Lsx, Lsy); pte = MainImageForm->reflection->FindScreenReflectionPos(Lex, Ley); if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); MoveToEx(dc, image->BitmapToCanvasX(pts.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(pts.y) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(pte.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(pte.y) - image->BitmapToCanvasY(y)); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); MoveToEx(dc, pts.x - x, pts.y - y, NULL); LineTo(dc, pte.x - x, pte.y - y); } rt.left = min(min(pts.x, pte.x), min(Lsx, Lex)) - 1; rt.top = min(min(pts.y, pte.y), min(Lsy, Ley)) - 1; rt.right = max(max(pts.x, pte.x), max(Lsx, Lex)) + 1; rt.bottom = max(max(pts.y, pte.y), max(Lsy, Ley)) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); } else { if ((a > b * 1.8) && (d3 < a)) { d1 = sqrt(d1); d2 = sqrt(d2); } tx = (Lex * d1 + Lsx * d2) / (d1 + d2); ty = (Ley * d1 + Lsy * d2) / (d1 + d2); if (tx == mx) ss = ty - my; else ss = (ty - my) / (tx - mx); theta = M_PI_2 - atan(ss); ct = cos(theta); st = sin(theta); tx = ct * (sx - mx) - st * (sy - my); ty = st * (sx - mx) + ct * (sy - my); alpha = ty / (tx * tx); ssx = 0; ssy = 0; eex = tx; eey = ty; lng = sqrt((eex - ssx + 1) * (eex - ssx + 1) + (eey - ssy + 1) * (eey - ssy + 1)); gap = (Ltype[Item].value[0] + Ltype[Item].value[1]) * PenManagerForm->Pen->BasicThick; cnt = lng / gap + 1; grade = (Ltype[Item].value[0] + Ltype[Item].value[1]) * 2; dot = (Ltype[Item].value[0] - 1) * 2; total = cnt * grade; for (i = 0; i < cnt; i++) { j = i * grade + 1 + Ltype[Item].value[1]; k = total - j; llsx = double(ssx * k + eex * j) / total; llsy = alpha * llsx * llsx; Lsx = ct * llsx + st * llsy + mx + 0.5; Lsy = ct * llsy - st * llsx + my + 0.5; j = j + dot; k = k - dot; llex = double(ssx * k + eex * j) / total; lley = alpha * llex * llex; Lex = ct * llex + st * lley + mx + 0.5; Ley = ct * lley - st * llex + my + 0.5; POINT pts, pte; pts = MainImageForm->reflection->FindScreenReflectionPos(Lsx, Lsy); pte = MainImageForm->reflection->FindScreenReflectionPos(Lex, Ley); if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); MoveToEx(dc, image->BitmapToCanvasX(pts.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(pts.y) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(pte.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(pte.y) - image->BitmapToCanvasY(y)); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); MoveToEx(dc, pts.x - x, pts.y - y, NULL); LineTo(dc, pte.x - x, pte.y - y); } rt.left = min(min(pts.x, pte.x), min(Lsx, Lex)) - 1; rt.top = min(min(pts.y, pte.y), min(Lsy, Ley)) - 1; rt.right = max(max(pts.x, pte.x), max(Lsx, Lex)) + 1; rt.bottom = max(max(pts.y, pte.y), max(Lsy, Ley)) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); } tx = ct * (ex - mx) - st * (ey - my); ty = st * (ex - mx) + ct * (ey - my); alpha = ty / (tx * tx); ssx = 0; ssy = 0; eex = tx; eey = ty; lng = sqrt((eex - ssx + 1) * (eex - ssx + 1) + (eey - ssy + 1) * (eey - ssy + 1)); gap = (Ltype[Item].value[0] + Ltype[Item].value[1]) * PenManagerForm->Pen->BasicThick; cnt = lng / gap + 1; grade = (Ltype[Item].value[0] + Ltype[Item].value[1]) * 2; dot = (Ltype[Item].value[0] - 1) * 2; total = cnt * grade; for (i = 0; i < cnt; i++) { j = i * grade + 1 + Ltype[Item].value[1]; k = total - j; llsx = double(ssx * k + eex * j) / total; llsy = alpha * llsx * llsx; Lsx = ct * llsx + st * llsy + mx + 0.5; Lsy = ct * llsy - st * llsx + my + 0.5; j = j + dot; k = k - dot; llex = double(ssx * k + eex * j) / total; lley = alpha * llex * llex; Lex = ct * llex + st * lley + mx + 0.5; Ley = ct * lley - st * llex + my + 0.5; POINT pts, pte; pts = MainImageForm->reflection->FindScreenReflectionPos(Lsx, Lsy); pte = MainImageForm->reflection->FindScreenReflectionPos(Lex, Ley); if (image->ZoomIn <= image->ZoomOut) { MoveToEx(dc, image->BitmapToCanvasX(Lsx) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Lsy) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(Lex) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(Ley) - image->BitmapToCanvasY(y)); MoveToEx(dc, image->BitmapToCanvasX(pts.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(pts.y) - image->BitmapToCanvasY(y), NULL); LineTo(dc, image->BitmapToCanvasX(pte.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(pte.y) - image->BitmapToCanvasY(y)); } else { MoveToEx(dc, Lsx - x, Lsy - y, NULL); LineTo(dc, Lex - x, Ley - y); MoveToEx(dc, pts.x - x, pts.y - y, NULL); LineTo(dc, pte.x - x, pte.y - y); } rt.left = min(min(pts.x, pte.x), min(Lsx, Lex)) - 1; rt.top = min(min(pts.y, pte.y), min(Lsy, Ley)) - 1; rt.right = max(max(pts.x, pte.x), max(Lsx, Lex)) + 1; rt.bottom = max(max(pts.y, pte.y), max(Lsy, Ley)) + 1; UnionRect(&DrawLocate[Item].Src, &DrawLocate[Item].Src, &rt); } } Lsx = sx; Lex = ex; Lsy = sy; Ley = ey; DrawLocate[Item].Src.left -= ls; DrawLocate[Item].Src.top -= ls; DrawLocate[Item].Src.right += rs; DrawLocate[Item].Src.bottom += rs; SelectObject(dc, hOldPen); DeleteObject(hPen); } END_LOG; } //---------------------------------------------------------------------------- void __fastcall TDrawForm::DrawDotCurveLocate(POINT First, POINT Second, POINT Third) { BEGIN_LOG("Draw_F"); RECT rt, dist; int ls, rs; TPItemImage *Image = MainImageForm->iMainImage; ls = PenManagerForm->Pen->BasicThick >> 1; rs = PenManagerForm->Pen->BasicThick - ls; if (Image->Reflection && MainImageForm->reflection){ POINT pts, pte, ptc; pts = MainImageForm->reflection->FindScreenReflectionPos(First.x, First.y); pte = MainImageForm->reflection->FindScreenReflectionPos(Second.x, Second.y); ptc = MainImageForm->reflection->FindScreenReflectionPos(Third.x, Third.y); rt.left = min(pts.x, pte.x) - 1; rt.top = min(pts.y, pte.y) - 1; rt.right = max(pts.x, pte.x) + 1; rt.bottom = max(pts.y, pte.y) + 1; if (ptc.x < rt.left) dist.left = rt.left - ptc.x; else dist.left = ls; if (ptc.x > rt.right) dist.right = ptc.x - rt.right; else dist.right = rs; if (ptc.y < rt.top) dist.top = rt.top - ptc.y; else dist.top = ls; if (ptc.y > rt.bottom) dist.bottom = ptc.y - rt.bottom; else dist.bottom = rs; rt.left = min(rt.left, ptc.x) - 1; rt.top = min(rt.top, ptc.y) - 1; rt.right = max(rt.right, ptc.x) + 1; rt.bottom = max(rt.bottom, ptc.y) + 1; DrawLocate[Item].Src.left = rt.left - dist.left; DrawLocate[Item].Src.top = rt.top - dist.top; DrawLocate[Item].Src.right = rt.right + dist.right; DrawLocate[Item].Src.bottom = rt.bottom + dist.bottom; UnionRect(&DrawLocate[Item].Dst, &DrawLocate[Item].Src, &DrawLocate[Item].rtInvalidate); DrawLocate[Item].szPen = PenManagerForm->Pen->BasicThick; DrawLocate[Item].clPen = MainImageForm->Palette->Color[PaletteForm->DIB256Palette->ChoiceIndex]; DrawLocate[Item].ptFirst.x = rt.left; DrawLocate[Item].ptFirst.y = rt.top; DrawLocate[Item].ptSecond.x = rt.right; DrawLocate[Item].ptSecond.y = rt.bottom; Image->RectEditPaint(DrawLocate[Item].Dst, Reflection_DotCurveLocate, NULL); DrawLocate[Item].rtInvalidate = DrawLocate[Item].Src; } else { rt.left = min(First.x, Second.x) - 1; rt.top = min(First.y, Second.y) - 1; rt.right = max(First.x, Second.x) + 1; rt.bottom = max(First.y, Second.y) + 1; if (Third.x < rt.left) dist.left = rt.left - Third.x; else dist.left = ls; if (Third.x > rt.right) dist.right = Third.x - rt.right; else dist.right = rs; if (Third.y < rt.top) dist.top = rt.top - Third.y; else dist.top = ls; if (Third.y > rt.bottom) dist.bottom = Third.y - rt.bottom; else dist.bottom = rs; rt.left = min(rt.left, Third.x) - 1; rt.top = min(rt.top, Third.y) - 1; rt.right = max(rt.right, Third.x) + 1; rt.bottom = max(rt.bottom, Third.y) + 1; DrawLocate[Item].Src.left = rt.left - dist.left; DrawLocate[Item].Src.top = rt.top - dist.top; DrawLocate[Item].Src.right = rt.right + dist.right; DrawLocate[Item].Src.bottom = rt.bottom + dist.bottom; UnionRect(&DrawLocate[Item].Dst, &DrawLocate[Item].Src, &DrawLocate[Item].rtInvalidate); DrawLocate[Item].szPen = PenManagerForm->Pen->BasicThick; DrawLocate[Item].clPen = MainImageForm->Palette->Color[PaletteForm->DIB256Palette->ChoiceIndex]; DrawLocate[Item].ptFirst.x = rt.left; DrawLocate[Item].ptFirst.y = rt.top; DrawLocate[Item].ptSecond.x = rt.right; DrawLocate[Item].ptSecond.y = rt.bottom; Image->RectEditPaint(DrawLocate[Item].Dst, DotCurveLocate, NULL); DrawLocate[Item].rtInvalidate = DrawLocate[Item].Src; } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::DotRectangleLocate(HDC dc, int x, int y, void *pData) { BEGIN_LOG("Draw_F"); TPLayerImage *image=MainImageForm->iMainImage; int ssx, ssy, eex, eey, sx, sy, ex, ey, lx, ly, lng, l; HPEN hPen = NULL, hOldPen; if (image->ZoomIn <= image->ZoomOut) { hPen = CreatePen(PS_SOLID, DrawLocate[Item].szPen*image->ZoomIn/image->ZoomOut+0.5, DrawLocate[Item].clPen); } else { hPen = CreatePen(PS_SOLID, DrawLocate[Item].szPen, DrawLocate[Item].clPen); } // by celberus zoomIn ÇßÀ»¶§ ²ÞƲ°Å¸®´Â ¹®Á¦ ¶§¹®¿¡.. if (hPen!=NULL) { hOldPen = (HPEN)SelectObject(dc, hPen); ssx = Tstitch.l[1].sx; ssy = Tstitch.l[1].sy; eex = Tstitch.l[1].ex; eey = Tstitch.l[1].ey; if (Item == TD_SQUR) { sx = Tstitch.sx; sy = Tstitch.sy; ex = Tstitch.ex; ey = Tstitch.ey; lx = ex - sx; ly = ey - sy; if (abs(lx) > abs(ly)) lng = ly; else lng = lx; l = abs(lng); if (lx * ly > 0) { Tstitch.l[1].sx = sx; Tstitch.l[1].sy = sy; Tstitch.l[1].ex = sx; Tstitch.l[1].ey = sy + lng; fit_dot_line(dc, x, y); Tstitch.l[1].ex = sx + lng; Tstitch.l[1].ey = sy; fit_dot_line(dc, x, y); Tstitch.l[1].sx = sx + lng; Tstitch.l[1].sy = sy + lng; Tstitch.l[1].ex = sx; Tstitch.l[1].ey = sy + lng; fit_dot_line(dc, x, y); Tstitch.l[1].ex = sx + lng; Tstitch.l[1].ey = sy; fit_dot_line(dc, x, y); } else { if (lx < 0) l = l * (-1); Tstitch.l[1].sx = sx; Tstitch.l[1].sy = sy; Tstitch.l[1].ex = sx; Tstitch.l[1].ey = sy - l; fit_dot_line(dc, x, y); Tstitch.l[1].ex = sx + l; Tstitch.l[1].ey = sy; fit_dot_line(dc, x, y); Tstitch.l[1].sx = sx + l; Tstitch.l[1].sy = sy - l; Tstitch.l[1].ex = sx; Tstitch.l[1].ey = sy - l; fit_dot_line(dc, x, y); Tstitch.l[1].ex = sx + l; Tstitch.l[1].ey = sy; fit_dot_line(dc, x, y); } l = abs(l) + PenManagerForm->Pen->BasicThick; switch (MainImageForm->CurrentUnit) { case uDot : eLength1->Value = l; break; case uInch: eLength1->Value = (double)l / MainImageForm->CanvasInfor.DotsPerInch; break; //Format("%.2f", OPENARRAY(TVarRec, ((double)l / MainImageForm->CanvasInfor.DotsPerInch))); break; case uCm : eLength1->Value = (double)l / MainImageForm->CanvasInfor.DotsPerInch * 2.54; //Format("%.2f", OPENARRAY(TVarRec, ((double)l / MainImageForm->CanvasInfor.DotsPerInch * 2.54))); } eLength2->Value = eLength1->Value; } else if (Item == TD_RECT) { sx = Tstitch.sx; sy = Tstitch.sy; ex = Tstitch.ex; ey = Tstitch.ey; Tstitch.l[1].sx = sx; Tstitch.l[1].sy = sy; Tstitch.l[1].ex = ex; Tstitch.l[1].ey = sy; fit_dot_line(dc, x, y); Tstitch.l[1].ex = sx; Tstitch.l[1].ey = ey; fit_dot_line(dc, x, y); Tstitch.l[1].sx = ex; Tstitch.l[1].sy = ey; Tstitch.l[1].ex = sx; Tstitch.l[1].ey = ey; fit_dot_line(dc, x, y); Tstitch.l[1].ex = ex; Tstitch.l[1].ey = sy; fit_dot_line(dc, x, y); lx = abs(ex - sx) + PenManagerForm->Pen->BasicThick; ly = abs(ey - sy) + PenManagerForm->Pen->BasicThick; switch (MainImageForm->CurrentUnit) { case uDot : eLength1->Value = lx; eLength2->Value = ly; break; case uInch: eLength1->Value = (double)lx / MainImageForm->CanvasInfor.DotsPerInch; //Format("%.2f", OPENARRAY(TVarRec, ((double)lx / MainImageForm->CanvasInfor.DotsPerInch))); eLength2->Value = (double)ly / MainImageForm->CanvasInfor.DotsPerInch; //Format("%.2f", OPENARRAY(TVarRec, ((double)ly / MainImageForm->CanvasInfor.DotsPerInch))); break; case uCm : eLength1->Value = (double)lx / MainImageForm->CanvasInfor.DotsPerInch * 2.54; //Format("%.2f", OPENARRAY(TVarRec, ((double)lx / MainImageForm->CanvasInfor.DotsPerInch * 2.54))); eLength2->Value = (double)ly / MainImageForm->CanvasInfor.DotsPerInch * 2.54; //Format("%.2f", OPENARRAY(TVarRec, ((double)ly / MainImageForm->CanvasInfor.DotsPerInch * 2.54))); } } Tstitch.l[1].sx = ssx; Tstitch.l[1].sy = ssy; Tstitch.l[1].ex = eex; Tstitch.l[1].ey = eey; SelectObject(dc, hOldPen); DeleteObject(hPen); } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::DrawDotRectangleLocate(RECT rc) { BEGIN_LOG("Draw_F"); RECT rt, Src, Dst; int ls, rs; TPItemImage *Image = MainImageForm->iMainImage; ls = PenManagerForm->Pen->BasicThick >> 1; rs = PenManagerForm->Pen->BasicThick - ls; rt.left = min(rc.left, rc.right); rt.top = min(rc.top, rc.bottom); rt.right = max(rc.left, rc.right); rt.bottom = max(rc.top, rc.bottom); Src.left = rt.left - ls * 2; Src.top = rt.top - ls * 2; Src.right = rt.right + rs * 2; Src.bottom = rt.bottom + rs * 2; UnionRect(&Dst, &Src, &DrawLocate[Item].rtInvalidate); DrawLocate[Item].szPen = PenManagerForm->Pen->BasicThick; DrawLocate[Item].clPen = MainImageForm->Palette->Color[PaletteForm->DIB256Palette->ChoiceIndex]; DrawLocate[Item].ptFirst.x = rt.left; DrawLocate[Item].ptFirst.y = rt.top; DrawLocate[Item].ptSecond.x = rt.right; DrawLocate[Item].ptSecond.y = rt.bottom; Image->RectEditPaint(Dst, DotRectangleLocate, NULL); DrawLocate[Item].rtInvalidate = Src; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::RectangleLocate(HDC dc, int x, int y, void *pData) { BEGIN_LOG("Draw_F"); TPLayerImage *image=MainImageForm->iMainImage; HPEN hPen = NULL, hOldPen; HBRUSH hOldBrush; /* LOGBRUSH lb; // ·Î±× ºê·¯½¬. ExtCreatePen Çϱâ À§ÇÏ¿© by tmddn85 lb.lbColor = DrawLocate[Item].clPen; // »ç°¢ÇüÀº PS_ENDCAP_SQUARE°¡ ÀÌ»óÇÏ¿© Àá½Ã ¸·¾ÆµÒ lb.lbStyle = BS_SOLID; */ if (image->ZoomIn <= image->ZoomOut) { hPen = CreatePen(PS_SOLID, DrawLocate[Item].szPen*image->ZoomIn/image->ZoomOut+0.5, DrawLocate[Item].clPen); // hPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_SQUARE, DrawLocate[Item].szPen*image->ZoomIn/image->ZoomOut+0.5, &lb, 0, NULL); } else { hPen = CreatePen(PS_SOLID, DrawLocate[Item].szPen, DrawLocate[Item].clPen); // hPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_SQUARE, DrawLocate[Item].szPen*image->ZoomIn/image->ZoomOut+0.5, &lb, 0, NULL); } // by celberus zoomIn ÇßÀ»¶§ ²ÞƲ°Å¸®´Â ¹®Á¦ ¶§¹®¿¡.. if (hPen!=NULL) { hOldPen = (HPEN)SelectObject(dc, hPen); hOldBrush = (HBRUSH)SelectObject(dc, GetStockObject(NULL_BRUSH)); if (image->ZoomIn <= image->ZoomOut) { Rectangle(dc, image->BitmapToCanvasX(DrawLocate[Item].ptFirst.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(DrawLocate[Item].ptFirst.y) - image->BitmapToCanvasY(y), image->BitmapToCanvasX(DrawLocate[Item].ptSecond.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(DrawLocate[Item].ptSecond.y) - image->BitmapToCanvasY(y)); } else { Rectangle(dc, DrawLocate[Item].ptFirst.x - x, DrawLocate[Item].ptFirst.y - y, DrawLocate[Item].ptSecond.x - x, DrawLocate[Item].ptSecond.y - y); } SelectObject(dc, hOldBrush); SelectObject(dc, hOldPen); DeleteObject(hPen); } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::Reflection_RectangleLocate(HDC dc, int x, int y, void *pData) { BEGIN_LOG("Draw_F"); TPLayerImage *image=MainImageForm->iMainImage; HPEN hPen = NULL, hOldPen; HBRUSH hOldBrush; if (image->ZoomIn <= image->ZoomOut) { hPen = CreatePen(PS_SOLID, DrawLocate[Item].szPen*image->ZoomIn/image->ZoomOut+0.5, DrawLocate[Item].clPen); } else { hPen = CreatePen(PS_SOLID, DrawLocate[Item].szPen, DrawLocate[Item].clPen); } // by celberus zoomIn ÇßÀ»¶§ ²ÞƲ°Å¸®´Â ¹®Á¦ ¶§¹®¿¡.. if (hPen!=NULL) { hOldPen = (HPEN)SelectObject(dc, hPen); hOldBrush = (HBRUSH)SelectObject(dc, GetStockObject(NULL_BRUSH)); POINT pts, pte; pts = MainImageForm->reflection->FindScreenReflectionPos(DrawLocate[Item].ptFirst.x, DrawLocate[Item].ptFirst.y); pte = MainImageForm->reflection->FindScreenReflectionPos(DrawLocate[Item].ptSecond.x, DrawLocate[Item].ptSecond.y); if (image->ZoomIn <= image->ZoomOut) { Rectangle(dc, image->BitmapToCanvasX(DrawLocate[Item].ptFirst.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(DrawLocate[Item].ptFirst.y) - image->BitmapToCanvasY(y), image->BitmapToCanvasX(DrawLocate[Item].ptSecond.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(DrawLocate[Item].ptSecond.y) - image->BitmapToCanvasY(y)); Rectangle(dc, image->BitmapToCanvasX(pts.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(pts.y) - image->BitmapToCanvasY(y), image->BitmapToCanvasX(pte.x) - image->BitmapToCanvasX(x), image->BitmapToCanvasY(pte.y) - image->BitmapToCanvasY(y)); } else { Rectangle(dc, DrawLocate[Item].ptFirst.x - x, DrawLocate[Item].ptFirst.y - y, DrawLocate[Item].ptSecond.x - x, DrawLocate[Item].ptSecond.y - y); Rectangle(dc, pts.x - x, pts.y - y, pte.x - x, pte.y - y); } SelectObject(dc, hOldBrush); SelectObject(dc, hOldPen); DeleteObject(hPen); } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::DrawRectangleLocate(RECT rc) { BEGIN_LOG("Draw_F"); RECT rt, Src, Dst; int ls, rs; TPItemImage *Image = MainImageForm->iMainImage; ls = PenManagerForm->Pen->BasicThick >> 1; rs = PenManagerForm->Pen->BasicThick - ls; rt.left = min(rc.left, rc.right); rt.top = min(rc.top, rc.bottom); rt.right = max(rc.left, rc.right); rt.bottom = max(rc.top, rc.bottom); DrawLocate[Item].szPen = PenManagerForm->Pen->BasicThick; DrawLocate[Item].clPen = MainImageForm->Palette->Color[PaletteForm->DIB256Palette->ChoiceIndex]; DrawLocate[Item].ptFirst.x = rt.left; DrawLocate[Item].ptFirst.y = rt.top; DrawLocate[Item].ptSecond.x = rt.right; DrawLocate[Item].ptSecond.y = rt.bottom; if (Image->Reflection && MainImageForm->reflection){ RECT Ref; POINT pts, pte; pts = MainImageForm->reflection->FindScreenReflectionPos(rc.left, rc.top); pte = MainImageForm->reflection->FindScreenReflectionPos(rc.right, rc.bottom); Ref.left = min(min(pts.x, pte.x), rt.left); Ref.top = min(min(pts.y, pte.y), rt.top); Ref.right = max(max(pts.x, pte.x), rt.right); Ref.bottom = max(max(pts.y, pte.y), rt.bottom); Src.left = Ref.left - ls * 2; Src.top = Ref.top - ls * 2; Src.right = Ref.right + rs * 2; Src.bottom = Ref.bottom + rs * 2; UnionRect(&Dst, &Src, &DrawLocate[Item].rtInvalidate); Image->RectEditPaint(Dst, Reflection_RectangleLocate, NULL); DrawLocate[Item].rtInvalidate = Src; } else { Src.left = rt.left - ls * 2; Src.top = rt.top - ls * 2; Src.right = rt.right + rs * 2; Src.bottom = rt.bottom + rs * 2; UnionRect(&Dst, &Src, &DrawLocate[Item].rtInvalidate); Image->RectEditPaint(Dst, RectangleLocate, NULL); DrawLocate[Item].rtInvalidate = Src; } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::EllipseLocate(HDC dc, int x, int y, void *pData) { BEGIN_LOG("Draw_F"); TPLayerImage *image=MainImageForm->iMainImage; HPEN hPen = NULL, hOldPen; HBRUSH hOldBrush; RECT drawRect; if (image->ZoomIn <= image->ZoomOut) { hPen = CreatePen(PS_SOLID, DrawLocate[Item].szPen*image->ZoomIn/image->ZoomOut+0.5, DrawLocate[Item].clPen); } else { hPen = CreatePen(PS_SOLID, DrawLocate[Item].szPen, DrawLocate[Item].clPen); } // by celberus zoomIn ÇßÀ»¶§ ²ÞƲ°Å¸®´Â ¹®Á¦ ¶§¹®¿¡.. if (hPen!=NULL) { hOldPen = (HPEN)SelectObject(dc, hPen); hOldBrush = (HBRUSH)SelectObject(dc, GetStockObject(NULL_BRUSH)); if (image->ZoomIn <= image->ZoomOut) { drawRect.left = image->BitmapToCanvasX(DrawLocate[Item].ptFirst.x) - image->BitmapToCanvasX(x); drawRect.right = image->BitmapToCanvasX(DrawLocate[Item].ptSecond.x) - image->BitmapToCanvasX(x); drawRect.top = image->BitmapToCanvasY(DrawLocate[Item].ptFirst.y) - image->BitmapToCanvasY(y); drawRect.bottom = image->BitmapToCanvasY(DrawLocate[Item].ptSecond.y) - image->BitmapToCanvasY(y); if (drawRect.left >= drawRect.right) drawRect.right = drawRect.left + 1; if (drawRect.top >= drawRect.bottom) drawRect.bottom = drawRect.top + 1; Ellipse(dc, drawRect.left, drawRect.top, drawRect.right, drawRect.bottom); } else { Ellipse(dc, DrawLocate[Item].ptFirst.x - x, DrawLocate[Item].ptFirst.y - y, DrawLocate[Item].ptSecond.x - x, DrawLocate[Item].ptSecond.y - y); } SelectObject(dc, hOldBrush); SelectObject(dc, hOldPen); DeleteObject(hPen); } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::Reflection_EllipseLocate(HDC dc, int x, int y, void *pData) { BEGIN_LOG("Draw_F"); TPLayerImage *image=MainImageForm->iMainImage; HPEN hPen = NULL, hOldPen; HBRUSH hOldBrush; RECT drawRect; if (image->ZoomIn <= image->ZoomOut) { hPen = CreatePen(PS_SOLID, DrawLocate[Item].szPen*image->ZoomIn/image->ZoomOut+0.5, DrawLocate[Item].clPen); } else { hPen = CreatePen(PS_SOLID, DrawLocate[Item].szPen, DrawLocate[Item].clPen); } // by celberus zoomIn ÇßÀ»¶§ ²ÞƲ°Å¸®´Â ¹®Á¦ ¶§¹®¿¡.. if (hPen!=NULL) { hOldPen = (HPEN)SelectObject(dc, hPen); hOldBrush = (HBRUSH)SelectObject(dc, GetStockObject(NULL_BRUSH)); POINT ps, pe, ptf, pts; ps = MainImageForm->reflection->FindScreenReflectionPos(DrawLocate[Item].ptFirst.x, DrawLocate[Item].ptFirst.y); pe = MainImageForm->reflection->FindScreenReflectionPos(DrawLocate[Item].ptSecond.x, DrawLocate[Item].ptSecond.y); ptf.x = min(ps.x, pe.x); ptf.y = min(ps.y, pe.y); pts.x = max(ps.x, pe.x); pts.y = max(ps.y, pe.y); if (image->ZoomIn <= image->ZoomOut) { drawRect.left = image->BitmapToCanvasX(DrawLocate[Item].ptFirst.x) - image->BitmapToCanvasX(x); drawRect.right = image->BitmapToCanvasX(DrawLocate[Item].ptSecond.x) - image->BitmapToCanvasX(x); drawRect.top = image->BitmapToCanvasY(DrawLocate[Item].ptFirst.y) - image->BitmapToCanvasY(y); drawRect.bottom = image->BitmapToCanvasY(DrawLocate[Item].ptSecond.y) - image->BitmapToCanvasY(y); if (drawRect.left >= drawRect.right) drawRect.right = drawRect.left + 1; if (drawRect.top >= drawRect.bottom) drawRect.bottom = drawRect.top + 1; Ellipse(dc, drawRect.left, drawRect.top, drawRect.right, drawRect.bottom); drawRect.left = image->BitmapToCanvasX(ptf.x) - image->BitmapToCanvasX(x); drawRect.right = image->BitmapToCanvasX(pts.x) - image->BitmapToCanvasX(x); drawRect.top = image->BitmapToCanvasY(ptf.y) - image->BitmapToCanvasY(y); drawRect.bottom = image->BitmapToCanvasY(pts.y) - image->BitmapToCanvasY(y); if (drawRect.left >= drawRect.right) drawRect.right = drawRect.left + 1; if (drawRect.top >= drawRect.bottom) drawRect.bottom = drawRect.top + 1; Ellipse(dc, drawRect.left, drawRect.top, drawRect.right, drawRect.bottom); } else { Ellipse(dc, DrawLocate[Item].ptFirst.x - x, DrawLocate[Item].ptFirst.y - y, DrawLocate[Item].ptSecond.x - x, DrawLocate[Item].ptSecond.y - y); Ellipse(dc, ptf.x - x, ptf.y - y, pts.x - x, pts.y - y); } SelectObject(dc, hOldBrush); SelectObject(dc, hOldPen); DeleteObject(hPen); } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::DrawEllipseLocate(RECT rc) { BEGIN_LOG("Draw_F"); RECT rt, Src, Dst; int ls, rs; TPItemImage *Image = MainImageForm->iMainImage; ls = PenManagerForm->Pen->BasicThick >> 1; rs = PenManagerForm->Pen->BasicThick - ls; rt.left = min(rc.left, rc.right); rt.top = min(rc.top, rc.bottom); rt.right = max(rc.left, rc.right); rt.bottom = max(rc.top, rc.bottom); DrawLocate[Item].szPen = PenManagerForm->Pen->BasicThick; DrawLocate[Item].clPen = MainImageForm->Palette->Color[PaletteForm->DIB256Palette->ChoiceIndex]; if (rc.left + ls > rc.right - rs) { // by celberus DrawLocate[Item].ptFirst.x = rt.left + (rt.right - rt.left - 1) / 2; DrawLocate[Item].ptSecond.x = DrawLocate[Item].ptFirst.x + 1; } else { DrawLocate[Item].ptFirst.x = rt.left + ls; DrawLocate[Item].ptSecond.x = rt.right - rs; } if (rc.top + ls > rc.bottom - rs) { // by celberus DrawLocate[Item].ptFirst.y = rt.top + (rc.bottom - rc.top - 1) / 2; DrawLocate[Item].ptSecond.y = DrawLocate[Item].ptFirst.y + 1; } else { DrawLocate[Item].ptFirst.y = rt.top + ls; DrawLocate[Item].ptSecond.y = rt.bottom - rs; } if (Image->Reflection && MainImageForm->reflection){ POINT pts, pte; pts = MainImageForm->reflection->FindScreenReflectionPos(rt.left, rt.top); pte = MainImageForm->reflection->FindScreenReflectionPos(rt.right, rt.bottom); Src.left = min(min(pts.x, pte.x), rt.left) - 10; Src.top = min(min(pts.y, pte.y), rt.top) - 10; Src.right = max(max(pts.x, pte.x), rt.right) + 10; Src.bottom = max(max(pts.y, pte.y), rt.bottom) + 10; UnionRect(&Dst, &Src, &DrawLocate[Item].rtInvalidate); Image->RectEditPaint(Dst, Reflection_EllipseLocate, NULL); DrawLocate[Item].rtInvalidate = Src; } else { Src.left = rt.left - 10; Src.top = rt.top - 10; Src.right = rt.right + 10; Src.bottom = rt.bottom + 10; UnionRect(&Dst, &Src, &DrawLocate[Item].rtInvalidate); Image->RectEditPaint(Dst, EllipseLocate, NULL); DrawLocate[Item].rtInvalidate = Src; } END_LOG; } //--------------------------------------------------------------------------- // Public Function //--------------------------------------------------------------------------- void __fastcall TDrawForm::InitForm() { BEGIN_LOG("Draw_F"); // MainImageForm->DrawORStitch=true; MainImageForm->DrawORStitch=false; // ±×¸®±â ¸ðµåÀ϶§µµ Å©·Î½º¶óÀÎ »ý±â°Ô Çϱâ À§ÇØ ´Ù½Ã false·Î by tmddn85 int i; TPItemImage *Image = MainImageForm->iMainImage; /// °¢ Formµé µ¶¸³ÀûÀ¸·Î °ü¸®Çϱâ À§ÇØ ÁÖ¼®Ã³¸® //ParentHeight = Parent->Height+20; ClientHeight = 106; /// °¢ Formµé µ¶¸³ÀûÀ¸·Î °ü¸®Çϱâ À§ÇØ ÁÖ¼®Ã³¸® //Parent->Height = ParentHeight+ClientHeight; MousePointPlace = D_Center; // ±×¸®±â ¸ðµå½Ã ¸¶¿ì½º¸ðµå´Â °¡¿îµ¥·Î by tmddn85 DrawMousePoint(MousePointPlace); // °¡¿îµ¥·Î ÃʱâÈ­ if (PenManagerForm->sbMask->Down) { if (Image->uBitmap->BitsPerPixel==8) { MainImageForm->OnSetHLine = MainImageForm->SetHLineMask8; if (PenManagerForm->rzckDelete->Checked) { MainImageForm->MaskPixel = 0x00; } else { MainImageForm->MaskPixel = 0x0F; } } else { if (PenManagerForm->rzckDelete->Checked) { MainImageForm->OnSetHLine = MainImageForm->SetHLineMaskDelete24; MainImageForm->MaskPixel = 0x00; } else { MainImageForm->OnSetHLine = MainImageForm->SetHLineMask24; MainImageForm->MaskPixel = 0x80; } } } else { if (Image->uBitmap->BitsPerPixel==8) { if (MainImageForm->Palette->UseColor-1 == 250) rzbtnLType->Enabled = false; //lhskys »ö¼±Åüö°¡ 250ÀÌ»óÀ̱⠶§¹®¿¡ taper »ç¿ë±ÝÁö. MainImageForm->OnSetHLine = MainImageForm->SetHLine8ColorNo; } else { MainImageForm->OnSetHLine = MainImageForm->SetHLine24; } } /* for (i = 0; i <= 6; i++) { Ltype[i].sw = 0; Ltype[i].value[0] = 3; Ltype[i].value[1] = 1; } */ ReadIniFile(); // isw = 0; hasUserLength = false; isNumberInput = false; isHVLine = false; Asw = 0; Lsw = 0; Dsw = 0; step = 0; undos = 0; IsDraw = false; MainImageForm->iMainImage->OnPaintLocate = NULL;/////////////////by jeegeo PointList = new TList; IsBackpoint = false; swLength = false; swAngle = false; view(); m_IsChangedItemByShift = false; if (Item == TD_LINE) { FunctionClick(sbLine); sbLine->Down = true; } else if (Item == TD_CURVE) { FunctionClick(sbCurve); sbCurve->Down = true; } else if (Item == TD_RECT) { mnitmRectClick(mnitmRectangle); } else if (Item == TD_SQUR) { mnitmRectClick(mnitmSquare); } else if (Item == TD_ELLIP) { mnitmCircleClick(mnitmEllipse); } else if (Item == TD_CIRCLE) { mnitmCircleClick(mnitmCircle); } else if (Item == TD_OUT) { FunctionClick(sbOut); sbOut->Down = true; } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::ReadIniFile() { BEGIN_LOG("Draw_F"); TIniFile *DrawIni = NULL; String str; DrawIni = new TIniFile(AppDataItem + "\\Draw.ini"); if (DrawIni) { Item = DrawIni->ReadInteger("Draw", "Type", 0); for (int i = 0; i <= 6; i++) { str = IntToStr(i); Ltype[i].sw = DrawIni->ReadInteger("LineType", "DS" + str, 0); Ltype[i].value[0] = DrawIni->ReadInteger("LineType", "Dot" + str, 3); Ltype[i].value[1] = DrawIni->ReadInteger("LineType", "Gap" + str, 1); } Line_type = DrawIni->ReadInteger("Line", "Type", 1); Curve_type = DrawIni->ReadInteger("Curve", "Type", 1); Curve_input = DrawIni->ReadInteger("Curve", "Input", 0); fill_not = DrawIni->ReadInteger("Fill", "Ok", 0); delete DrawIni; } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::WriteIniFile() { BEGIN_LOG("Draw_F"); TIniFile *DrawIni = NULL; String str; DrawIni = new TIniFile(AppDataItem + "\\Draw.ini"); if (DrawIni) { DrawIni->WriteInteger("Draw", "Type", Item); for (int i = 0; i <= 6; i++) { str = IntToStr(i); DrawIni->WriteInteger("LineType", "DS" + str, Ltype[i].sw); DrawIni->WriteInteger("LineType", "Dot" + str, Ltype[i].value[0]); DrawIni->WriteInteger("LineType", "Gap" + str, Ltype[i].value[1]); } DrawIni->WriteInteger("Line", "Type", Line_type); DrawIni->WriteInteger("Curve", "Type", Curve_type); DrawIni->WriteInteger("Curve", "Input", Curve_input); DrawIni->WriteInteger("Fill", "Ok", fill_not); delete DrawIni; } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::ExitForm(void) { BEGIN_LOG("Draw_F"); WriteIniFile(); InitPointList(); delete PointList; iMainImageChange(); MainImageForm->DrawORStitch=false; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::view(void) { BEGIN_LOG("Draw_F"); switch (Item) { case TD_OUT : sbOut->Down = true; StartSize->Enabled = false; EndSize->Enabled = false; ClientHeight = rzplMenu->Height; break; case TD_LINE : sbLine->Down = true; rzbtnLType->Visible = true; if (Line_type == 0) { step = 0; rzbtnLType->Hint = IDS_COMMON_SEPARATELINE; } else if (Line_type == 1) { undos = 0; separatel = 0; rzbtnLType->Hint = IDS_COMMON_CONTINUOUSLINE; } ChangeLTypeImg(Line_type); rzcbFill->Left = 50; imgFill->Left = 70; if (fill_not == 0) rzcbFill->Checked = false; else if (fill_not == 1) rzcbFill->Checked = true; MousePanel->Visible = true; rzpnlLength->Top = rzpnlOption->Top + rzpnlOption->Height; rzpnlLength->Visible = true; Label1->Caption = IDS_LINE; lLength->Caption = IDS_COMMON_LENGTH; lAngle->Caption = IDS_COMMON_ANGLE; eLength2->Visible = false; eAngle->Visible = true; rzpnlDot->Top = rzpnlLength->Top + rzpnlLength->Height; if(!isTaper)rzcbDot->Enabled = true; else rzcbDot->Enabled = false; if (Ltype[TD_LINE].sw == 0) { lDotLength->Visible = false; lDotSpace->Visible = false; eDotLength->Visible = false; eDotSpace->Visible = false; rzcbFill->Visible = Line_type; imgFill->Visible = Line_type; if(!isTaper) { rzcbFill->Enabled = true; imgFill->Enabled = true; } else { rzcbFill->Enabled = false; imgFill->Enabled = false; } rzcbDot->Checked = false; } else if (Ltype[TD_LINE].sw == 1) { lDotLength->Visible = true; lDotSpace->Visible = true; eDotLength->Visible = true; eDotSpace->Visible = true; rzcbFill->Visible = false; imgFill->Visible = false; rzcbDot->Checked = true; } rzpnlPressure->Top = rzpnlDot->Top + rzpnlDot->Height; rzpnlPressure->Visible = true; if (rzcbPressure->Checked) { StartSize->Visible = true; EndSize->Visible = true; StartSize->Enabled = true; EndSize->Enabled = true; } else { StartSize->Enabled = false; EndSize->Enabled = false; StartSize->Visible = false; EndSize->Visible = false; } rzpnlButton->Top = rzpnlPressure->Top + rzpnlPressure->Height; rzpnlButton->Visible = true; rzbtFirst->Visible = true; rzbtDelete->Visible = true; rzbtnLastCenter->Visible = false; sbInputMode1->Visible = false; sbInputMode2->Visible = false; ClientHeight = rzpnlButton->Top + rzpnlButton->Height; break; case TD_CURVE : sbCurve->Down = true; rzbtnLType->Visible = true; if (Curve_type == 0) { step = 0; rzbtnLType->Hint = IDS_COMMON_SEPARATELINE; } else if (Curve_type == 1) { undos = 0; rzbtnLType->Hint = IDS_COMMON_CONTINUOUSLINE; } ChangeLTypeImg(Curve_type); rzcbFill->Visible = false; imgFill->Visible = false; MousePanel->Visible = true; rzpnlLength->Visible = false; rzpnlDot->Top = rzpnlOption->Top + rzpnlOption->Height; if(!isTaper)rzcbDot->Enabled = true; else rzcbDot->Enabled = false; if (Ltype[TD_CURVE].sw == 0) { rzcbDot->Checked = false; lDotLength->Visible = false; lDotSpace->Visible = false; eDotLength->Visible = false; eDotSpace->Visible = false; } else if (Ltype[TD_CURVE].sw == 1) { rzcbDot->Checked = true; lDotLength->Visible = true; lDotSpace->Visible = true; eDotLength->Visible = true; eDotSpace->Visible = true; } rzpnlPressure->Top = rzpnlDot->Top + rzpnlDot->Height; rzpnlPressure->Visible = true; if (rzcbPressure->Checked) { StartSize->Visible = true; EndSize->Visible = true; StartSize->Enabled = true; EndSize->Enabled = true; } else { StartSize->Visible = false; EndSize->Visible = false; StartSize->Enabled = false; EndSize->Enabled = false; } rzpnlButton->Top = rzpnlPressure->Top + rzpnlPressure->Height; rzpnlButton->Visible = true; rzbtFirst->Visible = false; rzbtDelete->Visible = true; rzbtnLastCenter->Visible = false; sbInputMode1->Visible = true; sbInputMode2->Visible = true; if (Curve_input == 0) sbInputMode1->Down = true; else if (Curve_input == 1) sbInputMode2->Down = true; ClientHeight = rzpnlButton->Top + rzpnlButton->Height; break; case TD_CIRCLE : if(cirlastpoint) rzbtnLastCenter->Enabled = false; else rzbtnLastCenter->Enabled = true; // Ltype[Item].sw = Ltype[4].sw; // Ltype[Item].value[0] = Ltype[4].value[0]; // Ltype[Item].value[1] = Ltype[4].value[1]; case TD_ELLIP : sbEllip->Down = true; rzbtnLType->Visible = false; rzcbFill->Visible = true; rzcbFill->Enabled = true; rzcbFill->Left = 5; imgFill->Visible = true; imgFill->Enabled = true; imgFill->Left = 25; if (fill_not == 0) rzcbFill->Checked = false; else if (fill_not == 1) rzcbFill->Checked = true; MousePanel->Visible = false; rzpnlLength->Top = rzpnlOption->Top + rzpnlLength->Height; rzpnlLength->Visible = true; Label1->Caption = IDS_FIGURE; lLength->Caption = IDS_HORI; lAngle->Caption = IDS_VERT; eAngle->Visible = false; eLength2->Visible = true; rzpnlDot->Top = rzpnlLength->Top + rzpnlLength->Height; rzcbDot->Enabled = true; if (Ltype[Item].sw == 0) { rzcbDot->Checked = false; lDotLength->Visible = false; lDotSpace->Visible = false; eDotLength->Visible = false; eDotSpace->Visible = false; } else if (Ltype[Item].sw == 1) { rzcbDot->Checked = true; lDotLength->Visible = true; lDotSpace->Visible = true; eDotLength->Visible = true; eDotSpace->Visible = true; } rzpnlPressure->Visible = false; rzpnlButton->Top = rzpnlDot->Top + rzpnlDot->Height; rzpnlButton->Visible = true; rzbtFirst->Visible = false; rzbtDelete->Visible = false; rzbtnLastCenter->Visible = true; if(elliplastpoint) rzbtnLastCenter->Enabled = false; else rzbtnLastCenter->Enabled = true; sbInputMode1->Visible = false; sbInputMode2->Visible = false; ClientHeight = rzpnlButton->Top + rzpnlButton->Height; break; case TD_SQUR : // Ltype[Item].sw = Ltype[2].sw; // Ltype[Item].value[0] = Ltype[2].value[0]; // Ltype[Item].value[1] = Ltype[2].value[1]; case TD_RECT : sbRect->Down = true; rzbtnLType->Visible = false; rzcbFill->Visible = true; rzcbFill->Enabled = true; rzcbFill->Left = 5; imgFill->Visible = true; imgFill->Enabled = true; imgFill->Left = 25; if (fill_not == 0) rzcbFill->Checked = false; else if (fill_not == 1) rzcbFill->Checked = true; MousePanel->Visible = true; rzpnlLength->Top = rzpnlOption->Top + rzpnlOption->Height; rzpnlLength->Visible = true; Label1->Caption = IDS_FIGURE; lLength->Caption = IDS_HORI; lAngle->Caption = IDS_VERT; eAngle->Visible = false; eLength2->Visible = true; rzpnlDot->Top = rzpnlLength->Top + rzpnlLength->Height; rzcbDot->Enabled = true; if (Ltype[Item].sw == 0) { rzcbDot->Checked = false; lDotLength->Visible = false; lDotSpace->Visible = false; eDotLength->Visible = false; eDotSpace->Visible = false; } else if (Ltype[Item].sw == 1) { rzcbDot->Checked = true; lDotLength->Visible = true; lDotSpace->Visible = true; eDotLength->Visible = true; eDotSpace->Visible = true; } rzpnlPressure->Visible = false; rzpnlButton->Visible = false; ClientHeight = rzpnlDot->Top + rzpnlDot->Height; break; default: ; } eDotLength->Value = Ltype[Item].value[0]; eDotSpace->Value = Ltype[Item].value[1]; // step = 0; undos = 0; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::DrawMouseDown(TMouseButton Button, TShiftState Shift, int XD, int YD) { BEGIN_LOG("Draw_F"); RECT rect; int pw, ra, lsx, lsy, lex, ley, ww, hh; int PenThick; bool Mbmp; COLORREF c; TPItemImage *Image = MainImageForm->iMainImage; int s_size, e_size; if (PenManagerForm->spread_sw[4] == 0 && PenManagerForm->aspread == true ){ END_LOG; return; } if (Image->Reflection){ POINT reflectionPos; reflectionPos = MainImageForm->reflection->FindOriginalPos(XD, YD); if (reflectionPos.x < 0 || reflectionPos.y < 0){ END_LOG; return; } } c = PaletteForm->DIB256Palette->GetFGCOLORREF(Image->uBitmap->BitsPerPixel); PenThick = PenManagerForm->Pen->BasicThick; if (PenManagerForm && PenManagerForm->Pen->Thick != PenManagerForm->rzsePenSize->Value) { PenManagerForm->Pen->Thick = PenManagerForm->rzsePenSize->Value; PenManagerForm->Pen->Thick = PenManagerForm->Pen->BasicThick; } pw = PenManagerForm->Pen->BasicThick + 10; BtnClick = true; rect = Rect(0, 0, Image->uBitmap->Width, Image->uBitmap->Height); if (Item != TD_CIRCLE && Item != TD_ELLIP){ if (MousePointPlace == 1) { XD = XD+PenThick/2; YD = YD+PenThick/2; } else if (MousePointPlace == 2) { XD = XD-PenThick/2; YD = YD+PenThick/2; } else if (MousePointPlace == 3) { XD = XD+PenThick/2; YD = YD-PenThick/2; } else if (MousePointPlace == 4) { XD = XD-PenThick/2; YD = YD-PenThick/2; } } switch (Item) { case TD_OUT : if(pw > 50){ ShowMessage(IDS_MESSAGE_OUTLINEPENSIZEOVER); return; } if (PenManagerForm->sbMask->Down) { MainImageForm->UndoSave(UK_MASK, Rect(0,0,0,0)); //by linuxjun if (MainImageForm->reflection){ if (Image->uBitmap->BitsPerPixel == 8) { MainImageForm->UndoSave(UK_PATTERN, Rect(0,0,0,0)); //by linuxjun Reflection_outline(XD, YD); MainImageForm->Undo->UndoRead(); } else { if(!Reflection_outline_24(XD, YD)) MainImageForm->Undo->RemoveLast(); // outline_24(XD, YD); //may be bug don't ignore } } else { if (Image->uBitmap->BitsPerPixel == 8) { MainImageForm->UndoSave(UK_PATTERN, Rect(0,0,0,0)); //by linuxjun outline(XD, YD); MainImageForm->Undo->UndoRead(); } else { if(!outline_24(XD, YD)) MainImageForm->Undo->RemoveLast(); // outline_24(XD, YD); //may be bug don't ignore } } } else { MainImageForm->UndoSave(UK_PATTERN, Rect(0,0,0,0)); //by linuxjun if (MainImageForm->reflection){ if (Image->uBitmap->BitsPerPixel == 8) { if (MainImageForm->Protect==false) { Reflection_outline(XD, YD); } else { if (MainImageForm->Palette->ColorData[Image->uBitmap->GetPixelColor(XD, YD)]->Protect==0) { Reflection_outline(XD, YD); } } } else { if(!Reflection_outline_24(XD, YD)) MainImageForm->Undo->RemoveLast(); //outline_24(XD, YD); //may be bug don't ignore } } else { if (Image->uBitmap->BitsPerPixel == 8) { if (MainImageForm->Protect==false) { outline(XD, YD); } else { if (MainImageForm->Palette->ColorData[Image->uBitmap->GetPixelColor(XD, YD)]->Protect==0) { outline(XD, YD); } } } else { if(!outline_24(XD, YD)) MainImageForm->Undo->RemoveLast(); //outline_24(XD, YD); //may be bug don't ignore } } } if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(PenManagerForm->sbMask->Down, true); break; case TD_LINE : // if (isw == 0) { // Input switch if (!hasUserLength && !isHVLine) { if (Ltype[TD_LINE].sw == 0) { // solid or dot xkey = 0; if (step == 0) { firstln = Point(XD, YD); Lsx = XD; Lsy = YD; Lex = Lsx; Ley = Lsy; DrawLineLocate(Point(Lsx, Lsy), Point(Lex, Ley)); if (Line_type) AddPointList(XD, YD, c); step = 1; separatel = 1; //lhskys ²÷¾îÁø Á¡¼± È®ÀÎ... } else if (step == 1) { Lex = XD; Ley = YD; if (Line_type == 0) { lsx = min(Lsx, Lex); lsy = min(Lsy, Ley); lex = max(Lsx, Lex); ley = max(Lsy, Ley); rect = Rect(lsx-pw/2, lsy-pw/2, lex+pw/2, ley+pw/2); if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) rect = MainImageForm->AutoRep_UndoRect(rect); // MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN, rect); MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN, Rect(0,0,0,0)); //by linuxjun } else { AddPointList(XD, YD, c); if (undos == 0) { // MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN, rect); MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN, Rect(0,0,0,0)); //by linuxjun undos = 1; } } if (!isTaper) Line(c); else {s_size = StartSize->Value; e_size = EndSize->Value; TaperLine(s_size, e_size, 0, 1, c); //k3dogs } //by jeegeo MainImageForm->iMainImage->RectPaint(rect/*Rect(lsx-15, lsy-15, lex+15, ley+15)*/); //k3dogs 20001212 ÀÜ»óÀÌ ³²¾Æ¼­.. if (Line_type == 0) { step = 0; } else if (Line_type == 1) { Lsx = Lex; Lsy = Ley; } if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(PenManagerForm->sbMask->Down, true); } } else if (Ltype[TD_LINE].sw == 1) { if(eDotLength->Value == 0){// || eDotSpace->Text == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); iMainImageChange(); if (Line_type == 1 || Curve_type == 1) { InitPointList(); step = 0; undos = 0; xkey = 1; } { END_LOG; return; } } if (step == 0) { firstln = Point(XD, YD); Tstitch.l[1].sx = XD; Tstitch.l[1].sy = YD; Tstitch.sx = Tstitch.l[1].sx; Tstitch.sy = Tstitch.l[1].sy; Tstitch.ex = Tstitch.l[1].sx; Tstitch.ey = Tstitch.l[1].sy; Tstitch.l[1].ex = Tstitch.l[1].sx; Tstitch.l[1].ey = Tstitch.l[1].sy; DrawDotLineLocate(Point(Tstitch.l[1].sx, Tstitch.l[1].sy), Point(Tstitch.l[1].ex, Tstitch.l[1].ey)); if (Line_type) AddPointList(XD, YD, c); step = 1; separatel = 1; //lhskys ²÷¾îÁø Á¡¼± È®ÀÎ... } else if (step == 1) { if (Line_type == 0) { lsx = min(Tstitch.l[1].sx, Tstitch.l[1].ex); lsy = min(Tstitch.l[1].sy, Tstitch.l[1].ey); lex = max(Tstitch.l[1].sx, Tstitch.l[1].ex); ley = max(Tstitch.l[1].sy, Tstitch.l[1].ey); rect = Rect(lsx-pw/2, lsy-pw/2, lex+pw/2, ley+pw/2); if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) rect = MainImageForm->AutoRep_UndoRect(rect); // MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN, rect); MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN, Rect(0,0,0,0)); //by linuxjun } else { AddPointList(XD, YD, c); if (undos == 0) { // MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN, rect); MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN, Rect(0,0,0,0)); //by linuxjun undos = 1; } } dot_line(pmCopy, 1, Ltype[TD_LINE].value, c); if (Line_type == 0) { step = 0; } else if (Line_type == 1) { Tstitch.l[1].sx = Tstitch.l[1].ex; Tstitch.l[1].sy = Tstitch.l[1].ey; } if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(PenManagerForm->sbMask->Down, true); } } } else if (isHVLine) { if (Ltype[TD_LINE].sw == 0) { //isw != 0 separatel = 0; //lhskys ²÷¾îÁø Á¡¼± È®ÀÎ... int delta_x,delta_y; delta_x = (XD - Lsx); if(delta_x<0) delta_x = -delta_x; delta_y = (YD - Lsy); if(delta_y<0) delta_y = -delta_y; if( delta_xUndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN, Rect(0,0,0,0)); } else { if (undos == 0) { MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN, Rect(0,0,0,0)); undos = 1; } } if (!isTaper) Line(c); //lhskys Taper À϶§... else {s_size = StartSize->Value; e_size = EndSize->Value; TaperLine(s_size, e_size, 0, 1, c); } // Line(c); if (Line_type == 0) { step = 0; } else if (Line_type == 1) { Lsx = Lex; Lsy = Ley; AddPointList(Lex,Ley, c); //lhskys ¼±±×¸®±â¿¡¼­ z۸¦ ´­·¶À»¶§ Ä«¿îÆ®¸¦ } //lhskys ÇØÁ־ ÇÑÁ¡µÚ·ÎÀÇ ±â´ÉÀ» ÇÒ¼ö ÀÖµµ·Ï... if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(PenManagerForm->sbMask->Down, true); // isw = 0; isHVLine = false; isNumberInput = false; //============================================================================== } else if (Ltype[TD_LINE].sw == 1) { //lhskys Á¡¼±À϶§ Á¡Âï¾îÁÖ±â... separatel = 0; //lhskys ²÷¾îÁø Á¡¼± È®ÀÎ... int delta_x,delta_y; delta_x = (XD - Tstitch.l[1].sx); if(delta_x<0) delta_x = -delta_x; delta_y = (YD - Tstitch.l[1].sy); if(delta_y<0) delta_y = -delta_y; if( delta_xUndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN, Rect(0,0,0,0)); } else { if (undos == 0) { MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN, Rect(0,0,0,0)); undos = 1; } } dot_line(pmCopy, 1, Ltype[TD_LINE].value, c); if (Line_type == 0) { step = 0; } else if (Line_type == 1) { Tstitch.l[1].sx = Tstitch.l[1].ex; Tstitch.l[1].sy = Tstitch.l[1].ey; AddPointList(Tstitch.l[1].ex,Tstitch.l[1].ey, c); //lhskys ¼±±×¸®±â¿¡¼­ z۸¦ ´­·¶À»¶§ Ä«¿îÆ®¸¦ } //lhskys ÇØÁ־ ÇÑÁ¡µÚ·ÎÀÇ ±â´ÉÀ» ÇÒ¼ö ÀÖµµ·Ï... // isw = 0; isHVLine = false; isNumberInput = false; } } else if (hasUserLength) { if (Ltype[TD_LINE].sw == 0) { //isw != 0 Lex = XD; Ley = YD; LenAng_check(XD, YD); // Z Ű ¹æ¹ý ¼öÁ¤ by celberus if (Line_type == 0) { MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN, Rect(0,0,0,0)); } else { if (undos == 0) { MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN, Rect(0,0,0,0)); undos = 1; } } if (!isTaper) Line(c); //lhskys Taper À϶§... else {s_size = StartSize->Value; e_size = EndSize->Value; TaperLine(s_size, e_size, 0, 1, c); } // Line(c); if (Line_type == 0) { step = 0; } else if (Line_type == 1) { Lsx = Lex; Lsy = Ley; AddPointList(Lex,Ley, c); //lhskys ¼±±×¸®±â¿¡¼­ z۸¦ ´­·¶À»¶§ Ä«¿îÆ®¸¦ } //lhskys ÇØÁ־ ÇÑÁ¡µÚ·ÎÀÇ ±â´ÉÀ» ÇÒ¼ö ÀÖµµ·Ï... if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(PenManagerForm->sbMask->Down, true); // isw = 0; hasUserLength = false; isNumberInput = false; //============================================================================== } else if (Ltype[TD_LINE].sw == 1) { //lhskys Á¡¼±À϶§ Á¡Âï¾îÁÖ±â... separatel = 0; //lhskys ²÷¾îÁø Á¡¼± È®ÀÎ... Tstitch.l[1].ex = XD; Tstitch.l[1].ey = YD; LenAng_check(XD, YD); // Z Ű ¹æ¹ý ¼öÁ¤ by celberus if (Line_type == 0) { MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN, Rect(0,0,0,0)); } else { if (undos == 0) { MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN, Rect(0,0,0,0)); undos = 1; } } dot_line(pmCopy, 1, Ltype[TD_LINE].value, c); if (Line_type == 0) { step = 0; } else if (Line_type == 1) { Tstitch.l[1].sx = Tstitch.l[1].ex; Tstitch.l[1].sy = Tstitch.l[1].ey; AddPointList(Tstitch.l[1].ex,Tstitch.l[1].ey, c); //lhskys ¼±±×¸®±â¿¡¼­ z۸¦ ´­·¶À»¶§ Ä«¿îÆ®¸¦ } //lhskys ÇØÁ־ ÇÑÁ¡µÚ·ÎÀÇ ±â´ÉÀ» ÇÒ¼ö ÀÖµµ·Ï... // isw = 0; hasUserLength = false; isNumberInput = false; } } //============================================================================== break; case TD_SQUR : // if (isw == 0) { if (!hasUserLength) { if (Ltype[TD_SQUR].sw == 0) { if (step == 0) { Lsx = XD; Lsy = YD; Lex = Lsx; Ley = Lsy; square(pmXor, c); step = 1; } else if (step == 1) { Lex = XD; Ley = YD; lsx = min(Lsx, Lex); lsy = min(Lsy, Ley); lex = max(Lsx, Lex); ley = max(Lsy, Ley); rect = Rect(lsx-pw/2, lsy-pw/2, lex+pw/2, ley+pw/2); if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) rect = MainImageForm->AutoRep_UndoRect(rect); MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN, Rect(0,0,0,0)); square(pmCopy, c); step = 0; if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(PenManagerForm->sbMask->Down, true); } } else if (Ltype[TD_SQUR].sw == 1) { if(eDotLength->Value == 0){// || eDotSpace->Text == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); END_LOG; return; } if (step == 0) { Tstitch.l[1].sx = XD; Tstitch.l[1].sy = YD; Tstitch.sx = Tstitch.l[1].sx; Tstitch.sy = Tstitch.l[1].sy; Tstitch.ex = Tstitch.l[1].sx; Tstitch.ey = Tstitch.l[1].sy; Tstitch.l[1].ex = Tstitch.l[1].sx; Tstitch.l[1].ey = Tstitch.l[1].sy; DrawDotRectangleLocate(Rect(Tstitch.l[1].sx, Tstitch.l[1].sy, Tstitch.l[1].ex, Tstitch.l[1].ey)); step = 1; } else if (step == 1) { lsx = min(Tstitch.l[1].sx, Tstitch.l[1].ex); lsy = min(Tstitch.l[1].sy, Tstitch.l[1].ey); Tstitch.l[1].ex = Lex; Tstitch.l[1].ey = Ley; lex = max(Tstitch.l[1].sx, Tstitch.l[1].ex); ley = max(Tstitch.l[1].sy, Tstitch.l[1].ey); rect = Rect(lsx-pw/2, lsy-pw/2, lex+pw/2, ley+pw/2); if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) rect = MainImageForm->AutoRep_UndoRect(rect); MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN, Rect(0,0,0,0)); dotted_square(pmCopy, Ltype[TD_SQUR].value, c); step = 0; if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(PenManagerForm->sbMask->Down, true); } } } else { if(MainImageForm->CurrentUnit == uDot) { if (eLength1->IntValue == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); END_LOG; return; } }else if(MainImageForm->CurrentUnit == uInch) { if (eLength1->Value == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); END_LOG; return; } }else if (MainImageForm->CurrentUnit == uCm) { if (eLength1->Value == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); END_LOG; return; } } if (Ltype[TD_SQUR].sw == 0) { sqr_len = Sqr_l - pw; Csx = XD; Csy = YD; Lsx = Csx - sqr_len / 2.0; Lsy = Csy - sqr_len / 2.0; if ((Csx >= 0) && (Csx <= sqr_len / 2.0)) Lsx = 0; else if ((Csx >= Image->uBitmap->Width - sqr_len / 2.0) && (Csx <= Image->uBitmap->Width)) Lsx = Image->uBitmap->Width - sqr_len; if ((Csy >= 0) && (Csy <= sqr_len / 2.0)) Lsy = 0; else if ((Csy >= Image->uBitmap->Height - sqr_len / 2.0) && (Csy <= Image->uBitmap->Height)) Lsy = Image->uBitmap->Height - sqr_len; Lex = Lsx + sqr_len - 1; Ley = Lsy + sqr_len - 1; MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN,Rect(0,0,0,0)); square(pmCopy, c); }else if (Ltype[TD_SQUR].sw == 1) { int pt = PenManagerForm->Pen->BasicThick; sqr_len = Sqr_l; Tstitch.l[1].sx = XD; Tstitch.l[1].sy = YD; Tstitch.sx = Tstitch.l[1].sx - sqr_len / 2.0 + pt/2; Tstitch.sy = Tstitch.l[1].sy - sqr_len / 2.0 + pt/2; if ((Tstitch.l[1].sx >= 0) && (Tstitch.l[1].sx <= sqr_len / 2.0)) Lsx = 0; else if ((Tstitch.l[1].sx >= Image->uBitmap->Width - sqr_len / 2.0) && (Tstitch.l[1].sx <= Image->uBitmap->Width)) Lsx = Image->uBitmap->Width - sqr_len; if ((Tstitch.l[1].sy >= 0) && (Tstitch.l[1].sy <= sqr_len / 2.0)) Lsy = 0; else if ((Tstitch.l[1].sy >= Image->uBitmap->Height - sqr_len / 2.0) && (Tstitch.l[1].sy <= Image->uBitmap->Height)) Lsy = Image->uBitmap->Height - sqr_len; Lex = Tstitch.l[1].sx + sqr_len / 2.0 - pt/2; Ley = Tstitch.l[1].sy + sqr_len / 2.0 - pt/2; Tstitch.ex = Lex; Tstitch.ey = Ley; MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN, Rect(0,0,0,0)); dotted_square(pmCopy, Ltype[TD_SQUR].value, c); } step = 0; // isw = 0; hasUserLength = false; isNumberInput = false; if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(PenManagerForm->sbMask->Down, true); } break; case TD_RECT : // if (isw == 0) { if (!hasUserLength) { if (Ltype[TD_RECT].sw == 0) { if (step == 0) { Lsx = XD; Lsy = YD; Lex = Lsx; Ley = Lsy; rectangle(pmXor, c); step = 1; } else if (step == 1) { Lex = XD; Ley = YD; lsx = min(Lsx, Lex); lsy = min(Lsy, Ley); lex = max(Lsx, Lex); ley = max(Lsy, Ley); rect = Rect(lsx-pw/2, lsy-pw/2, lex+pw/2, ley+pw/2); if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) rect = MainImageForm->AutoRep_UndoRect(rect); MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN,Rect(0,0,0,0)); rectangle(pmCopy, c); step = 0; if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(PenManagerForm->sbMask->Down, true); } } else if (Ltype[TD_RECT].sw == 1) { if(eDotLength->Value == 0){// || eDotSpace->Text == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); END_LOG; return; } if (step == 0) { Tstitch.l[1].sx = XD; Tstitch.l[1].sy = YD; Tstitch.sx = Tstitch.l[1].sx; Tstitch.sy = Tstitch.l[1].sy; Tstitch.ex = Tstitch.l[1].sx; Tstitch.ey = Tstitch.l[1].sy; Tstitch.l[1].ex = Tstitch.l[1].sx; Tstitch.l[1].ey = Tstitch.l[1].sy; DrawDotRectangleLocate(Rect(Tstitch.l[1].sx, Tstitch.l[1].sy, Tstitch.l[1].ex, Tstitch.l[1].ey)); step = 1; } else if (step == 1) { lsx = min(Tstitch.l[1].sx, Tstitch.l[1].ex); lsy = min(Tstitch.l[1].sy, Tstitch.l[1].ey); Tstitch.l[1].ex = Lex; Tstitch.l[1].ey = Ley; lex = max(Tstitch.l[1].sx, Tstitch.l[1].ex); ley = max(Tstitch.l[1].sy, Tstitch.l[1].ey); rect = Rect(lsx-pw/2, lsy-pw/2, lex+pw/2, ley+pw/2); if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) rect = MainImageForm->AutoRep_UndoRect(rect); MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN, Rect(0,0,0,0)); dotted_rectangle(pmCopy, Ltype[TD_RECT].value, c); step = 0; if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(PenManagerForm->sbMask->Down, true); } } } else { if(MainImageForm->CurrentUnit == uDot) { if (eLength1->IntValue == 0 || eLength2->IntValue == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); END_LOG; return; } }else if(MainImageForm->CurrentUnit == uInch) { if (eLength1->Value == 0 || eLength2->Value == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); END_LOG; return; } }else if (MainImageForm->CurrentUnit == uCm) { if (eLength1->Value == 0 || eLength2->Value == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); END_LOG; return; } } MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN, Rect(0,0,0,0)); if (Ltype[TD_RECT].sw == 0) { rec_x = Rec_lx - pw; rec_y = Rec_ly - pw; Csx = XD; Csy = YD; Lsx = Csx - rec_x / 2.0; Lsy = Csy - rec_y / 2.0; if ((Csx >= 0) && (Csx <= rec_x / 2.0)) Lsx = 0; else if ((Csx >= Image->uBitmap->Width - rec_x / 2.0) && (Csx < Image->uBitmap->Width)) Lsx = (Image->uBitmap->Width - 1) - rec_x; if ((Csy>=0) && (Csy <= rec_y / 2.0)) Lsy = 0; else if ((Csy >= Image->uBitmap->Height - rec_y / 2.0) && (Csy < Image->uBitmap->Height)) Lsy = (Image->uBitmap->Height - 1) - rec_y; Lex = Lsx + rec_x - 1; Ley = Lsy + rec_y - 1; rectangle(pmCopy, c); }else if (Ltype[TD_RECT].sw == 1) { int pt = PenManagerForm->Pen->BasicThick; rec_x = Rec_lx - pt; rec_y = Rec_ly - pt; Tstitch.l[1].sx = XD; Tstitch.l[1].sy = YD; Lsx = Tstitch.l[1].sx - rec_x / 2.0; Lsy = Tstitch.l[1].sy - rec_y / 2.0; Tstitch.sx = Lsx; Tstitch.sy = Lsy; if ((Tstitch.l[1].sx >= 0) && (Tstitch.l[1].sx <= rec_x / 2.0)) Lsx = 0; else if ((Tstitch.l[1].sx >= Image->uBitmap->Width - rec_x / 2.0) && (Tstitch.l[1].sx < Image->uBitmap->Width)) Lsx = (Image->uBitmap->Width - 1) - rec_x; if ((Tstitch.l[1].sy>=0) && (Tstitch.l[1].sy <= rec_y / 2.0)) Lsy = 0; else if ((Tstitch.l[1].sy >= Image->uBitmap->Height - rec_y / 2.0) && (Tstitch.l[1].sy < Image->uBitmap->Height)) Lsy = (Image->uBitmap->Height - 1) - rec_y; Lex = Lsx + rec_x; Ley = Lsy + rec_y; Tstitch.ex = Lex; Tstitch.ey = Ley; if (MainImageForm->reflection){ if (Tstitch.sx < 0) Tstitch.ex += Tstitch.sx; if (Tstitch.sy < 0) Tstitch.ey += Tstitch.sy; } dotted_rectangle(pmCopy, Ltype[TD_RECT].value, c); } step = 0; // isw = 0; hasUserLength = false; isNumberInput = false; if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(PenManagerForm->sbMask->Down, true); } break; case TD_CIRCLE : // if (isw == 0) { if (!hasUserLength) { if (Ltype[TD_CIRCLE].sw == 1) { if(eDotLength->Value == 0){// || eDotSpace->Text == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); END_LOG; return; } } if (step == 0) { Csx = XD; Csy = YD; Lsx = Csx; Lsy = Csy; cirlast.x = Csx; cirlast.y = Csy; cirlastpoint = false; rzbtnLastCenter->Enabled = true; circle(pmXor, c); step = 1; } else if (step == 1) { Lsx = XD; Lsy = YD; ra = sqrt((Csx-Lsx)*(Csx-Lsx) + (Csy-Lsy)*(Csy-Lsy)); rect = Rect(Csx-ra-pw/2, Csy-ra-pw/2, Csx+ra+pw/2, Csy+ra+pw/2); if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) rect = MainImageForm->AutoRep_UndoRect(rect); MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN, Rect(0,0,0,0)); if (Ltype[TD_CIRCLE].sw == 0) { circle(pmCopy, c); } else if (Ltype[TD_CIRCLE].sw == 1) { dotted_circle(pmCopy, Ltype[TD_CIRCLE].value); } step = 0; if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(PenManagerForm->sbMask->Down, true); } } else { if(MainImageForm->CurrentUnit == uDot) { if (eLength1->IntValue == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); END_LOG; return; } }else if(MainImageForm->CurrentUnit == uInch) { if (eLength1->Value == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); END_LOG; return; } }else if (MainImageForm->CurrentUnit == uCm) { if (eLength1->Value == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); END_LOG; return; } } Tradius = Radius - pw / 2.0; Csx = XD; Csy = YD; cirlast.x = Csx; cirlast.y = Csy; cirlastpoint = false; rzbtnLastCenter->Enabled = true; if (Ltype[TD_CIRCLE].sw == 0) { Lsx = Csx + Tradius - 1; Lsy = Csy + Tradius - 1; } else if (Ltype[TD_CIRCLE].sw == 1) { Lsx = Csx + Radius/2; Lsy = Csy; } if (Lsx > Image->uBitmap->Width) Lsx = Csx - Tradius - 1; MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN, Rect(0,0,0,0)); if (Ltype[TD_CIRCLE].sw == 0) { circle(pmCopy, c); } else if (Ltype[TD_CIRCLE].sw == 1) { dotted_circle(pmCopy, Ltype[TD_CIRCLE].value); } step = 0; // isw = 0; hasUserLength = false; isNumberInput = false; if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(PenManagerForm->sbMask->Down, true); } break; case TD_ELLIP : // if (isw == 0) { if (!hasUserLength) { if (Ltype[TD_CIRCLE].sw == 1) { if(eDotLength->Value == 0){// || eDotSpace->Text == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); END_LOG; return; } } if (step == 0) { Csx = XD; Csy = YD; Lsx = Csx; Lsy = Csy; elliplast.x = Csx; elliplast.y = Csy; elliplastpoint = false; rzbtnLastCenter->Enabled = true; ellipse(pmXor, c); step = 1; } else if (step == 1 ) { Lsx = XD; Lsy = YD; if (Csx > Lsx) { lsx = Lsx; lex = Lsx + 2*(Csx - Lsx); } else { lex = Lsx; lsx = Lsx - 2*(Lsx - Csx); } if (Csy > Lsy) { lsy = Lsy; ley = Lsy + 2*(Csy - Lsy); } else { ley = Lsy; lsy = Lsy - 2*(Lsy - Csy); } rect = Rect(lsx-pw/2, lsy-pw/2, lex+pw/2, ley+pw/2); if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) rect = MainImageForm->AutoRep_UndoRect(rect); MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN, Rect(0,0,0,0)); if (Ltype[TD_ELLIP].sw == 0) { ellipse(pmCopy, c); } else if (Ltype[TD_ELLIP].sw == 1) { dotted_ellipse(pmCopy, Ltype[TD_ELLIP].value); } step = 0; if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(PenManagerForm->sbMask->Down, true); } } else { if(MainImageForm->CurrentUnit == uDot) { if (eLength1->IntValue == 0 || eLength2->IntValue == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); END_LOG; return; } }else if(MainImageForm->CurrentUnit == uInch) { if (eLength1->Value == 0 || eLength2->Value == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); END_LOG; return; } }else if (MainImageForm->CurrentUnit == uCm) { if (eLength1->Value == 0 || eLength2->Value == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); END_LOG; return; } } MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN,Rect(0,0,0,0)); ell_x = Ell_rx - pw / 2.0; ell_y = Ell_ry - pw / 2.0; Csx = XD; Csy = YD; elliplast.x = Csx; elliplast.y = Csy; elliplastpoint = false; rzbtnLastCenter->Enabled = true; if (Ltype[TD_ELLIP].sw == 0) { Lsx = Csx + ell_x - 1; Lsy = Csy + ell_y - 1; } else if (Ltype[TD_ELLIP].sw == 1) { Lsx = Csx + Ell_rx/2; Lsy = Csy + Ell_ry/2; } if (Lsx > Image->uBitmap->Width) Lsx = Csx - ell_x - 1; if (Lsy > Image->uBitmap->Height) Lsy = Csy - ell_y - 1; if (Ltype[TD_ELLIP].sw == 0) { ellipse(pmCopy, c); } else if (Ltype[TD_ELLIP].sw == 1) { dotted_ellipse(pmCopy, Ltype[TD_ELLIP].value); } step = 0; // isw = 0; hasUserLength = false; isNumberInput = false; if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(PenManagerForm->sbMask->Down, true); } break; case TD_CURVE : if (Ltype[TD_CURVE].sw == 0) { if (step == 0) { firstln = Point(XD, YD); curvest = true; //2001.4.17 by lhskys °î¼± ÇÑÁ¡µÚ·Î¿¡¼­ Lsx = XD; Lsy = YD; Lex = Lsx; Ley = Lsy; if (Curve_type) AddPointList(XD, YD, c); DrawLineLocate(Point(Lsx, Lsy), Point(Lex, Ley)); step = 1; } else if (step == 1) { if (Curve_input == 0) { Lex = XD; Ley = YD; Csx = Lex; Csy = Ley; } else if (Curve_input == 1) { Csx = XD; Csy = YD; Lex = Csx; Ley = Csy; } DrawLineLocate(Point(Lsx, Lsy), Point(Lex, Ley)); //================================================ //2001.4.10 by lhskys °î¼± ÇÑÁ¡µÚ·Î¿¡¼­ if(curvest){ // óÀ½¿¡ undosave°¡ ¾ÈµÇ¼­ üũ ÈÄ undosave ÇßÀ½ MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN, Rect(0,0,0,0)); curvest = false; } //================================================ if (Curve_type) AddPointList(XD, YD, c); step = 2; } else if (step == 2) { if (Curve_input == 0) { Csx = XD; Csy = YD; } else if (Curve_input == 1) { Lex = XD; Ley = YD; } if (Curve_type == 0) { //===================================== //2001.4.17 by lhskys °î¼± ÇÑÁ¡µÚ·Î¿¡¼­ if(curvest)MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN, Rect(0,0,0,0)); //===================================== } else { if (undos == 0) { //===================================== //2001.4.17 by lhskys °î¼± ÇÑÁ¡µÚ·Î¿¡¼­ if(curvest)MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN, Rect(0,0,0,0)); //===================================== undos = 1; } AddPointList(XD, YD, c); } if (!isTaper) curve(pmCopy, c); else TaperCurve(pmCopy, c); if (Curve_type == 0) { step = 0; } else if (Curve_type == 1) { step = 1; Lsx = Lex; Lsy = Ley; } if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(PenManagerForm->sbMask->Down, true); } } else if (Ltype[TD_CURVE].sw == 1) { if(eDotLength->Value == 0){// || eDotSpace->Text == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); END_LOG; return; } if (step == 0) { firstln = Point(XD, YD); curvest = true; //2001.4.17 by lhskys °î¼± ÇÑÁ¡µÚ·Î¿¡¼­ Tstitch.l[1].sx = XD; Tstitch.l[1].sy = YD; Tstitch.sx = Tstitch.l[1].sx; Tstitch.sy = Tstitch.l[1].sy; Tstitch.ex = Tstitch.l[1].sx; Tstitch.ey = Tstitch.l[1].sy; Tstitch.l[1].ex = Tstitch.l[1].sx; Tstitch.l[1].ey = Tstitch.l[1].sy; Lsx = Tstitch.sx; Lsy = Tstitch.sy; Lex = Lsx; Ley = Lsy; DrawDotLineLocate(Point(Tstitch.l[1].sx, Tstitch.l[1].sy), Point(Tstitch.l[1].ex, Tstitch.l[1].ey)); step = 1; if (Curve_type) AddPointList(XD, YD, c); } else if (step == 1) { if (Curve_input == 0) { Lex = XD; Ley = YD; Csx = Lex; Csy = Ley; } else if (Curve_input == 1) { Csx = XD; Csy = YD; Lex = Csx; Ley = Csy; } DrawDotLineLocate(Point(Tstitch.l[1].sx, Tstitch.l[1].sy), Point(Tstitch.l[1].ex, Tstitch.l[1].ey)); //================================================ //2001.4.10 by lhskys °î¼± ÇÑÁ¡µÚ·Î¿¡¼­ if(curvest){ // óÀ½¿¡ undosave°¡ ¾ÈµÇ¼­ üũ ÈÄ undosave ÇßÀ½ MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN, Rect(0,0,0,0)); curvest = false; } //================================================ step = 2; if (Curve_type) AddPointList(XD, YD, c); } else { if (Curve_input == 0) { Csx = XD; Csy = YD; } else if (Curve_input == 1) { Lex = XD; Ley = YD; } if (Curve_type == 0) { //===================================== //2001.4.17 by lhskys °î¼± ÇÑÁ¡µÚ·Î¿¡¼­ if(curvest)MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN, Rect(0,0,0,0)); //===================================== } else { if (undos == 0) { //===================================== //2001.4.17 by lhskys °î¼± ÇÑÁ¡µÚ·Î¿¡¼­ if(curvest)MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_MASK : UK_PATTERN, Rect(0,0,0,0)); //===================================== undos = 1; } AddPointList(XD, YD, c); } dot_curve(pmCopy, Ltype[TD_CURVE].value, c); if (Curve_type == 0) { step = 0; } else if (Curve_type == 1) { step = 1; Tstitch.l[1].sx = Lex; Tstitch.l[1].sy = Ley; Tstitch.l[1].ex = Tstitch.l[1].sx; Tstitch.l[1].ey = Tstitch.l[1].sy; Tstitch.sx = Tstitch.l[1].sx; Tstitch.sy = Tstitch.l[1].sy; Tstitch.ex = Tstitch.l[1].sx; Tstitch.ey = Tstitch.l[1].sy; Lsx = Tstitch.l[1].sx; Lsy = Tstitch.l[1].sy; } if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(PenManagerForm->sbMask->Down, true); } } } Asw = 0; Lsw = 0; // SetFocus(); // ¹Ú»óÈÆÀÌ ÁÖ¼®Ã³¸® (05.04.21) - ¿Ö ÇÊ¿äÇÑÁö ¾Ë¼ö¾øÀ½(ÇöÀç ´ÜÃàŰ // »ç¿ë½Ã ¹®Á¦(abstract¿¡·¯ ¹ß»ý)°¡ ¹ß»ýÇϱ⠶§¹®¿¡ ÁÖ¼®À¸·Î ó¸®ÇßÀ½) END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::DrawMouseMove(TShiftState Shift, int XD, int YD) { int pw; Byte c; TPItemImage *Image = MainImageForm->iMainImage; c = PaletteForm->DIB256Palette->ChoiceIndex; pw = PenManagerForm->Pen->BasicThick; if (Item != TD_CIRCLE && Item != TD_ELLIP){ if (MousePointPlace == 1) { XD = XD+pw/2; YD = YD+pw/2; } else if (MousePointPlace == 2) { XD = XD-pw/2; YD = YD+pw/2; } else if (MousePointPlace == 3) { XD = XD+pw/2; YD = YD-pw/2; } else if (MousePointPlace == 4) { XD = XD-pw/2; YD = YD-pw/2; } } switch (Item) { case TD_LINE : // if (isw == 0) { if (!hasUserLength && !isHVLine) { if (Ltype[TD_LINE].sw == 0) { if (step == 1) { Lex = XD; Ley = YD; DrawLineLocate(Point(Lsx, Lsy), Point(Lex, Ley)); LengthAngle(); } } else if (Ltype[TD_LINE].sw == 1) { if (step == 1) { if(eDotLength->Value == 0){// || eDotSpace->Text == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); iMainImageChange(); if (Line_type == 1 || Curve_type == 1) { InitPointList(); step = 0; undos = 0; xkey = 1; } return; } Tstitch.l[1].ex = XD; Tstitch.l[1].ey = YD; Tstitch.ex = Tstitch.l[1].ex; Tstitch.ey = Tstitch.l[1].ey; DrawDotLineLocate(Point(Tstitch.l[1].sx, Tstitch.l[1].sy), Point(Tstitch.l[1].ex, Tstitch.l[1].ey)); LengthAngle(); } } // } else if (isw == 1) { // Z Ű } else if (isHVLine) { if (Ltype[TD_LINE].sw == 0){ int delta_x,delta_y; delta_x = (XD - Lsx); if(delta_x<0) delta_x = -delta_x; delta_y = (YD - Lsy); if(delta_y<0) delta_y = -delta_y; if( delta_xValue == 0)return; Tstitch.l[1].ex = XD; Tstitch.l[1].ey = YD; // LenAng_check(XD, YD); Z Ű ¹æ¹ý ¼öÁ¤ by celberus Tstitch.ex = Tstitch.l[1].ex; Tstitch.ey = Tstitch.l[1].ey; DrawDotLineLocate(Point(Tstitch.l[1].sx, Tstitch.l[1].sy), Point(Tstitch.l[1].ex, Tstitch.l[1].ey)); LengthAngle(); //============================================================================== } } else if (hasUserLength) { if (Ltype[TD_LINE].sw == 0){ Lex = XD; Ley = YD; LenAng_check(XD, YD); // Z Ű ¹æ¹ý ¼öÁ¤ by celberus DrawLineLocate(Point(Lsx, Lsy), Point(Lex, Ley)); LengthAngle(); //============================================================================== }else if(Ltype[TD_LINE].sw == 1){ //lhskys z Ű Á¡¼±À϶§ if(eDotLength->Value == 0)return; Tstitch.l[1].ex = XD; Tstitch.l[1].ey = YD; LenAng_check(XD, YD); // Z Ű ¹æ¹ý ¼öÁ¤ by celberus Tstitch.ex = Tstitch.l[1].ex; Tstitch.ey = Tstitch.l[1].ey; DrawDotLineLocate(Point(Tstitch.l[1].sx, Tstitch.l[1].sy), Point(Tstitch.l[1].ex, Tstitch.l[1].ey)); LengthAngle(); //============================================================================== } } break; case TD_SQUR : // if (isw == 0) { if (!hasUserLength) { if (Ltype[TD_SQUR].sw == 0) { if (step == 1) { Lex = XD; Ley = YD; square(pmXor, c); } } else if (Ltype[TD_SQUR].sw == 1) { if (step == 1) { Lex = XD; Ley = YD; Tstitch.l[1].ex = XD; Tstitch.l[1].ey = YD; Tstitch.ex = Tstitch.l[1].ex; Tstitch.ey = Tstitch.l[1].ey; square(pmXor, c); } } /* if (Ltype[TD_SQUR].sw == 0) { if (step == 1) { Lex = XD; Ley = YD; square(pmXor, c); } } else if (Ltype[TD_SQUR].sw == 1) { if (step == 1) { Tstitch.l[1].ex = XD; Tstitch.l[1].ey = YD; Tstitch.ex = Tstitch.l[1].ex; Tstitch.ey = Tstitch.l[1].ey; DrawDotRectangleLocate(Rect(Tstitch.l[1].sx, Tstitch.l[1].sy, Tstitch.l[1].ex, Tstitch.l[1].ey)); ::RepaintImage(); DrawDotRectangleLocate(Rect(Tstitch.l[1].sx, Tstitch.l[1].sy, Tstitch.l[1].ex, Tstitch.l[1].ey)); } }*/ } else { sqr_len = Sqr_l - pw; Csx = XD; Csy = YD; Lsx = Csx - sqr_len / 2.0; Lsy = Csy - sqr_len / 2.0; if ((Csx >= 0) && (Csx <= sqr_len / 2.0)) Lsx = 0; else if ((Csx >= Image->uBitmap->Width - sqr_len / 2.0) && (Csx <= Image->uBitmap->Width)) Lsx = Image->uBitmap->Width - sqr_len; if ((Csy >= 0) && (Csy <= sqr_len / 2.0)) Lsy = 0; else if ((Csy >= Image->uBitmap->Height - sqr_len / 2.0) && (Csy <= Image->uBitmap->Height)) Lsy = Image->uBitmap->Height - sqr_len; Lex = Lsx + sqr_len - 1; Ley = Lsy + sqr_len - 1; square(pmXor, c); } break; case TD_RECT : // if (isw == 0) { if (!hasUserLength) { if (Ltype[TD_RECT].sw == 0) { if (step == 1) { Lex = XD; Ley = YD; rectangle(pmXor, c); } } else if (Ltype[TD_RECT].sw == 1) { if (step == 1) { Lex = XD; Ley = YD; Tstitch.l[1].ex = XD; Tstitch.l[1].ey = YD; Tstitch.ex = Tstitch.l[1].ex; Tstitch.ey = Tstitch.l[1].ey; rectangle(pmXor, c); } } /* if (Ltype[TD_RECT].sw == 0) { if (step == 1) { Lex = XD; Ley = YD; rectangle(pmXor, c); } } else if (Ltype[TD_RECT].sw == 1) { if (step == 1) { Tstitch.l[1].ex = XD; Tstitch.l[1].ey = YD; Tstitch.ex = Tstitch.l[1].ex; Tstitch.ey = Tstitch.l[1].ey; DrawDotRectangleLocate(Rect(Tstitch.l[1].sx, Tstitch.l[1].sy, Tstitch.l[1].ex, Tstitch.l[1].ey)); ::RepaintImage(); DrawDotRectangleLocate(Rect(Tstitch.l[1].sx, Tstitch.l[1].sy, Tstitch.l[1].ex, Tstitch.l[1].ey)); } }*/ } else { rec_x = Rec_lx - pw; rec_y = Rec_ly - pw; Csx = XD; Csy = YD; Lsx = Csx - rec_x / 2.0; Lsy = Csy - rec_y / 2.0; if ((Csx >= 0) && (Csx <= rec_x / 2.0)) Lsx = 0; else if ((Csx >= Image->uBitmap->Width - rec_x / 2.0) && (Csx < Image->uBitmap->Width)) Lsx = (Image->uBitmap->Width - 1) - rec_x; if ((Csy >= 0) && (Csy <= rec_y / 2.0)) Lsy = 0; else if ((Csy >= Image->uBitmap->Height - rec_y / 2.0) && (Csy < Image->uBitmap->Height)) Lsy = (Image->uBitmap->Height - 1) - rec_y; Lex = Lsx + rec_x - 1; Ley = Lsy + rec_y - 1; rectangle(pmXor, c); } break; case TD_CIRCLE : // if (isw == 0) { if (!hasUserLength) { if (step == 1) { Lsx = XD; Lsy = YD; circle(pmXor, c); } } else { Tradius = Radius - pw / 2.0; Csx = XD; Csy = YD; Lsx = Csx + Tradius - 1; Lsy = Csy + Tradius - 1; if (Lsx > Image->uBitmap->Width) Lsx = Csx - Tradius; circle(pmXor, c); } break; case TD_ELLIP : // if (isw == 0) { if (!hasUserLength) { if (step == 1) { Lsx = XD; Lsy = YD; ellipse(pmXor, c); } } else { ell_x = Ell_rx - pw / 2.0; ell_y = Ell_ry - pw / 2.0; Csx = XD; Csy = YD; Lsx = Csx + ell_x - 1; Lsy = Csy + ell_y - 1; if (Lsx > Image->uBitmap->Width) Lsx = Csx - ell_x - 1; if (Lsy > Image->uBitmap->Height) Lsy = Csy - ell_y - 1; ellipse(pmXor, c); } break; case TD_CURVE : if (Ltype[TD_CURVE].sw == 0) { if (step == 1) { if (Curve_input == 0) { Lex = XD; Ley = YD; DrawLineLocate(Point(Lsx, Lsy), Point(Lex, Ley)); } else if (Curve_input == 1) { Csx = XD; Csy = YD; DrawLineLocate(Point(Lsx, Lsy), Point(Csx, Csy)); } } else if (step == 2) { if (Curve_input == 0) { Csx = XD; Csy = YD; DrawCurveLocate(Point(Lsx, Lsy), Point(Lex, Ley), Point(Csx, Csy)); } else if (Curve_input == 1) { Lex = XD; Ley = YD; DrawCurveLocate(Point(Lsx, Lsy), Point(Lex, Ley), Point(Csx, Csy)); } } } else if (Ltype[TD_CURVE].sw == 1) { if(eDotLength->Value == 0)return; if (step == 1) { Tstitch.l[1].ex = XD; Tstitch.l[1].ey = YD; Tstitch.ex = Tstitch.l[1].ex; Tstitch.ey = Tstitch.l[1].ey; if (Curve_input == 0) { Lex = XD; Ley = YD; } else if (Curve_input == 1) { Csx = XD; Csy = YD; } DrawDotLineLocate(Point(Tstitch.l[1].sx, Tstitch.l[1].sy), Point(Tstitch.l[1].ex, Tstitch.l[1].ey)); } else if (step == 2) { Tstitch.l[1].ex = XD; Tstitch.l[1].ey = YD; Tstitch.ex = Tstitch.l[1].ex; Tstitch.ey = Tstitch.l[1].ey; if (Curve_input == 0) { Csx = XD; Csy = YD; } else if (Curve_input == 1) { Lex = XD; Ley = YD; } DrawDotCurveLocate(Point(Tstitch.l[1].sx, Tstitch.l[1].sy), Point(Tstitch.l[1].ex, Tstitch.l[1].ey), Point(Csx, Csy)); } } } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::DrawMouseUp(int XD, int YD) { BtnClick = false; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::iMainImageKeyDown(WORD Key, TShiftState Shift) { if (Key == 'X' && Shift.Contains(ssShift) && rzbtFirst->Enabled) { rzbtFirstClick(rzbtFirst); } else if (Key == 'Z' && Shift.Contains(ssShift) && rzbtDelete->Enabled) { rzbtDeleteClick(rzbtDelete); } else if (Key == 'C' && Shift.Contains(ssShift) && Item == TD_CURVE) { if (sbInputMode1->Down) { sbInputMode2->Down = true; sbInputModeClick(sbInputMode2); } else { sbInputMode1->Down = true; sbInputModeClick(sbInputMode1); } } else if (Key == VK_SHIFT && Shift.Contains(ssCtrl)) { mnitmSeparateClick(mnitmSeparate); } else if (Key == VK_MENU && Shift.Contains(ssCtrl)) { lFillTypeClick(rzcbFill); } else if (Key == 'X') { iMainImageChange(); if (Line_type == 1 || Curve_type == 1) { if(Item == TD_LINE)InitPointList(); if(Item == TD_CURVE)InitPointList(); step = 0; undos = 0; xkey = 1; separatel = 0; } } else if ((Key == 'Z') && ((PointList->Count>0) || separatel == 1)){ if (Item == TD_LINE && (Ltype[TD_LINE].sw == 0 || Ltype[TD_LINE].sw == 1 )) { /*isw = 1;*/ Line_angle = 0; Lsw = 0; Asw = 2; isHVLine = true; } } else if (Key == VK_SHIFT/*Shift.Contains(ssShift)*/) { switch (Item) { case TD_RECT: // Á÷»ç°¢Çü if(step ==1) { m_IsChangedItemByShift = true; Item = TD_SQUR; Ltype[TD_SQUR].sw = Ltype[TD_RECT].sw; Ltype[TD_SQUR].value[0] = Ltype[TD_RECT].value[0]; Ltype[TD_SQUR].value[1] = Ltype[TD_RECT].value[1]; view(); //step = 1; MainImageForm->iMainImage->Repaint(); // ÀÜ»ó Á¦°Å - by monkman (2006.09.14) } break; case TD_ELLIP: // Ÿ¿ø if(step ==1) { m_IsChangedItemByShift = true; //if (bPreCenter == false) { Item = TD_CIRCLE; Ltype[TD_CIRCLE].sw = Ltype[TD_ELLIP].sw; Ltype[TD_CIRCLE].value[0] = Ltype[TD_ELLIP].value[0]; Ltype[TD_CIRCLE].value[1] = Ltype[TD_ELLIP].value[1]; view(); //step = 1; MainImageForm->iMainImage->Repaint(); // ÀÜ»ó Á¦°Å - by monkman (2006.09.14) } //} break; } } else if (Key == '1') { FunctionClick(sbLine); sbLine->Down = true; } else if (Key == '2') { FunctionClick(sbCurve); sbCurve->Down = true; } else if (Key == '3') { mnitmRectClick(mnitmRectangle); } else if (Key == '4') { mnitmRectClick(mnitmSquare); } else if (Key == '5') { mnitmCircleClick(mnitmEllipse); } else if (Key == '6') { mnitmCircleClick(mnitmCircle); } else if (Key == '7') { FunctionClick(sbOut); sbOut->Down = true; } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::iMainImageKeyUp(int Key) { if (Key == 'Z') { // 88 : x 90 : z if (Item == TD_LINE && (Ltype[TD_LINE].sw == 0 || Ltype[TD_LINE].sw == 1 )) { /*isw = 0;*/ Lsw = 0; Asw = 0; isHVLine = false; } } if (Key == VK_SHIFT/*Shift.Contains(ssShift)*/) { switch (Item) { case TD_SQUR: // Á÷»ç°¢Çü if (m_IsChangedItemByShift == true) { Item = TD_RECT; view(); MainImageForm->iMainImage->Repaint(); // ÀÜ»ó Á¦°Å - by monkman (2006.09.14) } break; case TD_CIRCLE: // Ÿ¿ø if (m_IsChangedItemByShift == true) { Item = TD_ELLIP; view(); MainImageForm->iMainImage->Repaint(); // ÀÜ»ó Á¦°Å - by monkman (2006.09.14) } break; } m_IsChangedItemByShift = false; } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::iMainImageChange(void) { MainImageForm->iMainImage->Repaint(); } //--------------------------------------------------------------------------- void __fastcall TDrawForm::FGChange(int Value) { PenManagerForm->PenShapeChange(Value); iMainImageChange(); } //--------------------------------------------------------------------------- void __fastcall TDrawForm::InitPointList() { BEGIN_LOG("Draw_F"); TBackupPointData *bpd; while(PointList->Count) { bpd = (TBackupPointData *) PointList->Last(); PointList->Remove(bpd); delete bpd; } rzbtDelete->Enabled = false; rzbtFirst->Enabled = false; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::AddPointList(int x, int y, COLORREF c) { BEGIN_LOG("Draw_F"); double s_rate, e_rate; TBackupPointData *bpd, *bpd1; bpd = new TBackupPointData; bpd->pt.x = x; bpd->pt.y = y; bpd->start_size = StartSize->Value; //lhskys Taper À϶§ bpd->end_size = EndSize->Value; //lhskys Taper À϶§ bpd->spread = PenManagerForm->aspread; //lhskys Taper À϶§ if (Ltype[Item].sw == 1) { bpd->Dotspace = FloatToStr(eDotSpace->Value); //eDotSpace->Text; bpd->Dotlength = FloatToStr(eDotLength->Value); //eDotLength->Text; } if (PenManagerForm->aspread && isTaper) { //lhskys Taper À϶§ bpd->st_rate = s_rate; //lhskys Taper À϶§ bpd->ed_rate = e_rate; //lhskys Taper À϶§ bpd->s_color = PenManagerForm->shFirst->Brush->Color; //lhskys Taper À϶§ bpd->e_color = PenManagerForm->shSecond->Brush->Color; //lhskys Taper À϶§ bpd->grade = PenManagerForm->numedEGrade->Value; //lhskys Taper À϶§ if(sbCurve->Down)bpd->DotSolid = Ltype[TD_CURVE].sw; //2001.5.30 by lhskys else if (sbLine->Down)bpd->DotSolid = Ltype[TD_LINE].sw; } else { bpd->col = c; bpd->pen_size = PenManagerForm->Pen->BasicThick; //lhskys pen_size ¸¦ ¹é¾÷ÇÒ¶§¸¦ À§ÇØ °°ÀÌ ÀúÀå... if (sbCurve->Down) bpd->DotSolid = Ltype[TD_CURVE].sw; //2001.5.30 by lhskys else if (sbLine->Down) bpd->DotSolid = Ltype[TD_LINE].sw; } PointList->Add(bpd); if (Item == TD_CURVE && Curve_input == 1) { if (PointList->Count%2 && PointList->Count>1) PointList->Exchange(PointList->Count-1, PointList->Count-2); } rzbtDelete->Enabled = PointList->Count > 1; rzbtFirst->Enabled = PointList->Count > 1; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::FillPath() { BEGIN_LOG("Draw_F"); int i, w, h, x, y, cnt; bool isFirstX; int StartX,EndX; HDC dc = NULL; HPEN hPen = NULL; HBRUSH hBrush; COLORREF c; POINT *pt; TBackupPointData *bpd; Byte *IP, *MP, *LP, *PP, mm; TTexpiaBitmap *tb; TPItemImage *Image = MainImageForm->iMainImage; w = Image->uBitmap->Width; h = Image->uBitmap->Height; cnt = PointList->Count; pt = (POINT *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY , sizeof(POINT) * cnt); for (i = 0; i < cnt; i++) { bpd = (TBackupPointData *)PointList->Items[i]; pt[i] = bpd->pt; } tb = new TTexpiaBitmap; tb->Create(w, h, 1); dc = tb->CreateDC(); SelectObject(dc, GetStockObject(WHITE_BRUSH)); hPen = CreatePen(PS_SOLID, 1, clWhite); SelectObject(dc, hPen); SetPolyFillMode(dc, WINDING); Polygon(dc, pt, cnt); DeleteObject(hPen); tb->DeleteDC(dc); dc = NULL; HeapFree(GetProcessHeap(), 0, pt); /* Gdiplus::Point *pPoints; Gdiplus::Graphics graphics(dc); pPoints = new Gdiplus::Point[cnt]; Gdiplus::Color penColor(GetRValue(clWhite), GetGValue(clWhite), GetBValue(clWhite)); Gdiplus::Color FillColor(GetRValue(clWhite), GetGValue(clWhite), GetBValue(clWhite)); Gdiplus::Pen ObjectPen(penColor, 1); Gdiplus::SolidBrush ObjectBrush(FillColor); Gdiplus::GraphicsPath gFillPath; if (Item == TD_LINE) { for (i = 0; i < cnt; i++) { bpd = (TBackupPointData *)PointList->Items[i]; pPoints[i].X = bpd->pt.x; pPoints[i].Y = bpd->pt.y; } gFillPath.AddPolygon(pPoints, cnt); gFillPath.SetFillMode(Gdiplus::FillModeWinding); graphics.FillPath(&ObjectBrush, &gFillPath); graphics.DrawPath(&ObjectPen,&gFillPath); } else if (Item == TD_CURVE) { // added by maxleo21c (05.3.09) // gFillPath.AddBeziers(pPoints, cnt); int temp; for (i = 0; i < cnt/3; i++) { for (int j=0; j<3; j++) { temp = 3*i+j; if (temp >= cnt) break; bpd = (TBackupPointData *)PointList->Items[temp]; pPoints[j].X = bpd->pt.x; pPoints[j].Y = bpd->pt.y; } graphics.DrawClosedCurve(&ObjectPen, pPoints, 3); graphics.FillClosedCurve(&ObjectBrush, pPoints, 3, Gdiplus::FillModeWinding); } } delete[] pPoints; tb->DeleteDC(dc); dc = NULL; */ tb->StartScanLine(); if (PenManagerForm->Type == PT_MASK) { Image->Mask->StartScanLine(); if (Image->uBitmap->BitsPerPixel == 8) { for (y = 0; y < h; y++) { MP = Image->Mask->GetScanLine(y); PP = tb->GetScanLine(y); mm = 0x80; isFirstX=true; StartX=EndX=0; for (x = 0; x < w; x++, MP++) { if (*PP & mm) { *MP = MainImageForm->MaskPixel; EndX=x; if (isFirstX) { StartX=x; isFirstX=false; } } if (mm == 1) { PP++; mm = 0x80; } else mm >>= 1; } if(!isFirstX)Image->Mask->PutScanLine(y,StartX,EndX-StartX+1); //caution!!! } } else { if (PenManagerForm->rzckDelete->Checked) { for (y = 0; y < h; y++) { MP = Image->Mask->GetScanLine(y); PP = tb->GetScanLine(y); mm = 0x80; isFirstX=true; StartX=EndX=0; for (x = 0; x < w; x++) { if (*PP & mm) { *MP &= ~mm; EndX=x; if (isFirstX) { StartX=x; isFirstX=false; } } if (mm == 1) { MP++; PP++; mm = 0x80; } else mm >>= 1; } if(!isFirstX)Image->Mask->PutScanLine(y,StartX,EndX-StartX+1); } } else { for (y = 0; y < h; y++) { MP = Image->Mask->GetScanLine(y); PP = tb->GetScanLine(y); mm = 0x80; isFirstX=true; StartX=EndX=0; for (x = 0; x < w; x++) { if (*PP & mm) { *MP |= mm; EndX=x; if (isFirstX) { StartX=x; isFirstX=false; } } if (mm == 1) { MP++; PP++; mm = 0x80; } else mm >>= 1; } if(!isFirstX)Image->Mask->PutScanLine(y,StartX,EndX-StartX+1); } } } Image->Mask->StopScanLine(); } else { if (Image->LayerMask) { Image->uBitmap->StartScanLine(); Image->LayerMask->StartScanLine(); if (Image->uBitmap->BitsPerPixel == 8) { c = PaletteForm->DIB256Palette->GetFGCOLORREF(8); if (MainImageForm->MaskArea) { Image->Mask->StartScanLine(); if (MainImageForm->Protect) { for (y = 0; y < h; y++) { IP = Image->uBitmap->GetScanLine(y); LP = Image->LayerMask->GetScanLine(y); MP = Image->Mask->GetScanLine(y); PP = tb->GetScanLine(y); mm = 0x80; isFirstX=true; StartX=EndX=0; for (x = 0; x < w; x++, IP++, LP++, MP++) { if (*PP & mm) { if (*MP == 0 && MainImageForm->Palette->ColorData[*IP]->Protect == 0) { *IP = c; *LP = 0; EndX=x; if (isFirstX) { StartX=x; isFirstX=false; } } } if (mm == 1) { PP++; mm = 0x80; } else mm >>= 1; } if(!isFirstX)Image->LayerMask->PutScanLine(y,StartX,EndX-StartX+1); if(!isFirstX)Image->uBitmap->PutScanLine(y,StartX,EndX-StartX+1); } } else { for (y = 0; y < h; y++) { IP = Image->uBitmap->GetScanLine(y); LP = Image->LayerMask->GetScanLine(y); MP = Image->Mask->GetScanLine(y); PP = tb->GetScanLine(y); mm = 0x80; isFirstX=true; StartX=EndX=0; for (x = 0; x < w; x++, IP++, LP++, MP++) { if (*PP & mm) { if (*MP == 0) { *IP = c; *LP = 0; EndX=x; if (isFirstX) { StartX=x; isFirstX=false; } } } if (mm == 1) { PP++; mm = 0x80; } else mm >>= 1; } if(!isFirstX)Image->LayerMask->PutScanLine(y,StartX,EndX-StartX+1); if(!isFirstX)Image->uBitmap->PutScanLine(y,StartX,EndX-StartX+1); } } Image->Mask->StopScanLine(); } else { if (MainImageForm->Protect) { for (y = 0; y < h; y++) { IP = Image->uBitmap->GetScanLine(y); LP = Image->LayerMask->GetScanLine(y); PP = tb->GetScanLine(y); mm = 0x80; isFirstX=true; StartX=EndX=0; for (x = 0; x < w; x++, IP++, LP++) { if (*PP & mm) { if (MainImageForm->Palette->ColorData[*IP]->Protect == 0) { *IP = c; *LP = 0; EndX=x; if (isFirstX) { StartX=x; isFirstX=false; } } } if (mm == 1) { PP++; mm = 0x80; } else mm >>= 1; } if(!isFirstX)Image->LayerMask->PutScanLine(y,StartX,EndX-StartX+1); if(!isFirstX)Image->uBitmap->PutScanLine(y,StartX,EndX-StartX+1); } } else { for (y = 0; y < h; y++) { IP = Image->uBitmap->GetScanLine(y); LP = Image->LayerMask->GetScanLine(y); PP = tb->GetScanLine(y); mm = 0x80; isFirstX=true; StartX=EndX=0; for (x = 0; x < w; x++, IP++, LP++) { if (*PP & mm) { *IP = c; *LP = 0; EndX=x; if (isFirstX) { StartX=x; isFirstX=false; } } if (mm == 1) { PP++; mm = 0x80; } else mm >>= 1; } if(!isFirstX)Image->LayerMask->PutScanLine(y,StartX,EndX-StartX+1); if(!isFirstX)Image->uBitmap->PutScanLine(y,StartX,EndX-StartX+1); } } } } else { c = PaletteForm->DIB256Palette->GetFGCOLORREF(24); if (MainImageForm->MaskArea) { Image->Mask->StartScanLine(); for (y = 0; y < h; y++) { IP = Image->uBitmap->GetScanLine(y); LP = Image->LayerMask->GetScanLine(y); MP = Image->Mask->GetScanLine(y); PP = tb->GetScanLine(y); mm = 0x80; isFirstX=true; StartX=EndX=0; for (x = 0; x < w; x++, IP+=3) { if (*PP & mm) { if ((*MP & mm) == 0) { SetPixel24(IP, c); *LP &= ~mm; EndX=x; if (isFirstX) { StartX=x; isFirstX=false; } } } if (mm == 1) { MP++; LP++; PP++; mm = 0x80; } else mm >>= 1; } if(!isFirstX)Image->LayerMask->PutScanLine(y,StartX,EndX-StartX+1); if(!isFirstX)Image->uBitmap->PutScanLine(y,StartX,EndX-StartX+1); } Image->Mask->StopScanLine(); } else { for (y = 0; y < h; y++) { IP = Image->uBitmap->GetScanLine(y); LP = Image->LayerMask->GetScanLine(y); PP = tb->GetScanLine(y); mm = 0x80; isFirstX=true; StartX=EndX=0; for (x = 0; x < w; x++, IP+=3) { if (*PP & mm) { SetPixel24(IP, c); *LP &= ~mm; EndX=x; if (isFirstX) { StartX=x; isFirstX=false; } } if (mm == 1) { LP++; PP++; mm = 0x80; } else mm >>= 1; } if(!isFirstX)Image->LayerMask->PutScanLine(y,StartX,EndX-StartX+1); if(!isFirstX)Image->uBitmap->PutScanLine(y,StartX,EndX-StartX+1); } } } Image->uBitmap->StopScanLine(); Image->LayerMask->StopScanLine(); } else { Image->uBitmap->StartScanLine(); if (Image->uBitmap->BitsPerPixel == 8) { c = PaletteForm->DIB256Palette->GetFGCOLORREF(8); if (MainImageForm->MaskArea) { Image->Mask->StartScanLine(); if (MainImageForm->Protect) { for (y = 0; y < h; y++) { IP = Image->uBitmap->GetScanLine(y); MP = Image->Mask->GetScanLine(y); PP = tb->GetScanLine(y); mm = 0x80; isFirstX=true; StartX=EndX=0; for (x = 0; x < w; x++, IP++, MP++) { if (*PP & mm) { if (*MP == 0 && MainImageForm->Palette->ColorData[*IP]->Protect == 0) { *IP = c; EndX=x; if (isFirstX) { StartX=x; isFirstX=false; } } } if (mm == 1) { PP++; mm = 0x80; } else mm >>= 1; } if(!isFirstX)Image->uBitmap->PutScanLine(y,StartX,EndX-StartX+1); } } else { for (y = 0; y < h; y++) { IP = Image->uBitmap->GetScanLine(y); MP = Image->Mask->GetScanLine(y); PP = tb->GetScanLine(y); mm = 0x80; isFirstX=true; StartX=EndX=0; for (x = 0; x < w; x++, IP++,MP++) { if (*PP & mm) { if (*MP == 0) { *IP = c; EndX=x; if (isFirstX) { StartX=x; isFirstX=false; } } } if (mm == 1) { PP++; mm = 0x80; } else mm >>= 1; } if(!isFirstX)Image->uBitmap->PutScanLine(y,StartX,EndX-StartX+1); } } Image->Mask->StopScanLine(); } else { if (MainImageForm->Protect) { for (y = 0; y < h; y++) { IP = Image->uBitmap->GetScanLine(y); PP = tb->GetScanLine(y); mm = 0x80; isFirstX=true; StartX=EndX=0; for (x = 0; x < w; x++, IP++) { if (*PP & mm) { if (MainImageForm->Palette->ColorData[*IP]->Protect == 0) { *IP = c; EndX=x; if (isFirstX) { StartX=x; isFirstX=false; } } } if (mm == 1) { PP++; mm = 0x80; } else mm >>= 1; } if(!isFirstX)Image->uBitmap->PutScanLine(y,StartX,EndX-StartX+1); } } else { for (y = 0; y < h; y++) { IP = Image->uBitmap->GetScanLine(y); PP = tb->GetScanLine(y); mm = 0x80; isFirstX=true; StartX=EndX=0; for (x = 0; x < w; x++, IP++) { if (*PP & mm) { *IP = c; EndX=x; if (isFirstX) { StartX=x; isFirstX=false; } } if (mm == 1) { PP++; mm = 0x80; } else mm >>= 1; } if(!isFirstX)Image->uBitmap->PutScanLine(y,StartX,EndX-StartX+1); } } } } else { c = PaletteForm->DIB256Palette->GetFGCOLORREF(24); if (MainImageForm->MaskArea) { Image->Mask->StartScanLine(); for (y = 0; y < h; y++) { IP = Image->uBitmap->GetScanLine(y); MP = Image->Mask->GetScanLine(y); PP = tb->GetScanLine(y); mm = 0x80; isFirstX=true; StartX=EndX=0; for (x = 0; x < w; x++, IP+=3) { if (*PP & mm) { if ((*MP & mm) == 0) { SetPixel24(IP, c); EndX=x; if (isFirstX) { StartX=x; isFirstX=false; } } } if (mm == 1) { MP++; PP++; mm = 0x80; } else mm >>= 1; } if(!isFirstX)Image->uBitmap->PutScanLine(y,StartX,EndX-StartX+1); } Image->Mask->StopScanLine(); } else { for (y = 0; y < h; y++) { IP = Image->uBitmap->GetScanLine(y); PP = tb->GetScanLine(y); mm = 0x80; isFirstX=true; StartX=EndX=0; for (x = 0; x < w; x++, IP+=3) { if (*PP & mm) { SetPixel24(IP, c); EndX=x; if (isFirstX) { StartX=x; isFirstX=false; } } if (mm == 1) { PP++; mm = 0x80; } else mm >>= 1; } if(!isFirstX)Image->uBitmap->PutScanLine(y,StartX,EndX-StartX+1); } } } Image->uBitmap->StopScanLine(); } } tb->StopScanLine(); delete tb; END_LOG; //by jeegeo ::RepaintImage(); } //--------------------------------------------------------------------------- void __fastcall TDrawForm::Reflection_FillPath() { BEGIN_LOG("Draw_F"); int i, w, h, x, y, cnt; bool isFirstX; int StartX,EndX; HDC dc = NULL; HPEN hPen = NULL; HBRUSH hBrush; COLORREF c; POINT *pt; TBackupPointData *bpd; Byte *IP, *MP, *LP, *PP, mm; TTexpiaBitmap *tb; TPItemImage *Image = MainImageForm->iMainImage; if (!Image->Reflection || MainImageForm->reflection == NULL) return; int posx = MainImageForm->reflection->BitmapRange.left; int posy = MainImageForm->reflection->BitmapRange.top; w = MainImageForm->reflection->BitmapRange.right - MainImageForm->reflection->BitmapRange.left; h = MainImageForm->reflection->BitmapRange.bottom - MainImageForm->reflection->BitmapRange.top; //w = Image->uBitmap->Width; h = Image->uBitmap->Height; cnt = PointList->Count; pt = (POINT *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY , sizeof(POINT) * cnt); int wx = 0, hy = 0; if (MainImageForm->reflection->WorkSide == D_RIGHT){ wx = MainImageForm->reflection->BitmapWidth; } else if (MainImageForm->reflection->WorkSide == D_BOTTOM){ hy = MainImageForm->reflection->BitmapHeight; } for (i = 0; i < cnt; i++) { bpd = (TBackupPointData *)PointList->Items[i]; pt[i].x = bpd->pt.x - wx; pt[i].y = bpd->pt.y - hy; } tb = new TTexpiaBitmap; tb->Create(w, h, 1); dc = tb->CreateDC(); SelectObject(dc, GetStockObject(WHITE_BRUSH)); hPen = CreatePen(PS_SOLID, 1, clWhite); SelectObject(dc, hPen); SetPolyFillMode(dc, WINDING); Polygon(dc, pt, cnt); DeleteObject(hPen); tb->DeleteDC(dc); dc = NULL; HeapFree(GetProcessHeap(), 0, pt); tb->StartScanLine(); if (PenManagerForm->Type == PT_MASK) { Image->Mask->StartScanLine(); if (Image->uBitmap->BitsPerPixel == 8) { for (y = posy; y < h + posy; y++) { MP = Image->Mask->GetScanLine(y) + posx; PP = tb->GetScanLine(y-posy); mm = 0x80; isFirstX=true; StartX=EndX=posx; for (x = posx; x < w + posx; x++, MP++) { if (*PP & mm) { *MP = MainImageForm->MaskPixel; EndX=x; if (isFirstX) { StartX=x; isFirstX=false; } } if (mm == 1) { PP++; mm = 0x80; } else mm >>= 1; } if(!isFirstX)Image->Mask->PutScanLine(y,StartX,EndX-StartX+1); //caution!!! } } else { if (PenManagerForm->rzckDelete->Checked) { for (y = posy; y < h + posy; y++) { MP = Image->Mask->GetScanLine(y) + posx*3; PP = tb->GetScanLine(y-posy); mm = 0x80; isFirstX=true; StartX=EndX=posx; for (x = posx; x < w + posx; x++) { if (*PP & mm) { *MP &= ~mm; EndX=x; if (isFirstX) { StartX=x; isFirstX=false; } } if (mm == 1) { MP++; PP++; mm = 0x80; } else mm >>= 1; } if(!isFirstX)Image->Mask->PutScanLine(y,StartX,EndX-StartX+1); } } else { for (y = posy; y < h + posy; y++) { MP = Image->Mask->GetScanLine(y) + posx*3; PP = tb->GetScanLine(y-posy); mm = 0x80; isFirstX=true; StartX=EndX=posx; for (x = posx; x < w + posx; x++) { if (*PP & mm) { *MP |= mm; EndX=x; if (isFirstX) { StartX=x; isFirstX=false; } } if (mm == 1) { MP++; PP++; mm = 0x80; } else mm >>= 1; } if(!isFirstX)Image->Mask->PutScanLine(y,StartX,EndX-StartX+1); } } } Image->Mask->StopScanLine(); } else { if (Image->LayerMask) { Image->uBitmap->StartScanLine(); Image->LayerMask->StartScanLine(); if (Image->uBitmap->BitsPerPixel == 8) { c = PaletteForm->DIB256Palette->GetFGCOLORREF(8); if (MainImageForm->MaskArea) { Image->Mask->StartScanLine(); if (MainImageForm->Protect) { for (y = posy; y < h + posy; y++) { IP = Image->uBitmap->GetScanLine(y) + posx; LP = Image->LayerMask->GetScanLine(y) + posx; MP = Image->Mask->GetScanLine(y) + posx; PP = tb->GetScanLine(y-posy); mm = 0x80; isFirstX=true; StartX=EndX=posx; for (x = posx; x < w + posx; x++, IP++, LP++, MP++) { if (*PP & mm) { if (*MP == 0 && MainImageForm->Palette->ColorData[*IP]->Protect == 0) { *IP = c; *LP = 0; EndX=x; if (isFirstX) { StartX=x; isFirstX=false; } } } if (mm == 1) { PP++; mm = 0x80; } else mm >>= 1; } if(!isFirstX)Image->LayerMask->PutScanLine(y,StartX,EndX-StartX+1); if(!isFirstX)Image->uBitmap->PutScanLine(y,StartX,EndX-StartX+1); } } else { for (y = posy; y < h + posy; y++) { IP = Image->uBitmap->GetScanLine(y) + posx; LP = Image->LayerMask->GetScanLine(y) + posx; MP = Image->Mask->GetScanLine(y) + posx; PP = tb->GetScanLine(y-posy); mm = 0x80; isFirstX=true; StartX=EndX=posx; for (x = posx; x < w + posx; x++, IP++, LP++, MP++) { if (*PP & mm) { if (*MP == 0) { *IP = c; *LP = 0; EndX=x; if (isFirstX) { StartX=x; isFirstX=false; } } } if (mm == 1) { PP++; mm = 0x80; } else mm >>= 1; } if(!isFirstX)Image->LayerMask->PutScanLine(y,StartX,EndX-StartX+1); if(!isFirstX)Image->uBitmap->PutScanLine(y,StartX,EndX-StartX+1); } } Image->Mask->StopScanLine(); } else { if (MainImageForm->Protect) { for (y = posy; y < h + posy; y++) { IP = Image->uBitmap->GetScanLine(y) + posx; LP = Image->LayerMask->GetScanLine(y) + posx; PP = tb->GetScanLine(y-posy); mm = 0x80; isFirstX=true; StartX=EndX=posx; for (x = posx; x < w + posx; x++, IP++, LP++) { if (*PP & mm) { if (MainImageForm->Palette->ColorData[*IP]->Protect == 0) { *IP = c; *LP = 0; EndX=x; if (isFirstX) { StartX=x; isFirstX=false; } } } if (mm == 1) { PP++; mm = 0x80; } else mm >>= 1; } if(!isFirstX)Image->LayerMask->PutScanLine(y,StartX,EndX-StartX+1); if(!isFirstX)Image->uBitmap->PutScanLine(y,StartX,EndX-StartX+1); } } else { for (y = posy; y < h + posy; y++) { IP = Image->uBitmap->GetScanLine(y) + posx; LP = Image->LayerMask->GetScanLine(y) + posx; PP = tb->GetScanLine(y-posy); mm = 0x80; isFirstX=true; StartX=EndX=posx; for (x = posx; x < w + posx; x++, IP++, LP++) { if (*PP & mm) { *IP = c; *LP = 0; EndX=x; if (isFirstX) { StartX=x; isFirstX=false; } } if (mm == 1) { PP++; mm = 0x80; } else mm >>= 1; } if(!isFirstX)Image->LayerMask->PutScanLine(y,StartX,EndX-StartX+1); if(!isFirstX)Image->uBitmap->PutScanLine(y,StartX,EndX-StartX+1); } } } } else { c = PaletteForm->DIB256Palette->GetFGCOLORREF(24); if (MainImageForm->MaskArea) { Image->Mask->StartScanLine(); for (y = posy; y < h + posy; y++) { IP = Image->uBitmap->GetScanLine(y) + posx*3; LP = Image->LayerMask->GetScanLine(y) + posx*3; MP = Image->Mask->GetScanLine(y) + posx*3; PP = tb->GetScanLine(y-posy); mm = 0x80; isFirstX=true; StartX=EndX=posx; for (x = posx; x < w + posx; x++, IP+=3) { if (*PP & mm) { if ((*MP & mm) == 0) { SetPixel24(IP, c); *LP &= ~mm; EndX=x; if (isFirstX) { StartX=x; isFirstX=false; } } } if (mm == 1) { MP++; LP++; PP++; mm = 0x80; } else mm >>= 1; } if(!isFirstX)Image->LayerMask->PutScanLine(y,StartX,EndX-StartX+1); if(!isFirstX)Image->uBitmap->PutScanLine(y,StartX,EndX-StartX+1); } Image->Mask->StopScanLine(); } else { for (y = posy; y < h + posy; y++) { IP = Image->uBitmap->GetScanLine(y) + posx*3; LP = Image->LayerMask->GetScanLine(y) + posx*3; PP = tb->GetScanLine(y-posy); mm = 0x80; isFirstX=true; StartX=EndX=posx; for (x = posx; x < w + posx; x++, IP+=3) { if (*PP & mm) { SetPixel24(IP, c); *LP &= ~mm; EndX=x; if (isFirstX) { StartX=x; isFirstX=false; } } if (mm == 1) { LP++; PP++; mm = 0x80; } else mm >>= 1; } if(!isFirstX)Image->LayerMask->PutScanLine(y,StartX,EndX-StartX+1); if(!isFirstX)Image->uBitmap->PutScanLine(y,StartX,EndX-StartX+1); } } } Image->uBitmap->StopScanLine(); Image->LayerMask->StopScanLine(); } else { Image->uBitmap->StartScanLine(); if (Image->uBitmap->BitsPerPixel == 8) { c = PaletteForm->DIB256Palette->GetFGCOLORREF(8); if (MainImageForm->MaskArea) { Image->Mask->StartScanLine(); if (MainImageForm->Protect) { for (y = posy; y < h + posy; y++) { IP = Image->uBitmap->GetScanLine(y) + posx; MP = Image->Mask->GetScanLine(y) + posx; PP = tb->GetScanLine(y-posy); mm = 0x80; isFirstX=true; StartX=EndX=posx; for (x = posx; x < w + posx; x++, IP++, MP++) { if (*PP & mm) { if (*MP == 0 && MainImageForm->Palette->ColorData[*IP]->Protect == 0) { *IP = c; EndX=x; if (isFirstX) { StartX=x; isFirstX=false; } } } if (mm == 1) { PP++; mm = 0x80; } else mm >>= 1; } if(!isFirstX)Image->uBitmap->PutScanLine(y,StartX,EndX-StartX+1); } } else { for (y = posy; y < h + posy; y++) { IP = Image->uBitmap->GetScanLine(y) + posx; MP = Image->Mask->GetScanLine(y) + posx; PP = tb->GetScanLine(y-posy); mm = 0x80; isFirstX=true; StartX=EndX=posx; for (x = posx; x < w + posx; x++, IP++,MP++) { if (*PP & mm) { if (*MP == 0) { *IP = c; EndX=x; if (isFirstX) { StartX=x; isFirstX=false; } } } if (mm == 1) { PP++; mm = 0x80; } else mm >>= 1; } if(!isFirstX)Image->uBitmap->PutScanLine(y,StartX,EndX-StartX+1); } } Image->Mask->StopScanLine(); } else { if (MainImageForm->Protect) { for (y = posy; y < h + posy; y++) { IP = Image->uBitmap->GetScanLine(y) + posx; PP = tb->GetScanLine(y-posy); mm = 0x80; isFirstX=true; StartX=EndX=posx; for (x = posx; x < w + posx; x++, IP++) { if (*PP & mm) { if (MainImageForm->Palette->ColorData[*IP]->Protect == 0) { *IP = c; EndX=x; if (isFirstX) { StartX=x; isFirstX=false; } } } if (mm == 1) { PP++; mm = 0x80; } else mm >>= 1; } if(!isFirstX)Image->uBitmap->PutScanLine(y,StartX,EndX-StartX+1); } } else { for (y = posy; y < h + posy; y++) { IP = Image->uBitmap->GetScanLine(y) + posx; PP = tb->GetScanLine(y-posy); mm = 0x80; isFirstX=true; StartX=EndX=posx; for (x = posx; x < w + posx; x++, IP++) { if (*PP & mm) { *IP = c; EndX=x; if (isFirstX) { StartX=x; isFirstX=false; } } if (mm == 1) { PP++; mm = 0x80; } else mm >>= 1; } if(!isFirstX)Image->uBitmap->PutScanLine(y,StartX,EndX-StartX+1); } } } } else { c = PaletteForm->DIB256Palette->GetFGCOLORREF(24); if (MainImageForm->MaskArea) { Image->Mask->StartScanLine(); for (y = posy; y < h + posy; y++) { IP = Image->uBitmap->GetScanLine(y) + posx*3; MP = Image->Mask->GetScanLine(y) + posx*3; PP = tb->GetScanLine(y-posy); mm = 0x80; isFirstX=true; StartX=EndX=posx; for (x = posx; x < w + posx; x++, IP+=3) { if (*PP & mm) { if ((*MP & mm) == 0) { SetPixel24(IP, c); EndX=x; if (isFirstX) { StartX=x; isFirstX=false; } } } if (mm == 1) { MP++; PP++; mm = 0x80; } else mm >>= 1; } if(!isFirstX)Image->uBitmap->PutScanLine(y,StartX,EndX-StartX+1); } Image->Mask->StopScanLine(); } else { for (y = posy; y < h + posy; y++) { IP = Image->uBitmap->GetScanLine(y) + posx*3; PP = tb->GetScanLine(y-posy); mm = 0x80; isFirstX=true; StartX=EndX=posx; for (x = posx; x < w + posx; x++, IP+=3) { if (*PP & mm) { SetPixel24(IP, c); EndX=x; if (isFirstX) { StartX=x; isFirstX=false; } } if (mm == 1) { PP++; mm = 0x80; } else mm >>= 1; } if(!isFirstX)Image->uBitmap->PutScanLine(y,StartX,EndX-StartX+1); } } } Image->uBitmap->StopScanLine(); } } tb->StopScanLine(); delete tb; END_LOG; //by jeegeo ::RepaintImage(); } //--------------------------------------------------------------------------- void __fastcall TDrawForm::FillRectangle(int sx, int sy, int ex, int ey, COLORREF fc) { TPItemImage *Image = MainImageForm->iMainImage; TPException ec = EC_NONE; int pt, sr, lr; pt = PenManagerForm->Pen->Thick; sr = pt >> 1; lr = pt - sr; int ssx = sx, ssy = sy, eex = ex, eey = ey; if (Image->Reflection && MainImageForm->reflection){ RECT range; MainImageForm->reflection->ChangeAvailableOriginalRange(Rect(sx, sy, ex, ey), range); ssx = range.left; ssy = range.top; eex = range.right; eey = range.bottom; if (ssx == MainImageForm->reflection->BitmapRange.left) ssx -= pt; if (ssy == MainImageForm->reflection->BitmapRange.top) ssy -= pt; if (eex == MainImageForm->reflection->BitmapRange.right) eex += pt; if (eey == MainImageForm->reflection->BitmapRange.bottom) eey += pt; } if (PenManagerForm->sbMask->Down) { if (!(Image->Mask->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if (!(Image->uBitmap->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Image->LayerMask) { if (!(Image->LayerMask->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } if (MainImageForm->MaskArea) { if (!(Image->Mask->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } } for (int i = ssy + lr; i < eey - sr; i++) { MainImageForm->set_hline(ssx + lr, i, eex - ssx - pt, fc); } if (PenManagerForm->sbMask->Down) { Image->Mask->StopScanLine(); } else { if (MainImageForm->MaskArea) Image->Mask->StopScanLine(); if (Image->LayerMask) Image->LayerMask->StopScanLine(); Image->uBitmap->StopScanLine(); } return; fail: if (Image->Mask) Image->Mask->StopScanLine(); if (Image->LayerMask) Image->LayerMask->StopScanLine(); Image->uBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); } //--------------------------------------------------------------------------- void __fastcall TDrawForm::TaperLabelClick(TObject *Sender) { BEGIN_LOG("Draw_F"); if (rzcbPressure->Checked) { isTaper = true; // Ltype[Item].sw = 0; //lDotType->Enabled = false; //taper »ç¿ë½Ã ½Ç¼±¸¸»ç¿ë Ltype[TD_LINE].sw = 0; Ltype[TD_CURVE].sw = 0; rzcbDot->Enabled = false; fill_not = 0; //lFillType->Enabled = false; //taper »ç¿ë½Ã ä¿ì±â ±ÝÁö rzcbFill->Enabled = false; imgFill->Enabled = false; //===========================================¼±²÷±â iMainImageChange(); InitPointList(); step = 0; undos = 0; //=========================================== } else { isTaper = false; // lDotType->Enabled = true; //taper »ç¿ë½Ã ½Ç¼±¸¸»ç¿ë ÇØÁ¦ rzcbDot->Enabled = true; // lFillType->Enabled = true; //taper »ç¿ë½Ã ä¿ì±â ±ÝÁö ÇØÁ¦ rzcbFill->Enabled = true; imgFill->Enabled = true; //===========================================¼±²÷±â iMainImageChange(); InitPointList(); step = 0; undos = 0; } view(); step = 0; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::StartSize_Click(TObject *Sender) //lhskys taper ¼ýÀڹٲٱâ { StartSize->SelectAll(); StartSize->SetFocus(); } //--------------------------------------------------------------------------- void __fastcall TDrawForm::EndSize_Click(TObject *Sender) //lhskys taper ¼ýÀڹٲٱâ { EndSize->SelectAll(); EndSize->SetFocus(); } //--------------------------------------------------------------------------- void __fastcall TDrawForm::StartSize_Change(TObject *Sender) //lhskys taper ¼ýÀڹٲٱâ { if (StartSize->Text.Length() > 0) { if (StartSize->Value > 50) StartSize->Value = 50; if (StartSize->Value < 1) StartSize->Value = 1; PenManagerForm->rzsePenSize->Value = StartSize->Value; } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::EndSize_Change(TObject *Sender) //lhskys taper ¼ýÀڹٲٱâ { if (EndSize->Text.Length()>0) { if (EndSize->Value > 50) EndSize->Value = 50; if (EndSize->Value < 1) EndSize->Value = 1; // PenManagerForm->rzsePenSize->Value = EndSize->Value; } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::LengthAngle() { double p; int lx, ly, dx, dy; if (Ltype[TD_LINE].sw == 0) { dx = Lex - Lsx; dy = Ley - Lsy; }else if (Ltype[TD_LINE].sw == 1) { dx = Tstitch.l[1].ex - Tstitch.l[1].sx; dy = Tstitch.l[1].ey - Tstitch.l[1].sy; } if (dy < 0) { p = (atan2((double)dy, (double)dx) + 2 * M_PI) * 180.0 / M_PI; } else { if ((dx == 0) && (dy == 0)) p = 0; else p = atan2((double)dy, (double)dx) * 180.0 / M_PI; } eAngle->Value = p; //Format("%3.1f", OPENARRAY(TVarRec, (p))); lx = abs(dx); ly = abs(dy); p = sqrt(lx * lx + ly * ly) + PenManagerForm->Pen->BasicThick; switch (MainImageForm->CurrentUnit) { case uDot : eLength1->Value = p; break; case uInch: eLength1->Value = p / MainImageForm->CanvasInfor.DotsPerInch; break; //Format("%.2f", OPENARRAY(TVarRec, (p / MainImageForm->CanvasInfor.DotsPerInch))); break; case uCm : eLength1->Value = p / MainImageForm->CanvasInfor.DotsPerInch * 2.54; break; //Format("%.2f", OPENARRAY(TVarRec, (p / MainImageForm->CanvasInfor.DotsPerInch * 2.54))); } /* dx = Tstitch.l[1].ex - Tstitch.l[1].sx; dy = Tstitch.l[1].ey - Tstitch.l[1].sy; if (dy < 0) { p = (atan2(dy, dx) + 2 * M_PI) * 180.0 / M_PI; } else { if ((dx == 0) && (dy == 0)) p = 0; else p = (atan2(dy, dx)) * 180.0 / M_PI; } eAngle->Text = Format("%3.1f", OPENARRAY(TVarRec, (p))); lx = abs(dx) + 1; ly = abs(dy) + 1; p = sqrt(lx * lx + ly * ly) + PenManagerForm->Pen->Thick; switch (MainImageForm->CurrentUnit) { case uDot : eLength1->Text = p; break; case uInch: eLength1->Text = Format("%.2f", OPENARRAY(TVarRec, (p / MainImageForm->CanvasInfor.DotsPerInch))); break; case uCm : eLength1->Text = Format("%.2f", OPENARRAY(TVarRec, (p / MainImageForm->CanvasInfor.DotsPerInch * 2.54))); }*/ } //--------------------------------------------------------------------------- void __fastcall TDrawForm::editChange(TObject *Sender) { BEGIN_LOG("Draw_F"); TNumEdit *s; if(swLength || swAngle){ iMainImageChange(); s = (TNumEdit *)Sender; try{ if (s == eLength2) { if (Item != TD_LINE) { Lsx = -1; Lex = -1; Lsy = -1; Ley = -1; Csx = -1; Csy = -1; } // isw = 1; hasUserLength = true; isNumberInput = false; // by celberus Lsw = 1; InputNumber(); } else if (s == eDotLength) { Dsw = 1; InputDotNumber(); } else if (s == eDotSpace) { Dsw = 2; InputDotNumber(); } }catch(EConvertError &ec){ } } swLength = false; swAngle = false; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::eLength1_Change(TObject *Sender) { BEGIN_LOG("Draw_F"); TNumEdit *s; double dtemp,itemp; if(swLength || swAngle){ iMainImageChange(); s = (TNumEdit *)Sender; try{ if (s == eLength1) { if (Item != TD_LINE) { Lsx = -1; Lex = -1; Lsy = -1; Ley = -1; Csx = -1; Csy = -1; } // isw = 1; hasUserLength = true; isNumberInput = false; // by celberus Lsw = 1; //if(eLength1->Value == 0) eLength1->Value = 1; InputNumber(); } else if (s == eAngle) { // isw = 1; hasUserLength = true; isNumberInput = false; // by celberus Asw = 1; //if(eAngle->Value == 0) eAngle->Value = 1; InputNumber(); } }catch(EConvertError &ec){ } } swLength = false; swAngle = false; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::sbInputModeClick(TObject *Sender) { BEGIN_LOG("Draw_F"); TRzBitBtn *SBtn = NULL; TBackupPointData *bpd; if ((SBtn = dynamic_cast(Sender)) != NULL) { Curve_input = SBtn->Tag; if (step==2) { if (Curve_type && PointList->Count>1) { bpd = (TBackupPointData *)PointList->Last(); PointList->Remove(bpd); delete bpd; } step = 1; } } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::Line1Click(TObject *Sender) { TRzMenuToolbarButton *sp = (TRzMenuToolbarButton *)Sender; switch(sp->Tag){ case 1 : FunctionClick(sbLine); break; case 2 : FunctionClick(sbCurve); break; case 3 : mnitmRectClick(mnitmRectangle); break; case 4 : mnitmRectClick(mnitmSquare); break; case 5 : mnitmCircleClick(mnitmEllipse); break; case 6 : mnitmCircleClick(mnitmCircle); break; case 7 : FunctionClick(sbOut); break; } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::MakeMenuHintByShortcut() { BEGIN_LOG(""); sbLine->Hint = TexActionManager->GetHint("Draw", "Line"); sbCurve->Hint = TexActionManager->GetHint("Draw", "Curve"); sbRect->Hint = TexActionManager->GetHint("Draw", "Rectangle"); sbEllip->Hint = TexActionManager->GetHint("Draw", "Ellipse"); mnitmRectangle->Caption = TexActionManager->GetHint("Draw", "Rectangle"); mnitmSquare->Caption = TexActionManager->GetHint("Draw", "Square"); mnitmEllipse->Caption = TexActionManager->GetHint("Draw", "Ellipse"); mnitmCircle->Caption = TexActionManager->GetHint("Draw", "Circle"); sbOut->Hint = TexActionManager->GetHint("Draw", "Outline"); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::MouseImage_MouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { int w, h; w = MouseImage->Width; h = MouseImage->Height; if (Item != TD_CIRCLE && Item != TD_ELLIP){ if((X>w/4 && X<=3*w/4) && (Y>h/4 && Y<= 3*h/4)) { //Center MousePointPlace = D_Center; } else if((X>=0 && X<=w/2) && (Y>=0 && Y<=h/2)) { //Left-Top MousePointPlace = D_LeftTop; } else if((X>=w/2 && X<=w) && (Y>=0 && Y<=h/2)) { //Right-Top MousePointPlace = D_RightTop; } else if((X>=0 && X<=w/2) && (Y>h/2 && Y<= h)) { //Left-Bottom MousePointPlace = D_LeftBottom; } else if((X>w/2 && X<=w) && (Y>h/2 && Y<=h)) { //Right-Bottom MousePointPlace = D_RightBottom; } DrawMousePoint(MousePointPlace); } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::DrawMousePoint(int mousepoint) { int width, height; TRect canvas; width = MouseImage->Width; height = MouseImage->Height; canvas = Rect(0,0,width,height); MouseImage->Canvas->Brush->Color = clWhite; MouseImage->Canvas->FillRect(canvas); //Create New MouseMark MouseImage->Canvas->Pen->Color = clBlack; MouseImage->Canvas->Pen->Width = 1; MouseImage->Canvas->Brush->Color = clWhite; switch(mousepoint) { case 1: // MouseImage->Canvas->Rectangle(3+2, 3+2, 13-2, 13-2); MouseImage->Canvas->Rectangle(5-3, 5-3, 5+3, 5+3); break; case 2: // MouseImage->Canvas->Rectangle(width-13+2, 3+2, width-3-2, 13-2); MouseImage->Canvas->Rectangle(width-5-3, 5-3, width-5+3, 5+3); break; case 3: // MouseImage->Canvas->Rectangle(3+2, height-13+2, 13-2, height-3-2); MouseImage->Canvas->Rectangle(5-3, height-5-3, 5+3, height-5+3); break; case 4: // MouseImage->Canvas->Rectangle(width-13+2, height-13+2, width-3-2, height-3-2); MouseImage->Canvas->Rectangle(width-5-3, height-5-3, width-5+3, height-5+3); break; default: MouseImage->Canvas->Rectangle(width/2-5+2, height/2-5+2, width/2+5-2, height/2+5-2); break; } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::ExecuteHotKey(String command) { if (command == "Line") { FunctionClick(sbLine); sbLine->Down = true; } else if (command == "Curve") { FunctionClick(sbCurve); sbCurve->Down = true; } else if (command == "Square") { mnitmRectClick(mnitmSquare); } else if (command == "Rectangle") { mnitmRectClick(mnitmRectangle); } else if (command == "Circle") { mnitmCircleClick(mnitmCircle); } else if (command == "Ellipse") { mnitmCircleClick(mnitmEllipse); } else if (command == "Outline") { FunctionClick(sbOut); sbOut->Down = true; } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::rzbtFirstClick(TObject *Sender) { BEGIN_LOG("Draw_F"); COLORREF c; c = PaletteForm->DIB256Palette->GetFGCOLORREF(MainImageForm->iMainImage->uBitmap->BitsPerPixel); // iMainImageChange(); if (Item == TD_LINE) { if (Ltype[TD_LINE].sw == 0) { Lex = firstln.x; Ley = firstln.y; if (!isTaper) Line(c); else TaperLine(StartSize->Value, EndSize->Value, 0, 1, c); step = 0; if (fill_not == 1) { if (MainImageForm->reflection){ Reflection_FillPath(); } else { FillPath(); } } InitPointList(); //lhskys ½ÃÀÛÁ¡ ¸¶¹«¸® step = 0; undos = 0; xkey = 1; //taper À϶§.... if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(PenManagerForm->sbMask->Down, true); } else if (Ltype[TD_LINE].sw == 1) { Tstitch.l[1].ex = firstln.x; Tstitch.l[1].ey = firstln.y; Tstitch.ex = Tstitch.l[1].ex; Tstitch.ey = Tstitch.l[1].ey; dot_line(pmCopy, 1, Ltype[TD_LINE].value, c); step = 0; } InitPointList(); undos = 0; } else if (Item == TD_CURVE) { if (Ltype[TD_LINE].sw == 0) { Lex = firstln.x; Ley = firstln.y; if (!isTaper) Line(c); else TaperLine(StartSize->Value, EndSize->Value, 0, 1, c); step = 0; if (fill_not == 1) { if (MainImageForm->reflection){ Reflection_FillPath(); } else { FillPath(); } } InitPointList(); //lhskys ½ÃÀÛÁ¡ ¸¶¹«¸® step = 0; undos = 0; xkey = 1; //taper À϶§.... if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(PenManagerForm->sbMask->Down, true); } else if (Ltype[TD_LINE].sw == 1) { Tstitch.l[1].ex = firstln.x; Tstitch.l[1].ey = firstln.y; Tstitch.ex = Tstitch.l[1].ex; Tstitch.ey = Tstitch.l[1].ey; dot_line(pmCopy, 1, Ltype[TD_LINE].value, c); step = 0; } InitPointList(); undos = 0; } // } else if (Item == TD_CIRCLE) { // Csx = cirlast.x; Csy = cirlast.y; // Lsx = Csx; Lsy = Csy; Lex = Lsx; Ley = Lsy; //// isw = 0; // hasUserLength = false; // by celberus // step = 1; // } else if (Item == TD_ELLIP) { // Csx = elliplast.x; Csy = elliplast.y; // Lsx = Csx; Lsy = Csy; Lex = Lsx; Ley = Lsy; //// isw = 0; // hasUserLength = false; // by celberus // step = 1; // } if(FullViewForm->Visible==true)FullViewForm->View(); MainImageForm->iMainImage->Repaint(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::rzbtDeleteClick(TObject *Sender) { BEGIN_LOG("Draw_F"); Screen->Cursor=crHourGlass; int i, cnt, dot = 0, solid = 0; COLORREF c; TBackupPointData *bpd; btndelete = 1; RECT rect; if (Item == TD_CURVE && Curve_input && step==1) { if(PointList->Count == 1) bpd = (TBackupPointData *) PointList->Last(); // ÀåÁø¸¸: °î¼±2 À϶§ ¸¶Áö¸·Á¡ ¾ÈÁö¿öÁö´Â ¹®Á¦ ÇØ°á else if(PointList->Count < 2) { END_LOG; return; } else bpd = (TBackupPointData *) PointList->Items[PointList->Count-2]; } else { bpd = (TBackupPointData *) PointList->Last(); // ÇÑÁ¡Áö¿ì°í.... } PointList->Remove(bpd); delete bpd; if (PointList->Count == 0) { step = 0; xkey = 1; rzbtDelete->Enabled = false; rzbtFirst->Enabled = false; iMainImageChange(); Screen->Cursor = crDefault; END_LOG; return; } // Undo->Read(false); //BeConverted by linuxjun Undo_Method // undoread Çϰí.... // MainImageForm->Undo->UndoRead(); //BeConverted by linuxjun //¿ø·¡ ¼Ò½º³»¿ë test½Ã ÁÖÀÇ Undo->Read(false); // undoread Çϰí.... // MainImageForm->LoadUndoWithOutIndexChange if(PenManagerForm->sbMask->Down){ MainImageForm->iMainImage->Mask->PartialUndo->LoadUndoWithOutIndexChange(); //converted by linuxjun }else{ MainImageForm->iMainImage->uBitmap->PartialUndo->LoadUndoWithOutIndexChange(); //converted by linuxjun if (MainImageForm->iMainImage->LayerMask) // MainImageForm->iMainImage->LayerMask->Copy(ud->LayerMask, SRCCOPY); MainImageForm->iMainImage->LayerMask->PartialUndo->LoadUndoWithOutIndexChange(); //by linuxjun } cnt = PointList->Count; // óÀ½ºÎÅÍ ´Ù½Ã ±×·Á..... switch (Item) { case TD_LINE: bpd = (TBackupPointData *) PointList->Items[0]; if(bpd->DotSolid == 0){ Lsx = bpd->pt.x; Lsy = bpd->pt.y; Lex = bpd->pt.x; Ley = bpd->pt.y; }else if(bpd->DotSolid == 1){ Tstitch.l[1].sx = bpd->pt.x; Tstitch.l[1].sy = bpd->pt.y; } for (i = 1; i < cnt; i++) { if(solid == cnt || dot == cnt)break; bpd = (TBackupPointData *) PointList->Items[i]; Ltype[TD_LINE].sw = bpd->DotSolid; if (Ltype[TD_LINE].sw == 0) { // lDotType->Caption = IDS_SOLID; lDotLength->Visible = false; lDotSpace->Visible = false; eDotLength->Visible = false; eDotSpace->Visible = false; // lFillType->Visible = Line_type; // if(!isTaper)lFillType->Enabled = true; //lhskys Taper Àǰæ¿ì¸¦ ÆÄ¾Ç // else lFillType->Enabled = false; //lhskys rzcbFill->Visible = Line_type; imgFill->Visible = Line_type; if(!isTaper){ rzcbFill->Enabled = true; //lhskys Taper Àǰæ¿ì¸¦ ÆÄ¾Ç imgFill->Enabled = true; } else { rzcbFill->Enabled = false; //lhskys imgFill->Enabled = false; } // lFillType->Caption = String(IDS_COMMON_FILL) + " : " + IDS_COMMON_BUTTONNO; //ÇÑÁ¡µÚ·Î ÇßÀ» ¶§ fillÀÌ no°¡ µÇ´Âµ¥ ³ªÁß¿¡´Â ä¿öÁ®¼­ ¸·À½ by celberus for (solid = i; solid < cnt; solid++) { bpd = (TBackupPointData *) PointList->Items[solid]; if(bpd->DotSolid == 1){i=solid-1;Tstitch.l[1].sx=Lsx;Tstitch.l[1].sy=Lsy;break;} StartSize->Value = bpd->start_size; //lhskys Taper À϶§ EndSize->Value = bpd->end_size; //lhskys Taper À϶§ Lex = bpd->pt.x; Ley = bpd->pt.y; if (bpd->spread && isTaper){ //lhskys Taper À϶§ PenManagerForm->aspread = bpd->spread; //lhskys Taper À϶§ PenManagerForm->shFirst->Brush->Color = bpd->s_color; //lhskys Taper À϶§ PenManagerForm->shSecond->Brush->Color = bpd->e_color; //lhskys Taper À϶§ PenManagerForm->numedEGrade->Text = bpd->grade; //lhskys Taper À϶§ }else { c = bpd->col; PenManagerForm->Pen->BasicThick = bpd->pen_size; //lhskys ÇÑÁ¡µÚ·Î ÇØ¼­ ´Ù½Ã ±×·ÁÁÙ¶§ ¹é¾÷ÇØµÐ size·Î ±×¸°´Ù.... } if (!isTaper) Line(c); else TaperLine(StartSize->Value, EndSize->Value, 0, 1, c); Lsx = Lex; Lsy = Ley; } btndelete = 0; PenManagerForm->Pen->BasicThick = PenManagerForm->rzsePenSize->Value; //lhskys ÇÑÁ¡µÚ·Î°¡ ¿Ï·áµÇ¸é ÃÖÁ¾°ªÀ¸·Î ´Ù½Ã ±×¸®±â À§ÇØ... } else { // lDotType->Caption = IDS_DOT; lDotLength->Visible = true; lDotSpace->Visible = true; eDotLength->Visible = true; eDotSpace->Visible = true; // lFillType->Visible = false; rzcbFill->Visible = false; imgFill->Visible = false; for (dot = i; dot < cnt; dot++) { bpd = (TBackupPointData *) PointList->Items[dot]; if(bpd->DotSolid == 0){i=dot-1;Lsx=Tstitch.l[1].sx;Lsy=Tstitch.l[1].sy;break;} Tstitch.l[1].ex = bpd->pt.x; Tstitch.l[1].ey = bpd->pt.y; Ltype[Item].value[1] = StrToInt(bpd->Dotspace); Ltype[Item].value[0] = StrToInt(bpd->Dotlength); eDotLength->Value = StrToInt(bpd->Dotlength); eDotSpace->Value = StrToInt(bpd->Dotspace); c = bpd->col; PenManagerForm->Pen->BasicThick = bpd->pen_size; //lhskys ÇÑÁ¡µÚ·Î ÇØ¼­ ´Ù½Ã ±×·ÁÁÙ¶§ ¹é¾÷ÇØµÐ size·Î ±×¸°´Ù.... dot_line(pmCopy, 1, Ltype[TD_LINE].value, c); Tstitch.l[1].sx = Tstitch.l[1].ex; Tstitch.l[1].sy = Tstitch.l[1].ey; } } } break; case TD_CURVE: bpd = (TBackupPointData *) PointList->Items[0]; if(bpd->DotSolid == 0){ Lsx = bpd->pt.x; Lsy = bpd->pt.y; step = 1; }else if(bpd->DotSolid == 1){ Tstitch.l[1].sx = bpd->pt.x; Tstitch.l[1].sy = bpd->pt.y; Tstitch.l[1].ex = Tstitch.l[1].sx; Tstitch.l[1].ey = Tstitch.l[1].sy; Tstitch.sx = Tstitch.l[1].sx; Tstitch.sy = Tstitch.l[1].sy; Tstitch.ex = Tstitch.l[1].sx; Tstitch.ey = Tstitch.l[1].sy; Lsx = Tstitch.l[1].sx; Lsy = Tstitch.l[1].sy; step = 1; } for(i=1; iItems[i]; Ltype[TD_CURVE].sw = bpd->DotSolid; if (Ltype[TD_CURVE].sw == 0) { // lDotType->Caption = IDS_SOLID; lDotLength->Visible = false; lDotSpace->Visible = false; eDotLength->Visible = false; eDotSpace->Visible = false; //lFillType->Visible = false; rzcbFill->Visible = false; imgFill->Visible = false; for (solid = i; solid < cnt; solid++) { bpd = (TBackupPointData *) PointList->Items[solid]; if(bpd->DotSolid == 1){i=solid-1;Tstitch.l[1].sx=Lsx;Tstitch.l[1].sy=Lsy;break;} if (solid%2) { StartSize->Value = bpd->start_size; //lhskys Taper À϶§ EndSize->Value = bpd->end_size; //lhskys Taper À϶§ Lex = bpd->pt.x; Ley = bpd->pt.y; step = 2; } else { Csx = bpd->pt.x; Csy = bpd->pt.y; c = bpd->col; if (bpd->spread && isTaper){ //lhskys Taper À϶§ PenManagerForm->aspread = bpd->spread; //lhskys Taper À϶§ PenManagerForm->shFirst->Brush->Color = bpd->s_color; //lhskys Taper À϶§ PenManagerForm->shSecond->Brush->Color = bpd->e_color; //lhskys Taper À϶§ PenManagerForm->numedEGrade->Text = bpd->grade; //lhskys Taper À϶§ }else { c = bpd->col; PenManagerForm->Pen->BasicThick = bpd->pen_size; //lhskys ÇÑÁ¡µÚ·Î ÇØ¼­ ´Ù½Ã ±×·ÁÁÙ¶§ ¹é¾÷ÇØµÐ size·Î ±×¸°´Ù.... PenManagerForm->rzsePenSize->Value = PenManagerForm->Pen->BasicThick; } if (!isTaper) curve(pmCopy, c); else TaperCurve(pmCopy, c); Lsx = Lex; Lsy = Ley; step = 1; } } if (Curve_input && !(solid%2)) { Csx = Lex; Csy = Ley; } btndelete = 0; PenManagerForm->Pen->BasicThick = PenManagerForm->rzsePenSize->Value; //lhskys ÇÑÁ¡µÚ·Î°¡ ¿Ï·áµÇ¸é ÃÖÁ¾°ªÀ¸·Î ´Ù½Ã ±×¸®±â À§ÇØ... } else { // lDotType->Caption = IDS_DOT; lDotLength->Visible = true; lDotSpace->Visible = true; eDotLength->Visible = true; eDotSpace->Visible = true; //lFillType->Visible = false; rzcbFill->Visible = false; imgFill->Visible = false; for (dot = i; dot < cnt; dot++) { bpd = (TBackupPointData *) PointList->Items[dot]; if(bpd->DotSolid == 0){i=dot-1;Tstitch.l[1].sx=Lsx;Tstitch.l[1].sy=Lsy;break;} if (dot%2) { Tstitch.l[1].ex = bpd->pt.x; Tstitch.l[1].ey = bpd->pt.y; Tstitch.ex = bpd->pt.x; Tstitch.ey = bpd->pt.y; Lex = bpd->pt.x; Ley = bpd->pt.y; Ltype[Item].value[1] = StrToInt(bpd->Dotspace); Ltype[Item].value[0] = StrToInt(bpd->Dotlength); eDotLength->Value = StrToInt(bpd->Dotlength); eDotSpace->Value = StrToInt(bpd->Dotspace); step = 2; } else { Tstitch.l[1].ex = bpd->pt.x; Tstitch.l[1].ey = bpd->pt.y; Tstitch.ex = bpd->pt.x; Tstitch.ey = bpd->pt.y; Csx = bpd->pt.x; Csy = bpd->pt.y; c = bpd->col; PenManagerForm->Pen->BasicThick = bpd->pen_size; //lhskys ÇÑÁ¡µÚ·Î ÇØ¼­ ´Ù½Ã ±×·ÁÁÙ¶§ ¹é¾÷ÇØµÐ size·Î ±×¸°´Ù.... dot_curve(pmCopy, Ltype[TD_CURVE].value, c); Tstitch.l[1].sx = Lex; Tstitch.l[1].sy = Ley; Tstitch.l[1].ex = Lex; Tstitch.l[1].ey = Ley; Tstitch.sx = Tstitch.l[1].sx; Tstitch.sy = Tstitch.l[1].sy; Tstitch.ex = Tstitch.l[1].sx; Tstitch.ey = Tstitch.l[1].sy; Lsx = Tstitch.l[1].sx; Lsy = Tstitch.l[1].sy; step = 1; } } if (Curve_input && !(dot%2)) { Csx = Lex; Csy = Ley; } } } } if(solid == cnt || dot == cnt){ PenManagerForm->Pen->BasicThick = bpd->pen_size; PenManagerForm->rzsePenSize->Value = PenManagerForm->Pen->BasicThick; } if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(PenManagerForm->sbMask->Down, false); IsBackpoint = false; ::RepaintImage(); Screen->Cursor = crDefault; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::FormClose(TObject *Sender, TCloseAction &Action) { BEGIN_LOG(""); HWND hWnd = ((TWinControl *)Owner)->Handle; PostMessage(hWnd, TPM_EXITFUNCTION, 0, 0); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::mnitmRectClick(TObject *Sender) { TMenuItem *mi = (TMenuItem *)Sender; if (mi != NULL) { sbRect->Glyph->Assign(mi->Bitmap); sbRect->Hint = mi->Caption; // PopupMenu Áß ¾î¶² »ç°¢ÇüÀÌ ¼±ÅõǾú´ÂÁö ±â·ÏÇϱâ À§ÇØ - by monkman (2010.08.27) pumnRect->Tag = mi->Tag; FunctionClick(sbRect); if (mi->Tag == 0) Item = TD_RECT; else Item = TD_SQUR; } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::mnitmCircleClick(TObject *Sender) { TMenuItem *mi = (TMenuItem *)Sender; if (mi != NULL) { sbEllip->Glyph->Assign(mi->Bitmap); sbEllip->Hint = mi->Caption; // PopupMenu Áß ¾î¶² ¿øÀÌ ¼±ÅõǾú´ÂÁö ±â·ÏÇϱâ À§ÇØ - by monkman (2010.08.27) pumnEllip->Tag = mi->Tag; FunctionClick(sbEllip); if (mi->Tag == 0) Item = TD_ELLIP; else Item = TD_CIRCLE; } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::rzbtnLastCenterClick(TObject *Sender) { BEGIN_LOG("Draw_F"); COLORREF c; c = PaletteForm->DIB256Palette->GetFGCOLORREF(MainImageForm->iMainImage->uBitmap->BitsPerPixel); if (Item == TD_CIRCLE) { Csx = cirlast.x; Csy = cirlast.y; Lsx = Csx; Lsy = Csy; Lex = Lsx; Ley = Lsy; // isw = 0; hasUserLength = false; // by celberus step = 1; } else if (Item == TD_ELLIP) { Csx = elliplast.x; Csy = elliplast.y; Lsx = Csx; Lsy = Csy; Lex = Lsx; Ley = Lsy; // isw = 0; hasUserLength = false; // by celberus step = 1; } if(FullViewForm->Visible==true)FullViewForm->View(); MainImageForm->iMainImage->Repaint(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::mnitmSeparateClick(TObject *Sender) { BEGIN_LOG("Draw_F"); iMainImageChange(); InitPointList(); if (Item == TD_LINE) { if (Sender == mnitmSeparate) { Line_type = 0; } else { Line_type = 1; } } else if (Item == TD_CURVE) { if (Sender == mnitmSeparate) { Curve_type = 0; } else { Curve_type = 1; } } view(); step = 0; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::ChangeLTypeImg(int kind) { TMenuItem *menuItem = NULL; if (kind == 0) menuItem = mnitmSeparate; else if (kind == 1) menuItem = mnitmContinuous; if (menuItem != NULL) rzbtnLType->Glyph->Assign(menuItem->Bitmap); } //--------------------------------------------------------------------------- void __fastcall TDrawForm::sbRectClick(TObject *Sender) { // Ŭ¸¯ÇßÀ» °æ¿ì ¸¶Áö¸· ¼±ÅÃÇß´ø »ç°¢ÇüÀÌ ¼±Åõǵµ·Ï ÇÑ´Ù // °°Àº À̺¥Æ®°¡ Áߺ¹ È£ÃâµÉ ¼öµµ ÀÖ´Ù - by monkman (2010.08.27) if (pumnRect->Tag == mnitmRectangle->Tag) mnitmRectClick(mnitmRectangle); else if (pumnRect->Tag == mnitmSquare->Tag) mnitmRectClick(mnitmSquare); } //--------------------------------------------------------------------------- void __fastcall TDrawForm::sbEllipClick(TObject *Sender) { // Ŭ¸¯ÇßÀ» °æ¿ì ¸¶Áö¸· ¼±ÅÃÇß´ø ¿øÀÌ ¼±Åõǵµ·Ï ÇÑ´Ù // °°Àº À̺¥Æ®°¡ Áߺ¹ È£ÃâµÉ ¼öµµ ÀÖ´Ù - by monkman (2010.08.27) if (pumnEllip->Tag == mnitmEllipse->Tag) mnitmCircleClick(mnitmEllipse); else if (pumnEllip->Tag == mnitmCircle->Tag) mnitmCircleClick(mnitmCircle); } //---------------------------------------------------------------------------