//--------------------------------------------------------------------------- #include #include #pragma hdrstop #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 "TPSpin" #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] //--------------------------------------------------------------------------- struct TBackupPointData { POINT pt; COLORREF col; int pen_size; //lhskys ÇϳªÀÇ º¯¼ö¸¦ ¸¸µé¾î ÁÂÇ¥°ª°ú Ä®¶ó°ª°ú °°ÀÌ size °ªµµ ¹é¾÷ÇØµÎ±â À§Çؼ­... int DotSolid; int start_size; int end_size; AnsiString Dotspace; AnsiString 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(DirectoryCommon, Language, "Draw"); SetSmallFont(Font); SetSmallFont(lLineType->Font); SetSmallFont(lFillType->Font); SetSmallFont(lLength->Font); SetSmallFont(lAngle->Font); SetSmallFont(TaperLabel->Font); SetSmallFont(lDotType->Font); SetSmallFont(lDotLength->Font); SetSmallFont(lDotSpace->Font); sbLine->Caption = IDS_COMMON_LINE; sbCurve->Caption = IDS_COMMON_CURVE; sbSquare->Caption = IDS_COMMON_SQUARE; sbRect->Caption = IDS_COMMON_RECTANGLE; sbCircle->Caption = IDS_COMMON_CIRCLE; sbEllip->Caption = IDS_COMMON_ELLIPSE; sbOut->Caption = IDS_COMMON_OUTLINE; lLineType->Caption = IDS_COMMON_CONTINUOUSLINE; lFillType->Caption = AnsiString(IDS_COMMON_FILL) + " : " + AnsiString(IDS_COMMON_BUTTONNO); lLength->Caption = IDS_COMMON_LENGTH; lAngle->Caption = IDS_COMMON_ANGLE; lDotType->Caption = IDS_SOLID; lDotLength->Caption = IDS_COMMON_LENGTH; lDotSpace->Caption = IDS_COMMON_GAP; btnFirst->Caption = IDS_COMMON_FIRSTPOINT; btnDelete->Caption = IDS_DELETEPOINT; TaperLabel->Caption = IDS_TAPERNO; sbInputMode1->Caption = IDS_INPUT_A; sbInputMode2->Caption = IDS_INPUT_B; //============================================================= isTaper = false; StartSize->Value = PenManagerForm->Pen->Thick; EndSize->Value = 1; PenManagerForm->sePenSize->Value = StartSize->Value; separatel = 0; //lhskys cirlastpoint = true; elliplastpoint = true; //============================= } //--------------------------------------------------------------------------- void __fastcall TDrawForm::FormCreate(TObject *Sender) { // } //--------------------------------------------------------------------------- void __fastcall TDrawForm::lLineTypeClick(TObject *Sender) { iMainImageChange(); InitPointList(); if (Item == TD_LINE) { if (Line_type == 0) { Line_type = 1; undos = 0; separatel = 0; lLineType->Caption = IDS_COMMON_CONTINUOUSLINE; } else if (Line_type == 1) { step = 0; Line_type = 0; lLineType->Caption = IDS_COMMON_SEPARATELINE; } } else if (Item == TD_CURVE) { if (Curve_type == 0) { Curve_type = 1; undos = 0; lLineType->Caption = IDS_COMMON_CONTINUOUSLINE; } else if (Curve_type == 1) { step = 0; Curve_type = 0; lLineType->Caption = IDS_COMMON_SEPARATELINE; } } view(); } //--------------------------------------------------------------------------- void __fastcall TDrawForm::lFillTypeClick(TObject *Sender) { iMainImageChange(); if (fill_not == 0) { fill_not = 1; lFillType->Caption = AnsiString(IDS_COMMON_FILL) + " : " + AnsiString(IDS_COMMON_BUTTONYES); Ltype[Item].sw = 0; lDotType->Caption = IDS_SOLID; } else if (fill_not == 1) { fill_not = 0; lFillType->Caption = AnsiString(IDS_COMMON_FILL) + " : " + AnsiString(IDS_COMMON_BUTTONNO); } InitPointList(); view(); } //--------------------------------------------------------------------------- void __fastcall TDrawForm::FunctionClick(TObject *Sender) { TSpeedButton *s; bool change = false; int prestep, sx, sy; COLORREF c = PaletteForm->DIB256Palette->GetFGCOLORREF(MainImageForm->iMainImage->uBitmap->BitsPerPixel); iMainImageChange(); InitPointList(); s = (TSpeedButton *)Sender; btnFirst->Enabled = true; if (s == sbLine) { if (Item == TD_CURVE && Line_type == 1 && step < 2) { 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; btnFirst->Caption = IDS_COMMON_FIRSTPOINT; StartSize->Value = PenManagerForm->Pen->Thick; //EndSize->Value = 1; ClientHeight = 231; Parent->Height = ParentHeight+ClientHeight; } else if (s == sbCurve) { 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->Thick; //EndSize->Value = 1; ClientHeight = 231; Parent->Height = ParentHeight+ClientHeight; } else if (s == sbSquare) { Item = TD_SQUR; ClientHeight = 231; Parent->Height = ParentHeight+ClientHeight; } else if (s == sbRect) { Item = TD_RECT; ClientHeight = 231; Parent->Height = ParentHeight+ClientHeight; } else if (s == sbCircle) { Item = TD_CIRCLE; btnFirst->Caption = IDS_LASTCENTER; ClientHeight = 231; Parent->Height = ParentHeight+ClientHeight; } else if (s == sbEllip) { Item = TD_ELLIP; btnFirst->Caption = IDS_LASTCENTER; ClientHeight = 231; Parent->Height = ParentHeight+ClientHeight; } else if (s == sbOut) { Item = TD_OUT; // ParentHeight = Parent->Height+20; ClientHeight = 106; Parent->Height = ParentHeight+ClientHeight; } isw = 0; Asw = 0; Lsw = 0; Dsw = 0; Line_type = 1; Curve_type = 1; view(); if(Item == TD_CIRCLE){ if(cirlastpoint)btnFirst->Enabled = false; }else if(Item == TD_ELLIP){ if(elliplastpoint)btnFirst->Enabled = false; } if (change) step = prestep; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::lDotTypeClick(TObject *Sender) { POINT *pt, st; iMainImageChange(); if (Ltype[Item].sw == 0) { Ltype[Item].sw = 1; lDotType->Caption = IDS_DOT; lFillType->Caption = AnsiString(IDS_COMMON_FILL) + " : " + IDS_COMMON_BUTTONNO; fill_not = 0; } else if (Ltype[Item].sw == 1) { 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; } } //=====================================================2001.8.22 by lhskys if (Item == TD_LINE) { sbLine->Down = true; lLineType->Visible = true; lLength->Visible = true; lLength->Caption = IDS_COMMON_LENGTH; lDotType->Visible = true; if(!isTaper)lDotType->Enabled = true; //lhskys Taper Àǰæ¿ì¸¦ ÆÄ¾Ç else lDotType->Enabled = false; //lhskys lAngle->Visible = true; eLength1->Visible = true; eLength2->Visible = false; eAngle->Visible = true; TaperLabel->Visible= true; if (TaperLabel->Caption == IDS_TAPERYES) { 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; } 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 } else if (Ltype[TD_LINE].sw == 1) { lDotType->Caption = IDS_DOT; lDotLength->Visible = true; lDotSpace->Visible = true; eDotLength->Visible = true; eDotSpace->Visible = true; lFillType->Visible = false; } btnFirst->Caption = IDS_COMMON_FIRSTPOINT; btnFirst->Visible = true; btnDelete->Visible = true; if (Line_type == 0) lLineType->Caption = IDS_COMMON_SEPARATELINE; else if (Line_type == 1) lLineType->Caption = IDS_COMMON_CONTINUOUSLINE; if (fill_not == 0) lFillType->Caption = AnsiString(IDS_COMMON_FILL) + " : " + AnsiString(IDS_COMMON_BUTTONNO); else if (fill_not == 1) lFillType->Caption = AnsiString(IDS_COMMON_FILL) + " : " + AnsiString(IDS_COMMON_BUTTONYES); } else if (Item == TD_CURVE) { sbCurve->Down = true; lLineType->Visible = true; lFillType->Visible = false; lLength->Visible = false; lDotType->Visible = true; if(!isTaper)lDotType->Enabled = true; //lhskys Taper Àǰæ¿ì¸¦ ÆÄ¾Ç else lDotType->Enabled = false; //lhskys lAngle->Visible = false; eLength1->Visible = false; eLength2->Visible = false; eAngle->Visible = false; TaperLabel->Visible= true; if (TaperLabel->Caption == IDS_TAPERYES) { 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; } if (Ltype[TD_CURVE].sw == 0) { lDotType->Caption = IDS_SOLID; lDotLength->Visible = false; lDotSpace->Visible = false; eDotLength->Visible = false; eDotSpace->Visible = false; } else if (Ltype[TD_CURVE].sw == 1) { lDotType->Caption = IDS_DOT; lDotLength->Visible = true; lDotSpace->Visible = true; eDotLength->Visible = true; eDotSpace->Visible = true; } btnFirst->Visible = false; btnDelete->Visible = true; if (Curve_type == 0) lLineType->Caption = IDS_COMMON_SEPARATELINE; else if (Curve_type == 1) lLineType->Caption = IDS_COMMON_CONTINUOUSLINE; } eDotLength->Text = Ltype[Item].value[0]; eDotSpace->Text = Ltype[Item].value[1]; //========================================================== // view(); // ÇÑÁ¡µÚ·Î ½Ã¿¡ Á¡¼±/½Ç¼± µ¿½Ã ¾ðµÎ¸¦ À§ÇØ ¸·À½ step = 1; }else { InitPointList(); view(); } //======================== } //--------------------------------------------------------------------------- void __fastcall TDrawForm::EditMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { TEdit *s; s = (TEdit *)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::EditKeyPress(TObject *Sender, char &Key) { TEdit *s; if (Key == 13) { iMainImageChange(); s = (TEdit *)Sender; if (s == eLength1) { if(eLength1->Text == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); return; } if (Item != TD_LINE) { Lsx = -1; Lex = -1; Lsy = -1; Ley = -1; Csx = -1; Csy = -1; } isw = 1; 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; Lsw = 1; InputNumber(); } else if (s == eAngle) { isw = 1; Asw = 1; InputNumber(); } else if (s == eDotLength) { Dsw = 1; InputDotNumber(); } else if (s == eDotSpace) { Dsw = 2; InputDotNumber(); } SetFocus(); Key = 0; }else { s = (TEdit *)Sender; if (s == eLength1 || s == eDotLength || eDotSpace) { swLength = true; } else if (s == eAngle) { swAngle = true; } else if (s == eLength2) { swLength = true; } } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::btnFirstClick(TObject *Sender) { 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) { FillInPolygon(); } 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; step = 1; } else if (Item == TD_ELLIP) { Csx = elliplast.x; Csy = elliplast.y; Lsx = Csx; Lsy = Csy; Lex = Lsx; Ley = Lsy; isw = 0; step = 1; } if(FullViewForm->Visible==true)FullViewForm->View(); MainImageForm->iMainImage->Repaint(); } //--------------------------------------------------------------------------- // Private Function //--------------------------------------------------------------------------- void __fastcall TDrawForm::InputDotNumber(void) { if (Dsw == 1) { Ltype[Item].value[0] = StrToInt(eDotLength->Text); Dsw = 0; } else if (Dsw == 2) { Ltype[Item].value[1] = StrToInt(eDotSpace->Text); Dsw = 0; } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::InputNumber(void) { AnsiString s; int pw, x, y, ang; double len; TPItemImage *Image = MainImageForm->iMainImage; pw = PenManagerForm->Pen->Thick; if (Item == TD_CIRCLE) { s = eLength1->Text; if (isw == 1) { switch (MainImageForm->CurrentUnit) { case uInch : if (StrToFloat(s) * MainImageForm->CanvasInfor.DotsPerInch + 0.5 > pw) { Radius = StrToFloat(s) * MainImageForm->CanvasInfor.DotsPerInch + 0.5; }else if(StrToFloat(s) == 0)Radius=0; break; case uCm : if (StrToFloat(s) / 2.54 * MainImageForm->CanvasInfor.DotsPerInch + 0.5 > pw) { Radius = StrToFloat(s) / 2.54 * MainImageForm->CanvasInfor.DotsPerInch + 0.5; }else if(StrToFloat(s) == 0)Radius=0; break; default : if (StrToInt(s) > (pw)) { Radius = StrToInt(s); }else if(StrToFloat(s) == 0)Radius=0; break; } isw = 2; 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) { switch (MainImageForm->CurrentUnit) { case uDot : if (StrToInt(eLength1->Text) > pw / 2.0) Ell_rx = StrToInt(eLength1->Text); else if(StrToInt(eLength1->Text) == 0) Ell_rx = 0; if (StrToInt(eLength2->Text) > pw / 2.0) Ell_ry = StrToInt(eLength2->Text); else if(StrToInt(eLength2->Text) == 0) Ell_ry = 0; break; case uInch : if (StrToFloat(eLength1->Text) * MainImageForm->CanvasInfor.DotsPerInch + 0.5 > pw / 2.0) { Ell_rx = StrToFloat(eLength1->Text) * MainImageForm->CanvasInfor.DotsPerInch + 0.5; }else if(StrToInt(eLength1->Text) == 0) Ell_rx = 0; if (StrToFloat(eLength2->Text) * MainImageForm->CanvasInfor.DotsPerInch + 0.5 > pw / 2.0) { Ell_ry = StrToFloat(eLength2->Text) * MainImageForm->CanvasInfor.DotsPerInch + 0.5; }else if(StrToInt(eLength2->Text) == 0) Ell_ry = 0; break; case uCm : if (StrToFloat(eLength1->Text) * MainImageForm->CanvasInfor.DotsPerInch / 2.54 + 0.5 > pw / 2.0) { Ell_rx = StrToFloat(eLength1->Text) * MainImageForm->CanvasInfor.DotsPerInch / 2.54 + 0.5; }else if(StrToInt(eLength1->Text) == 0) Ell_rx = 0; if (StrToFloat(eLength2->Text) * MainImageForm->CanvasInfor.DotsPerInch / 2.54 + 0.5 > pw / 2.0) { Ell_ry = StrToFloat(eLength2->Text) * MainImageForm->CanvasInfor.DotsPerInch / 2.54 + 0.5; }else if(StrToInt(eLength2->Text) == 0) Ell_ry = 0; } isw = 2; 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) { switch (MainImageForm->CurrentUnit) { case uDot : if (StrToInt(eLength1->Text) > pw) Sqr_l = StrToInt(eLength1->Text); else if(StrToInt(eLength1->Text) == 0) Sqr_l = 0; break; case uInch : if (StrToFloat(eLength1->Text) * MainImageForm->CanvasInfor.DotsPerInch + 0.5 > pw) { Sqr_l = StrToFloat(eLength1->Text) * MainImageForm->CanvasInfor.DotsPerInch + 0.5; }else if(StrToInt(eLength1->Text) == 0) Sqr_l = 0; break; case uCm : if (StrToFloat(eLength1->Text) / 2.54 * MainImageForm->CanvasInfor.DotsPerInch + 0.5 > pw) { Sqr_l = StrToFloat(eLength1->Text) / 2.54 * MainImageForm->CanvasInfor.DotsPerInch + 0.5; }else if(StrToInt(eLength1->Text) == 0) Sqr_l = 0; } isw = 2; 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) { switch (MainImageForm->CurrentUnit) { case uDot : if (StrToInt(eLength1->Text) > pw) Rec_lx = StrToInt(eLength1->Text); else if(StrToInt(eLength1->Text) == 0) Rec_lx = 0; if (StrToInt(eLength2->Text) > pw) Rec_ly = StrToInt(eLength2->Text); else if(StrToInt(eLength2->Text) == 0) Rec_ly = 0; break; case uInch : if (StrToFloat(eLength1->Text) * MainImageForm->CanvasInfor.DotsPerInch + 0.5 > pw) { Rec_lx = StrToFloat(eLength1->Text) * MainImageForm->CanvasInfor.DotsPerInch + 0.5; }else if(StrToFloat(eLength1->Text) == 0){ Rec_lx = 0; } if (StrToFloat(eLength2->Text) * MainImageForm->CanvasInfor.DotsPerInch + 0.5 > pw) { Rec_ly = StrToFloat(eLength2->Text) * MainImageForm->CanvasInfor.DotsPerInch + 0.5; }else if(StrToFloat(eLength2->Text) == 0){ Rec_ly = 0; } break; case uCm : if (StrToFloat(eLength1->Text) / 2.54 * MainImageForm->CanvasInfor.DotsPerInch + 0.5 > pw) { Rec_lx = StrToFloat(eLength1->Text) / 2.54 * MainImageForm->CanvasInfor.DotsPerInch + 0.5; }else if(StrToFloat(eLength1->Text) == 0){ Rec_lx = 0; } if (StrToFloat(eLength2->Text) / 2.54 * MainImageForm->CanvasInfor.DotsPerInch + 0.5 > pw) { Rec_ly = StrToFloat(eLength2->Text) / 2.54 * MainImageForm->CanvasInfor.DotsPerInch + 0.5; }else if(StrToFloat(eLength2->Text) == 0){ Rec_ly = 0; } } isw = 2; 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 = StrToFloat(eAngle->Text); ang %= 90; Line_angle = ang; Asw = 2; } if (Lsw == 1) { len = StrToFloat(eLength1->Text); 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; } } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::Line(COLORREF fc) { MainImageForm->line_pen(Lsx, Lsy, Lex, Ley, fc); } //---------------------------------------------------------------------------//k3dogs void __fastcall TDrawForm::TaperLine(int s_size, int e_size, double s_rate, double e_rate, COLORREF fc) { 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->Text = Format("%3.1f", OPENARRAY(TVarRec, (p))); lx = abs(dx); ly = abs(dy); 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))); } //============================================================================== PenManagerForm->update=false; PenManagerForm->DrawTaperLine(Lsx, Lsy, Lex, Ley, s_size, e_size, s_rate, e_rate, fc); PenManagerForm->update=true; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::outline_pen(TPBitmap *op, int sx, int sy) { int i, j, x, y, r, pw; Byte c; Byte *OP, *BP, *LP; TPItemImage *Image = MainImageForm->iMainImage; c = PaletteForm->DIB256Palette->ChoiceIndex; pw = PenManagerForm->Pen->Thick; 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 } } } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::outlinemask_pen(TPBitmap *op, int sx, int sy) { int i, j, x, y, r, pw; Byte *OP, *BP, *MP; TPItemImage *Image = MainImageForm->iMainImage; pw = PenManagerForm->Pen->Thick; 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 } } } //--------------------------------------------------------------------------- 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) { int i, j, x, y, r, pw; Byte *OP, *MP, *BBP, *LP; TPItemImage *Image = MainImageForm->iMainImage; pw = PenManagerForm->Pen->Thick; 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 } } } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::outlinemask_pen_24(TPBitmap *op, TPBitmap *mask, int sx, int sy) { int i, j, x, y, r, pw; Byte *OP, *MP, *BBP; TPItemImage *Image = MainImageForm->iMainImage; pw = PenManagerForm->Pen->Thick; 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 } } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::outlinemaskdelete_pen_24(TPBitmap *op, TPBitmap *mask, int sx, int sy) { int i, j, x, y, r, pw; Byte *OP, *MP, *BBP; TPItemImage *Image = MainImageForm->iMainImage; pw = PenManagerForm->Pen->Thick; 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 } } } //---------------------------------------------------------------------------- bool __fastcall TDrawForm::outline_24(int XD, int YD) { int x, y, sx, sy, ex, ey, a, pw, r1, tx, ty, wid, hei, code, i, 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; 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; goto fail; } } else { if (!(Image->FloodFillMask(fillstart, OutRead_layer24_zero, NULL, rect, MaskFF))) { ec = EC_MEMORY_LACK; goto fail; } } } else { if (!(Image->uBitmap->FloodFillMask(fillstart, OutRead_none24, NULL, rect, MaskFF))) { ec = EC_MEMORY_LACK; 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; goto fail; } if (!(MaskFE->Create(wid, hei, 1))) { ec = EC_MEMORY_LACK; goto fail; } if ((MaskFD = new TPBitmap) == NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!(MaskFD->Create(wid, hei, 1))) { ec = EC_MEMORY_LACK; goto fail; } if (MaskFF->Lock() == NULL) { ec = EC_MEMORY_LACK; goto fail; } if (MaskFE->Lock() == NULL) { ec = EC_MEMORY_LACK; 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; } /* mm = 0x80; *MP = 0; for (x = sx; x <= ex; x++) { 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; } } 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; 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; 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; goto fail; } if (!(outpen->Create(81, 81, 8))) { ec = EC_MEMORY_LACK; goto fail; } if (outpen->Lock() == NULL) { ec = EC_MEMORY_LACK; goto fail; } pw = (PenManagerForm->Pen->Thick - 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; goto fail; } if (MaskFF->Lock() == NULL) { ec = EC_MEMORY_LACK; goto fail; } if (PenManagerForm->sbMask->Down) { if (!(Image->Mask->StartScanLineN(2))) { ec = EC_MEMORY_LACK; goto fail; } if (PenManagerForm->chDelete->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; goto fail; } if (!Image->LayerMask->StartScanLine()) { ec = EC_MEMORY_LACK; 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; 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; 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); return false; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::outline(int XD, int YD) { ///* //BeConverted by linuxjun Don't Forget!! Undo_Method RGBQUAD rgb[256]; int x, y, sx, sy, ex, ey, i, code, a, pw, r1, 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; 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; 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; goto fail; } if (!(outpen->Create(81, 81, 8))) {ec = EC_MEMORY_LACK; goto fail; } if (outpen->Lock() == NULL) {ec = EC_MEMORY_LACK; goto fail; } pw = (PenManagerForm->Pen->Thick - 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; 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; 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; 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; 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); //*/ } //--------------------------------------------------------------------------- void __fastcall TDrawForm::fit_dot_line(TPenMode ch, int ln, int *value, COLORREF fc) { 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->Thick; 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); } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::fit_dot_line(HDC dc, int x, int y) { 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->Thick; 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); } } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::square(TPenMode ch, COLORREF fc) { int sx, sy, ex, ey, lx, ly, pt, sr, lr; int SignX, SignY; Byte *IP; TPItemImage *Image = MainImageForm->iMainImage; pt = PenManagerForm->Pen->Thick; sr = pt >> 1; lr = pt - sr; if (isw==0) { 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) { if (PenManagerForm->sbMask->Down) { if (!(Image->Mask->StartScanLine())) goto fail; } else { if (!(Image->uBitmap->StartScanLine())) goto fail; if (Image->LayerMask) { if (!(Image->LayerMask->StartScanLine())) goto fail; } if (MainImageForm->MaskArea) { if (!(Image->Mask->StartScanLine())) goto fail; } } for (int i = sy + lr; i < ey - sr; i++) { MainImageForm->set_hline(sx + lr, i, ex - sx - 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(); } } } 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); /* 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->Thick; switch (MainImageForm->CurrentUnit) { case uDot: eLength1->Text = lx; break; case uInch: eLength1->Text = Format("%.2f", OPENARRAY(TVarRec, ((double)lx / MainImageForm->CanvasInfor.DotsPerInch))); break; case uCm: eLength1->Text = Format("%.2f", OPENARRAY(TVarRec, (2.54 * lx / MainImageForm->CanvasInfor.DotsPerInch))); break; } 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) { 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->Thick; switch (MainImageForm->CurrentUnit) { case uDot : eLength1->Text = l; break; case uInch: eLength1->Text = Format("%.2f", OPENARRAY(TVarRec, ((double)l / MainImageForm->CanvasInfor.DotsPerInch))); break; case uCm : eLength1->Text = Format("%.2f", OPENARRAY(TVarRec, ((double)l / MainImageForm->CanvasInfor.DotsPerInch * 2.54))); } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::rectangle(TPenMode ch, COLORREF fc) { int sx, sy, ex, ey, lx, ly, pt, sr, lr; Byte *IP; TPItemImage *Image = MainImageForm->iMainImage; pt = PenManagerForm->Pen->Thick; sr = pt >> 1; lr = pt - sr; if (isw==0) { 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) { if (fill_not == 1) { if (ex - sx - pt > 0 && ey - sy - pt > 0) { if (PenManagerForm->sbMask->Down) { if (!(Image->Mask->StartScanLine())) goto fail; } else { if (!(Image->uBitmap->StartScanLine())) goto fail; if (Image->LayerMask) { if (!(Image->LayerMask->StartScanLine())) goto fail; } if (MainImageForm->MaskArea) { if (!(Image->Mask->StartScanLine())) goto fail; } } for (int i = sy + lr; i < ey - sr; i++) { MainImageForm->set_hline(sx + lr, i, ex - sx - 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(); } } } 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); /* 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->Thick; ly += PenManagerForm->Pen->Thick; switch (MainImageForm->CurrentUnit) { case uDot: eLength1->Text = lx; eLength2->Text = ly; break; case uInch: eLength1->Text = Format("%.2f", OPENARRAY(TVarRec, ((double)lx / MainImageForm->CanvasInfor.DotsPerInch))); eLength2->Text = Format("%.2f", OPENARRAY(TVarRec, ((double)ly / MainImageForm->CanvasInfor.DotsPerInch))); break; case uCm: eLength1->Text = Format("%.2f", OPENARRAY(TVarRec, (2.54 * lx / MainImageForm->CanvasInfor.DotsPerInch))); eLength2->Text = Format("%.2f", OPENARRAY(TVarRec, (2.54 * ly / MainImageForm->CanvasInfor.DotsPerInch))); break; } 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_rectangle(TPenMode ch, int *value, COLORREF fc) { 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->Thick; ly = abs(ey - sy) + PenManagerForm->Pen->Thick; switch (MainImageForm->CurrentUnit) { case uDot : eLength1->Text = lx; eLength2->Text = ly; break; case uInch: eLength1->Text = Format("%.2f", OPENARRAY(TVarRec, ((double)lx / MainImageForm->CanvasInfor.DotsPerInch))); eLength2->Text = Format("%.2f", OPENARRAY(TVarRec, ((double)ly / MainImageForm->CanvasInfor.DotsPerInch))); break; case uCm : eLength1->Text = Format("%.2f", OPENARRAY(TVarRec, ((double)lx / MainImageForm->CanvasInfor.DotsPerInch * 2.54))); eLength2->Text = Format("%.2f", OPENARRAY(TVarRec, ((double)ly / MainImageForm->CanvasInfor.DotsPerInch * 2.54))); } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::curve(TPenMode ch, COLORREF fc) { 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->Thick; 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; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::TaperCurve(TPenMode ch, COLORREF fc) { 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->Thick; 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; } //---------------------------------------------------------------------------- void __fastcall TDrawForm::dot_curve(TPenMode ch, int *value, COLORREF fc) { 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->Thick; 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->Thick; 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->Thick; 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; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::circle(TPenMode ch, COLORREF fc) { int lx, ly, dia, h; TTexpiaBitmap *tb = NULL; HDC dc = NULL; HPEN hPen = NULL, hOldPen = NULL; int x, y, xx, ls, rs, ec = EC_NONE; BYTE *bp; TPItemImage *Image = MainImageForm->iMainImage; if (isw==0) { lx = Lsx - Csx; ly = Lsy - Csy; dia = 2 * sqrt(lx * lx + ly * ly) + 1; } else { if(Radius == 0)dia = 13; else dia = Radius; } h = dia / 2; if (ch == pmXor) { DrawEllipseLocate(Rect(Csx - h, Csy - h, Csx - h + dia + 1, Csy - h + dia + 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; goto fail;} } else { if (!(Image->uBitmap->StartScanLine())) {ec = EC_MEMORY_LACK; goto fail;} if (Image->LayerMask) { if (!(Image->LayerMask->StartScanLine())) {ec = EC_MEMORY_LACK; goto fail;} if (MainImageForm->bProtect) if (!(Image->BackGround->StartScanLine())) goto fail; } if (MainImageForm->MaskArea) { if (!(Image->Mask->StartScanLine())) {ec = EC_MEMORY_LACK; goto fail;} } } ls = PenManagerForm->Pen->Thick >> 1; rs = PenManagerForm->Pen->Thick - ls; if ((tb = new TTexpiaBitmap)==NULL) {ec = EC_MEMORY_LACK; goto fail;} if (!tb->Create(dia, dia, 8)) {ec = EC_MEMORY_LACK; goto fail;} if ((dc = tb->CreateDC())==NULL) {ec = EC_RESOURCE_LACK; 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; goto fail;} hOldPen = SelectObject(dc, hPen); Ellipse(dc, ls, ls, dia - rs + 1, dia - rs + 1); SelectObject(dc, hOldPen); DeleteObject(hPen); hPen = NULL; tb->DeleteDC(dc); dc = NULL; if (!tb->StartScanLine()) {ec = EC_MEMORY_LACK; goto fail;} for (y = 0; y < dia; y++) { bp = tb->GetScanLine(y); for (x = 0; x < dia;) { if (bp[x]) { for (xx = x; xx < dia; xx++) { if (bp[xx]==0) break; } MainImageForm->set_hline(Csx - h + x, Csy - 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; switch (MainImageForm->CurrentUnit) { case uDot: eLength1->Text = dia; break; case uInch: eLength1->Text = Format("%.2f", OPENARRAY(TVarRec,((double)dia / MainImageForm->CanvasInfor.DotsPerInch))); break; case uCm: eLength1->Text = Format("%.2f", OPENARRAY(TVarRec,(2.54 * dia / MainImageForm->CanvasInfor.DotsPerInch))); break; } 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); } //--------------------------------------------------------------------------- void __fastcall TDrawForm::dot_line(TPenMode ch, int ln, int *value, COLORREF fc) { 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->Thick; 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->Thick)) <= lng) { Lex = (gap * i + ((value[0] - 1) * PenManagerForm->Pen->Thick)) * ct + sx + 0.5; Ley = (gap * i + ((value[0] - 1) * PenManagerForm->Pen->Thick)) * 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->Thick)) <= lng) { Lex = (gap * i + ((value[0] - 1) * PenManagerForm->Pen->Thick)) * ct + sx + 0.5; Ley = (gap * i + ((value[0] - 1) * PenManagerForm->Pen->Thick)) * 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->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::dot_line_mark(int len, char *bb, int *value) { 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->Thick; 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->Thick; 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 char[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(); } //--------------------------------------------------------------------------- void __fastcall TDrawForm::ellipse(TPenMode ch, COLORREF fc) { 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, ec = EC_NONE; BYTE *bp; TPItemImage *Image = MainImageForm->iMainImage; if (isw==0) { a = 2 * abs(Lsx - Csx) + 1; b = 2 * abs(Lsy - Csy) + 1; } else { if(Ell_rx == 0)a = 13; else a = Ell_rx; if(Ell_ry == 0)b = 13; else b = Ell_ry; } 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; goto fail;} } else { if (!(Image->uBitmap->StartScanLine())) {ec = EC_MEMORY_LACK; goto fail;} if (Image->LayerMask) { if (!(Image->LayerMask->StartScanLine())) {ec = EC_MEMORY_LACK; goto fail;} if (MainImageForm->bProtect) if (!(Image->BackGround->StartScanLine())) goto fail; } if (MainImageForm->MaskArea) { if (!(Image->Mask->StartScanLine())) {ec = EC_MEMORY_LACK; goto fail;} } } ls = PenManagerForm->Pen->Thick >> 1; rs = PenManagerForm->Pen->Thick - ls; if ((tb = new TTexpiaBitmap)==NULL) {ec = EC_MEMORY_LACK; goto fail;} if (!tb->Create(a, b, 8)) {ec = EC_MEMORY_LACK; goto fail;} if ((dc = tb->CreateDC())==NULL) {ec = EC_RESOURCE_LACK; 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; 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; goto fail;} for (y = 0; y < b; y++) { bp = tb->GetScanLine(y); for (x = 0; x < a;) { if (bp[x]) { for (xx = x; xx < a; xx++) { if (bp[xx]==0) break; } MainImageForm->set_hline(Csx - hx + x, Csy - 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; switch (MainImageForm->CurrentUnit) { case uDot : eLength1->Text = a; break; case uInch: eLength1->Text = Format("%.2f", OPENARRAY(TVarRec, ((double)a / MainImageForm->CanvasInfor.DotsPerInch))); break; case uCm : eLength1->Text = Format("%.2f", OPENARRAY(TVarRec, (2.54 * a / MainImageForm->CanvasInfor.DotsPerInch))); } next: if(Ell_ry == 0) if(!(isw == 0 && step == 1))return; switch (MainImageForm->CurrentUnit) { case uDot : eLength2->Text = b; break; case uInch: eLength2->Text = Format("%.2f", OPENARRAY(TVarRec, ((double)b / MainImageForm->CanvasInfor.DotsPerInch))); break; case uCm : eLength2->Text = Format("%.2f", OPENARRAY(TVarRec, (2.54 * b / MainImageForm->CanvasInfor.DotsPerInch))); } 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); } //--------------------------------------------------------------------------- void __fastcall TDrawForm::dotted_ellipse(TPenMode ch, int *value) { char *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->Thick; a = abs(Lsx - Csx) - pw / 2.0; b = abs(Lsy - Csy) - pw / 2.0; 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 char[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(); //by jeegeo Image->Repaint(); } //--------------------------------------------------------------------------- void __fastcall TDrawForm::LenAng_check(int x, int y) { 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); } } } } } //============================================================================== } //---------------------------------------------------------------------------- void __fastcall TDrawForm::DotLineLocate(HDC dc, int x, int y, void *pData) { 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 = 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->Thick; 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->Thick)) <= lng) { Lex = (gap * i + ((Ltype[Item].value[0] - 1) * PenManagerForm->Pen->Thick)) * ct + sx + 0.5; Ley = (gap * i + ((Ltype[Item].value[0] - 1) * PenManagerForm->Pen->Thick)) * 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->Thick)) <= lng) { Lex = (gap * i + ((Ltype[Item].value[0] - 1) * PenManagerForm->Pen->Thick)) * ct + sx + 0.5; Ley = (gap * i + ((Ltype[Item].value[0] - 1) * PenManagerForm->Pen->Thick)) * 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); } } //---------------------------------------------------------------------------- void __fastcall TDrawForm::DrawDotLineLocate(POINT First, POINT Second) { RECT rt, Src, Dst; int ls, rs; TPItemImage *Image = MainImageForm->iMainImage; ls = PenManagerForm->Pen->Thick >> 1; rs = PenManagerForm->Pen->Thick - ls; 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; UnionRect(&Dst, &Src, &DrawLocate[Item].rtInvalidate); DrawLocate[Item].szPen = PenManagerForm->Pen->Thick; 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; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::LineLocate(HDC dc, int x, int y, void *pData) { TPLayerImage *image=MainImageForm->iMainImage; 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 = 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); } /* TPLayerImage *image=MainImageForm->iMainImage; HPEN hPen, hOldPen; LOGBRUSH lplb = { BS_SOLID, DrawLocate[Item].clPen, HS_CROSS }; SetMiterLimit(dc, 5.0, NULL); hPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_FLAT | PS_JOIN_MITER, DrawLocate[Item].szPen*image->ZoomIn/image->ZoomOut+0.5, &lplb, 0, NULL); hOldPen = SelectObject(dc, hPen); 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)); SelectObject(dc, hOldPen); DeleteObject(hPen); */ } //---------------------------------------------------------------------------- void __fastcall TDrawForm::DrawLineLocate(POINT First, POINT Second) { RECT Src, Dst; int ls, rs; TPItemImage *Image = MainImageForm->iMainImage; ls = PenManagerForm->Pen->Thick >> 1; rs = PenManagerForm->Pen->Thick - 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; 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->Thick; 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; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::CurveLocate(HDC dc, int x, int y, void *pData) { 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; 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) { 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) return; // } // } hOldPen = SelectObject(dc, hPen); ls = PenManagerForm->Pen->Thick / 2.0; rs = PenManagerForm->Pen->Thick - ls; pw = PenManagerForm->Pen->Thick; 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); } } //---------------------------------------------------------------------------- void __fastcall TDrawForm::DrawCurveLocate(POINT First, POINT Second, POINT Third) { RECT rt, dist; int ls, rs; TPItemImage *Image = MainImageForm->iMainImage; ls = PenManagerForm->Pen->Thick >> 1; rs = PenManagerForm->Pen->Thick - ls; 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->Thick; 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; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::DotCurveLocate(HDC dc, int x, int y, void *pData) { 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 = SelectObject(dc, hPen); ls = PenManagerForm->Pen->Thick >> 1; rs = PenManagerForm->Pen->Thick - ls; pw = PenManagerForm->Pen->Thick; 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->Thick; 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->Thick; 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); } } //---------------------------------------------------------------------------- void __fastcall TDrawForm::DrawDotCurveLocate(POINT First, POINT Second, POINT Third) { RECT rt, dist; int ls, rs; TPItemImage *Image = MainImageForm->iMainImage; ls = PenManagerForm->Pen->Thick >> 1; rs = PenManagerForm->Pen->Thick - ls; 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->Thick; 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; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::DotRectangleLocate(HDC dc, int x, int y, void *pData) { 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 = 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->Thick; switch (MainImageForm->CurrentUnit) { case uDot : eLength1->Text = l; break; case uInch: eLength1->Text = Format("%.2f", OPENARRAY(TVarRec, ((double)l / MainImageForm->CanvasInfor.DotsPerInch))); break; case uCm : eLength1->Text = Format("%.2f", OPENARRAY(TVarRec, ((double)l / MainImageForm->CanvasInfor.DotsPerInch * 2.54))); } } 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->Thick; ly = abs(ey - sy) + PenManagerForm->Pen->Thick; switch (MainImageForm->CurrentUnit) { case uDot : eLength1->Text = lx; eLength2->Text = ly; break; case uInch: eLength1->Text = Format("%.2f", OPENARRAY(TVarRec, ((double)lx / MainImageForm->CanvasInfor.DotsPerInch))); eLength2->Text = Format("%.2f", OPENARRAY(TVarRec, ((double)ly / MainImageForm->CanvasInfor.DotsPerInch))); break; case uCm : eLength1->Text = Format("%.2f", OPENARRAY(TVarRec, ((double)lx / MainImageForm->CanvasInfor.DotsPerInch * 2.54))); eLength2->Text = 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); } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::DrawDotRectangleLocate(RECT rc) { RECT rt, Src, Dst; int ls, rs; TPItemImage *Image = MainImageForm->iMainImage; ls = PenManagerForm->Pen->Thick >> 1; rs = PenManagerForm->Pen->Thick - 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->Thick; 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; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::RectangleLocate(HDC dc, int x, int y, void *pData) { 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 = SelectObject(dc, hPen); hOldBrush = 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); } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::DrawRectangleLocate(RECT rc) { RECT rt, Src, Dst; int ls, rs; TPItemImage *Image = MainImageForm->iMainImage; ls = PenManagerForm->Pen->Thick >> 1; rs = PenManagerForm->Pen->Thick - 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->Thick; 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, RectangleLocate, NULL); DrawLocate[Item].rtInvalidate = Src; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::EllipseLocate(HDC dc, int x, int y, void *pData) { 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 = SelectObject(dc, hPen); hOldBrush = SelectObject(dc, GetStockObject(NULL_BRUSH)); if (image->ZoomIn <= image->ZoomOut) { Ellipse(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 { 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); } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::DrawEllipseLocate(RECT rc) { RECT rt, Src, Dst; int ls, rs; TPItemImage *Image = MainImageForm->iMainImage; ls = PenManagerForm->Pen->Thick >> 1; rs = PenManagerForm->Pen->Thick - 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 - 10; Src.top = rt.top - 10; Src.right = rt.right + 10; Src.bottom = rt.bottom + 10; UnionRect(&Dst, &Src, &DrawLocate[Item].rtInvalidate); DrawLocate[Item].szPen = PenManagerForm->Pen->Thick; DrawLocate[Item].clPen = MainImageForm->Palette->Color[PaletteForm->DIB256Palette->ChoiceIndex]; DrawLocate[Item].ptFirst.x = rt.left + ls; DrawLocate[Item].ptFirst.y = rt.top + ls; DrawLocate[Item].ptSecond.x = rt.right - rs; DrawLocate[Item].ptSecond.y = rt.bottom - rs; Image->RectEditPaint(Dst, EllipseLocate, NULL); DrawLocate[Item].rtInvalidate = Src; } //--------------------------------------------------------------------------- // Public Function //--------------------------------------------------------------------------- void __fastcall TDrawForm::InitForm() { MainImageForm->DrawORStitch=true; int i; TPItemImage *Image = MainImageForm->iMainImage; ParentHeight = Parent->Height+20; ClientHeight = 106; Parent->Height = ParentHeight+ClientHeight; if (PenManagerForm->sbMask->Down) { if (Image->uBitmap->BitsPerPixel==8) { MainImageForm->OnSetHLine = MainImageForm->SetHLineMask8; if (PenManagerForm->chDelete->Checked) { MainImageForm->MaskPixel = 0x00; } else { MainImageForm->MaskPixel = 0x0F; } } else { if (PenManagerForm->chDelete->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)TaperLabel->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; 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(); } //--------------------------------------------------------------------------- void __fastcall TDrawForm::ReadIniFile() { TIniFile *DrawIni = NULL; AnsiString str; DrawIni = new TIniFile(DirectoryItem + "\\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; } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::WriteIniFile() { TIniFile *DrawIni = NULL; AnsiString str; DrawIni = new TIniFile(DirectoryItem + "\\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; } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::ExitForm(void) { WriteIniFile(); InitPointList(); delete PointList; iMainImageChange(); MainImageForm->DrawORStitch=false; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::view(void) { if (Item == TD_OUT) { sbOut->Down = true; lLineType->Visible = false; lFillType->Visible = false; lLength->Visible = false; lDotType->Visible = false; lDotLength->Visible = false; lDotSpace->Visible = false; lAngle->Visible = false; eLength1->Visible = false; eLength2->Visible = false; eAngle->Visible = false; eDotLength->Visible = false; eDotSpace->Visible = false; btnFirst->Visible = false; btnDelete->Visible = false; TaperLabel->Visible = false; StartSize->Visible = false; EndSize->Visible = false; StartSize->Enabled = false; EndSize->Enabled = false; sbInputMode1->Visible = false; sbInputMode2->Visible = false; ClientHeight = 106; Parent->Height = ParentHeight+ClientHeight; } else if (Item == TD_LINE) { sbLine->Down = true; lLineType->Visible = true; lLength->Visible = true; lLength->Caption = IDS_COMMON_LENGTH; lDotType->Visible = true; if(!isTaper)lDotType->Enabled = true; //lhskys Taper Àǰæ¿ì¸¦ ÆÄ¾Ç else lDotType->Enabled = false; //lhskys lAngle->Visible = true; eLength1->Visible = true; eLength2->Visible = false; eAngle->Visible = true; TaperLabel->Visible= true; if (TaperLabel->Caption == IDS_TAPERYES) { 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; } 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 } else if (Ltype[TD_LINE].sw == 1) { lDotType->Caption = IDS_DOT; lDotLength->Visible = true; lDotSpace->Visible = true; eDotLength->Visible = true; eDotSpace->Visible = true; lFillType->Visible = false; } btnFirst->Caption = IDS_COMMON_FIRSTPOINT; btnFirst->Visible = true; btnDelete->Visible = true; sbInputMode1->Visible = false; sbInputMode2->Visible = false; if (Line_type == 0) lLineType->Caption = IDS_COMMON_SEPARATELINE; else if (Line_type == 1) lLineType->Caption = IDS_COMMON_CONTINUOUSLINE; if (fill_not == 0) lFillType->Caption = AnsiString(IDS_COMMON_FILL) + " : " + AnsiString(IDS_COMMON_BUTTONNO); else if (fill_not == 1) lFillType->Caption = AnsiString(IDS_COMMON_FILL) + " : " + AnsiString(IDS_COMMON_BUTTONYES); ClientHeight = 231; Parent->Height = ParentHeight+ClientHeight; } else if (Item == TD_CURVE) { sbCurve->Down = true; lLineType->Visible = true; lFillType->Visible = false; lLength->Visible = false; lDotType->Visible = true; if(!isTaper)lDotType->Enabled = true; //lhskys Taper Àǰæ¿ì¸¦ ÆÄ¾Ç else lDotType->Enabled = false; //lhskys lAngle->Visible = false; eLength1->Visible = false; eLength2->Visible = false; eAngle->Visible = false; TaperLabel->Visible= true; if (TaperLabel->Caption == IDS_TAPERYES) { 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; } if (Ltype[TD_CURVE].sw == 0) { lDotType->Caption = IDS_SOLID; lDotLength->Visible = false; lDotSpace->Visible = false; eDotLength->Visible = false; eDotSpace->Visible = false; } else if (Ltype[TD_CURVE].sw == 1) { lDotType->Caption = IDS_DOT; lDotLength->Visible = true; lDotSpace->Visible = true; eDotLength->Visible = true; eDotSpace->Visible = true; } btnFirst->Visible = false; btnDelete->Visible = true; sbInputMode1->Visible = true; sbInputMode2->Visible = true; if (Curve_type == 0) lLineType->Caption = IDS_COMMON_SEPARATELINE; else if (Curve_type == 1) lLineType->Caption = IDS_COMMON_CONTINUOUSLINE; if (Curve_input == 0) sbInputMode1->Down = true; else if (Curve_input == 1) sbInputMode2->Down = true; ClientHeight = 231; Parent->Height = ParentHeight+ClientHeight; } else { lLineType->Visible = false; lFillType->Visible = true; lFillType->Enabled = true; //taper »ç¿ë½Ã ä¿ì±â ±ÝÁö ÇØÁ¦ lLength->Visible = true; lDotType->Visible = true; lDotType->Enabled = true; //taper »ç¿ë½Ã ½Ç¼±¸¸»ç¿ë ÇØÁ¦ lAngle->Visible = false; eLength1->Visible = true; TaperLabel->Visible= false; StartSize->Visible = false; EndSize->Visible = false; StartSize->Enabled = false; EndSize->Enabled = false; sbInputMode1->Visible = false; sbInputMode2->Visible = false; if (Item == TD_CIRCLE) { sbCircle->Down = true; lLength->Caption = IDS_RADIUS; eLength2->Visible = false; btnFirst->Caption = IDS_LASTCENTER; btnFirst->Visible = true; if(cirlastpoint)btnFirst->Enabled = false; else btnFirst->Enabled = true; btnDelete->Visible = false; } else if (Item == TD_ELLIP) { sbEllip->Down = true; lLength->Caption = IDS_AXIS; eLength2->Visible = true; btnFirst->Caption = IDS_LASTCENTER; btnFirst->Visible = true; if(elliplastpoint)btnFirst->Enabled = false; else btnFirst->Enabled = true; btnDelete->Visible = false; } else if (Item == TD_SQUR) { sbSquare->Down = true; lLength->Caption = IDS_COMMON_LENGTH; eLength2->Visible = false; btnFirst->Visible = false; btnFirst->Enabled = false; btnDelete->Visible = false; } else { sbRect->Down = true; lLength->Caption = IDS_COMMON_LENGTH; eLength2->Visible = true; btnFirst->Visible = false; btnDelete->Visible = false; } eAngle->Visible = false; if (Ltype[Item].sw == 0) { lDotType->Caption = IDS_SOLID; lDotLength->Visible = false; lDotSpace->Visible = false; eDotLength->Visible = false; eDotSpace->Visible = false; } else if (Ltype[Item].sw == 1) { lDotType->Caption = IDS_DOT; lDotLength->Visible = true; lDotSpace->Visible = true; eDotLength->Visible = true; eDotSpace->Visible = true; } if (fill_not == 0) lFillType->Caption = AnsiString(IDS_COMMON_FILL) + " : " + AnsiString(IDS_COMMON_BUTTONNO); else if (fill_not == 1) lFillType->Caption = AnsiString(IDS_COMMON_FILL) + " : " + AnsiString(IDS_COMMON_BUTTONYES); ClientHeight = 231; Parent->Height = ParentHeight+ClientHeight; } eDotLength->Text = Ltype[Item].value[0]; eDotSpace->Text = Ltype[Item].value[1]; step = 0; undos = 0; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::DrawMouseDown(TMouseButton Button, TShiftState Shift, int XD, int YD) { RECT rect; int pw, ra, lsx, lsy, lex, ley, ww, hh; bool Mbmp; COLORREF c; TPItemImage *Image = MainImageForm->iMainImage; int s_size, e_size; if (PenManagerForm->spread_sw[4] == 0 && PenManagerForm->aspread == true )return; if (Button==mbMiddle || (Shift.Contains(ssShift) && Button==mbLeft)) return; c = PaletteForm->DIB256Palette->GetFGCOLORREF(Image->uBitmap->BitsPerPixel); pw = PenManagerForm->Pen->Thick + 10; BtnClick = true; rect = Rect(0, 0, Image->uBitmap->Width, Image->uBitmap->Height); switch (Item) { case TD_OUT : if(pw > 50){ ShowMessage(IDS_MESSAGE_OUTLINEPENSIZEOVER); return; } if (PenManagerForm->sbMask->Down) { // MainImageForm->UndoSave(UK_MASK, rect); MainImageForm->UndoSave(UK_MASK, Rect(0,0,0,0)); //by linuxjun if (Image->uBitmap->BitsPerPixel == 8) { MainImageForm->UndoSave(UK_PATTERN, Rect(0,0,0,0)); //by linuxjun outline(XD, YD); // Undo->Read(); //BeConverted by linuxjun Don't Forget!! Undo_Method MainImageForm->Undo->UndoRead(); //by jeegeo ::RepaintImage(); } 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 (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 (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->Text == 0){// || eDotSpace->Text == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); iMainImageChange(); if (Line_type == 1 || Curve_type == 1) { InitPointList(); step = 0; undos = 0; xkey = 1; } 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 (Ltype[TD_LINE].sw == 0) { //isw != 0 separatel = 0; //lhskys ²÷¾îÁø Á¡¼± È®ÀÎ... Lex = XD; Ley = YD; LenAng_check(XD, YD); 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; //============================================================================== }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); 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; } //============================================================================== break; case TD_SQUR : if (isw == 0) { 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->Text == 0){// || eDotSpace->Text == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); 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 (StrToInt(eLength1->Text) == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); return; } }else if(MainImageForm->CurrentUnit == uInch) { if (StrToFloat(eLength1->Text) == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); return; } }else if (MainImageForm->CurrentUnit == uCm) { if (StrToFloat(eLength1->Text) == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); 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->Thick; 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; if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(PenManagerForm->sbMask->Down, true); } break; case TD_RECT : if (isw == 0) { 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->Text == 0){// || eDotSpace->Text == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); 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 (StrToInt(eLength1->Text) == 0 || StrToInt(eLength2->Text) == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); return; } }else if(MainImageForm->CurrentUnit == uInch) { if (StrToFloat(eLength1->Text) == 0 || StrToFloat(eLength2->Text) == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); return; } }else if (MainImageForm->CurrentUnit == uCm) { if (StrToFloat(eLength1->Text) == 0 || StrToFloat(eLength2->Text) == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); 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->Thick; 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; dotted_rectangle(pmCopy, Ltype[TD_RECT].value, c); } step = 0; isw = 0; if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(PenManagerForm->sbMask->Down, true); } break; case TD_CIRCLE : if (isw == 0) { if (Ltype[TD_CIRCLE].sw == 1) { if(eDotLength->Text == 0){// || eDotSpace->Text == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); return; } } if (step == 0) { Csx = XD; Csy = YD; Lsx = Csx; Lsy = Csy; cirlast.x = Csx; cirlast.y = Csy; cirlastpoint = false; btnFirst->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 (StrToInt(eLength1->Text) == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); return; } }else if(MainImageForm->CurrentUnit == uInch) { if (StrToFloat(eLength1->Text) == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); return; } }else if (MainImageForm->CurrentUnit == uCm) { if (StrToFloat(eLength1->Text) == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); return; } } Tradius = Radius - pw / 2.0; Csx = XD; Csy = YD; cirlast.x = Csx; cirlast.y = Csy; cirlastpoint = false; btnFirst->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; if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(PenManagerForm->sbMask->Down, true); } break; case TD_ELLIP : if (isw == 0) { if (Ltype[TD_CIRCLE].sw == 1) { if(eDotLength->Text == 0){// || eDotSpace->Text == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); return; } } if (step == 0) { Csx = XD; Csy = YD; Lsx = Csx; Lsy = Csy; elliplast.x = Csx; elliplast.y = Csy; elliplastpoint = false; btnFirst->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 (StrToInt(eLength1->Text) == 0 || StrToInt(eLength2->Text) == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); return; } }else if(MainImageForm->CurrentUnit == uInch) { if (StrToFloat(eLength1->Text) == 0 || StrToFloat(eLength2->Text) == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); return; } }else if (MainImageForm->CurrentUnit == uCm) { if (StrToFloat(eLength1->Text) == 0 || StrToFloat(eLength2->Text) == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); 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; btnFirst->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; 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->Text == 0){// || eDotSpace->Text == 0){ ShowMessage(IDS_MESSAGE_NOTZERO); 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(); } //--------------------------------------------------------------------------- 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->Thick; switch (Item) { case TD_LINE : if (isw == 0) { 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->Text == 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) { if (Ltype[TD_LINE].sw == 0){ Lex = XD; Ley = YD; LenAng_check(XD, YD); DrawLineLocate(Point(Lsx, Lsy), Point(Lex, Ley)); LengthAngle(); //============================================================================== }else if(Ltype[TD_LINE].sw == 1){ //lhskys z Ű Á¡¼±À϶§ if(eDotLength->Text == 0)return; Tstitch.l[1].ex = XD; Tstitch.l[1].ey = YD; LenAng_check(XD, 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(); //============================================================================== } } break; case TD_SQUR : if (isw == 0) { 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 (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 (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 (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->Text == 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(int Key) { if (Key == 120 || Key == 88) { // 120: x 880: X down , 122 : z 900: Z down 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 == 122 || Key == 90) && ((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; } } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::iMainImageKeyUp(int Key) { if (Key == 90) { // 88 : x 90 : z if (Item == TD_LINE && (Ltype[TD_LINE].sw == 0 || Ltype[TD_LINE].sw == 1 )) { isw = 0; Lsw = 0; Asw = 0; } } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::iMainImageChange(void) { MainImageForm->iMainImage->Repaint(); } //--------------------------------------------------------------------------- void __fastcall TDrawForm::FGChange(int Value) { PenManagerForm->PenShapeChange(Value); iMainImageChange(); } //--------------------------------------------------------------------------- void __fastcall TDrawForm::InitPointList() { TBackupPointData *bpd; while(PointList->Count) { bpd = (TBackupPointData *) PointList->Last(); PointList->Remove(bpd); delete bpd; } btnDelete->Enabled = false; btnFirst->Enabled = false; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::AddPointList(int x, int y, COLORREF c) { 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 = eDotSpace->Text; bpd->Dotlength = 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 = StrToInt(PenManagerForm->eGrade->Text); //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->Thick; //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); } btnDelete->Enabled = PointList->Count > 1; btnFirst->Enabled = PointList->Count > 1; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::btnDeleteClick(TObject *Sender) { Screen->Cursor=crHourGlass; int i, cnt, dot, solid; COLORREF c; TBackupPointData *bpd; btndelete = 1; RECT rect; if (Item == TD_CURVE && Curve_input && step==1) { if(PointList->Count < 2) return; 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; btnDelete->Enabled = false; btnFirst->Enabled = false; iMainImageChange(); Screen->Cursor = crDefault; 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 lFillType->Caption = AnsiString(IDS_COMMON_FILL) + " : " + IDS_COMMON_BUTTONNO; 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->eGrade->Text = bpd->grade; //lhskys Taper À϶§ }else { c = bpd->col; PenManagerForm->Pen->Thick = 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->Thick = PenManagerForm->sePenSize->Value; //lhskys ÇÑÁ¡µÚ·Î°¡ ¿Ï·áµÇ¸é ÃÖÁ¾°ªÀ¸·Î ´Ù½Ã ±×¸®±â À§ÇØ... } else { lDotType->Caption = IDS_DOT; lDotLength->Visible = true; lDotSpace->Visible = true; eDotLength->Visible = true; eDotSpace->Visible = true; lFillType->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->Text = bpd->Dotlength; eDotSpace->Text = bpd->Dotspace; c = bpd->col; PenManagerForm->Pen->Thick = 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; 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->eGrade->Text = bpd->grade; //lhskys Taper À϶§ }else { c = bpd->col; PenManagerForm->Pen->Thick = bpd->pen_size; //lhskys ÇÑÁ¡µÚ·Î ÇØ¼­ ´Ù½Ã ±×·ÁÁÙ¶§ ¹é¾÷ÇØµÐ size·Î ±×¸°´Ù.... PenManagerForm->sePenSize->Value = PenManagerForm->Pen->Thick; } 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->Thick = PenManagerForm->sePenSize->Value; //lhskys ÇÑÁ¡µÚ·Î°¡ ¿Ï·áµÇ¸é ÃÖÁ¾°ªÀ¸·Î ´Ù½Ã ±×¸®±â À§ÇØ... } else { lDotType->Caption = IDS_DOT; lDotLength->Visible = true; lDotSpace->Visible = true; eDotLength->Visible = true; eDotSpace->Visible = true; lFillType->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->Text = bpd->Dotlength; eDotSpace->Text = 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->Thick = 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->Thick = bpd->pen_size; PenManagerForm->sePenSize->Value = PenManagerForm->Pen->Thick; } if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(PenManagerForm->sbMask->Down, false); IsBackpoint = false; ::RepaintImage(); Screen->Cursor = crDefault; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::FillInPolygon() { 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); 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->chDelete->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++, MP++) { 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++, MP++) { 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++, MP++) { 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++, MP++) { 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; //by jeegeo ::RepaintImage(); } //--------------------------------------------------------------------------- void __fastcall TDrawForm::TaperLabelClick(TObject *Sender) { if (isTaper) { TaperLabel->Caption = IDS_TAPERNO; isTaper = false; lDotType->Enabled = true; //taper »ç¿ë½Ã ½Ç¼±¸¸»ç¿ë ÇØÁ¦ lFillType->Enabled = true; //taper »ç¿ë½Ã ä¿ì±â ±ÝÁö ÇØÁ¦ //===========================================¼±²÷±â iMainImageChange(); InitPointList(); step = 0; undos = 0; //=========================================== } else { TaperLabel->Caption = IDS_TAPERYES; isTaper = true; Ltype[Item].sw = 0; lDotType->Enabled = false; //taper »ç¿ë½Ã ½Ç¼±¸¸»ç¿ë fill_not = 0; lFillType->Enabled = false; //taper »ç¿ë½Ã ä¿ì±â ±ÝÁö //===========================================¼±²÷±â iMainImageChange(); InitPointList(); step = 0; undos = 0; //=========================================== } view(); } //--------------------------------------------------------------------------- void __fastcall TDrawForm::StartSizeClick(TObject *Sender) //lhskys taper ¼ýÀڹٲٱâ { StartSize->SetFocus(); StartSize->SelectAll(); } //--------------------------------------------------------------------------- void __fastcall TDrawForm::EndSizeClick(TObject *Sender) //lhskys taper ¼ýÀڹٲٱâ { EndSize->SetFocus(); EndSize->SelectAll(); } //--------------------------------------------------------------------------- void __fastcall TDrawForm::StartSizeChange(TObject *Sender) //lhskys taper ¼ýÀڹٲٱâ { if (StartSize->Text.Length()>0) { if (StartSize->Value > 50) StartSize->Value = 50; if (StartSize->Value < 1) StartSize->Value = 1; PenManagerForm->sePenSize->Value = StartSize->Value; } } //--------------------------------------------------------------------------- void __fastcall TDrawForm::EndSizeChange(TObject *Sender) //lhskys taper ¼ýÀڹٲٱâ { if (EndSize->Text.Length()>0) { if (EndSize->Value > 50) EndSize->Value = 50; if (EndSize->Value < 1) EndSize->Value = 1; // PenManagerForm->sePenSize->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->Text = Format("%3.1f", OPENARRAY(TVarRec, (p))); lx = abs(dx); ly = abs(dy); 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))); } /* 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) { TEdit *s; if(swLength || swAngle){ iMainImageChange(); s = (TEdit *)Sender; try{ if (s == eLength2) { if (Item != TD_LINE) { Lsx = -1; Lex = -1; Lsy = -1; Ley = -1; Csx = -1; Csy = -1; } isw = 1; Lsw = 1; InputNumber(); } else if (s == eDotLength) { Dsw = 1; InputDotNumber(); } else if (s == eDotSpace) { Dsw = 2; InputDotNumber(); } }catch(EConvertError &ec){ } } swLength = false; swAngle = false; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::eLength1Change(TObject *Sender) { TEdit *s; double dtemp,itemp; if(swLength || swAngle){ iMainImageChange(); s = (TEdit *)Sender; try{ if (s == eLength1) { if (Item != TD_LINE) { Lsx = -1; Lex = -1; Lsy = -1; Ley = -1; Csx = -1; Csy = -1; } isw = 1; Lsw = 1; if(eLength1->Text=="")eLength1->Text = 1; InputNumber(); } else if (s == eAngle) { isw = 1; Asw = 1; if(eAngle->Text=="")eAngle->Text = 1; InputNumber(); } }catch(EConvertError &ec){ } } swLength = false; swAngle = false; } //--------------------------------------------------------------------------- void __fastcall TDrawForm::sbInputModeClick(TObject *Sender) { TSpeedButton *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; } } } //---------------------------------------------------------------------------