//--------------------------------------------------------------------------- #include #include #pragma hdrstop #include "FullView.h" #include "Grid_F.h" #include "MainImage.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "TPStretchImage" #pragma resource "*.dfm" //--------------------------------------------------------------------------- #define IDS_FORMCAPTION StringTable[0] #define IDS_TAPELINE StringTable[1] #define IDS_SUPER StringTable[2] #define IDS_SUPER_OFF StringTable[3] #define IDS_SUPER_NORMAL StringTable[4] #define IDS_SUPER_GAUZE StringTable[5] #define IDS_SUPER_OVERLAP StringTable[6] TFullViewForm *FullViewForm; //--------------------------------------------------------------------------- __fastcall TFullViewForm::TFullViewForm(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TFullViewForm::FormClose(TObject *Sender, TCloseAction &Action) { ExitForm(); Visible = false; if (FOnUpdateMenu) FOnUpdateMenu(Sender); } //--------------------------------------------------------------------------- void __fastcall TFullViewForm::FormCreate(TObject *Sender) { TGrid g; //======================================================= StringTable.Create(DirectoryBin, Language, "FullView"); SetFont(); Caption = IDS_FORMCAPTION; sbGrid->Caption = IDS_COMMON_GRID; Label2->Caption = IDS_TAPELINE; stTapeline->Caption = IDS_COMMON_OFF; Label1->Caption = IDS_SUPER; stSuper->Caption = IDS_SUPER_OFF; LabelZoom->Caption = IDS_COMMON_ZOOM; //======================================================= TIniFile *IniFile = new TIniFile(DirectoryItem+"\\Environment.ini"); if (IniFile) { GridColor = IniFile->ReadInteger("Grid", "Color", clBlack); Grid.Unit = IniFile->ReadInteger("Grid", "Unit", 0); Grid.X = IniFile->ReadFloat("Grid", "GapX", 1.0); Grid.Y = IniFile->ReadFloat("Grid", "GapY", 1.0); GridMark = IniFile->ReadInteger("Grid", "LinesPerSection", 0); GridMarkColor = IniFile->ReadInteger("Grid", "SectionColor", clBlack); delete IniFile; } else { GridColor = clBlack; Grid.Unit = 0; Grid.X = 1.0; Grid.Y = 1.0; GridMark = 0; GridMarkColor = clBlack; } Tapeline = 0; Super = sOff; bRatio = false; ratio = 1; bDraw = false; FOverlapDensity = 32; FOnUpdateMenu = NULL; OverlapBitmap = OverlapBack = NULL; #if defined(WEAVE) || defined(PILE) Label1->Enabled = false; stSuper->Enabled = false; #endif } //--------------------------------------------------------------------------- void __fastcall TFullViewForm::FormDestroy(TObject *Sender) { ExitOverlapChange(); } //--------------------------------------------------------------------------- void __fastcall TFullViewForm::FormPaint(TObject *Sender) { if(MainImageForm)Image->OnPaint = MainImageForm->iMainImage->FullViewPaint; } //--------------------------------------------------------------------------- void __fastcall TFullViewForm::FormResize(TObject *Sender) { if (MainImage) { if (MainImage->Bitmap->Width>0 && MainImage->Bitmap->Height>0) { RatioCalculate(); View(); } } } //--------------------------------------------------------------------------- void __fastcall TFullViewForm::ImageMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { MainImageForm->iMainImageChange(); if (Button==mbLeft) { FocusPosition(X, Y); InFocus = true; } } //--------------------------------------------------------------------------- void __fastcall TFullViewForm::ImageMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { if (InFocus) { FocusPosition(X, Y); } } //--------------------------------------------------------------------------- void __fastcall TFullViewForm::ImageMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { if (InFocus) { FocusPosition(X, Y); MainImageForm->iMainImage->Repaint(); InFocus = false; } } //--------------------------------------------------------------------------- void __fastcall TFullViewForm::ImagePaintEnd(TObject *Sender) { eBox(rcView); bDraw = true; if(MainImageForm->iMainImage) MainImageForm->iMainImage->OnFullViewRectPaint=FullViewRectPaint; } //--------------------------------------------------------------------------- void __fastcall TFullViewForm::sbGridClick(TObject *Sender) { TGridForm *Form = NULL; TTexpiaBitmap *bm1 = NULL, *bm2 = NULL; Byte *bp1, *bp2, mm; if ((Form = new TGridForm(NULL)) == NULL) goto fail; Form->DotsPerInch = MainImageForm->CanvasInfor.DotsPerInch; Form->GridColor = MainImage->GridColor; Form->Gap = Grid; Form->LinesPerSection = MainImage->GridMark; Form->SectionColor = MainImage->GridMarkColor; #ifndef dogtest Form->Unit = MainImageForm->CurrentUnit; #endif if (Form->ShowModal()==mrOk) { GridColor = Form->GridColor; Grid = Form->Gap; GridMark = Form->LinesPerSection; GridMarkColor = Form->SectionColor; SetGrid(); MainImageForm->iMainImageChange(); } delete Form; return; fail: if (Form) { if (bm1) { bm1->StopScanLine(); delete bm1; } if (bm2) delete bm2; delete Form; } EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TFullViewForm::stTapelineClick(TObject *Sender) { MainImageForm->iMainImageChange(); ExitLocate(); switch (Tapeline) { case 0: Tapeline = 3; stTapeline->Caption = IDS_COMMON_OBLIQUE; break; case 1: Tapeline = 2; stTapeline->Caption = IDS_COMMON_VERTICAL; break; case 2: Tapeline = 0; stTapeline->Caption = IDS_COMMON_OFF; break; case 3: Tapeline = 1; stTapeline->Caption = IDS_COMMON_HORIZONTAL; break; } } //--------------------------------------------------------------------------- void __fastcall TFullViewForm::stSuperClick(TObject *Sender) { switch (Super) { case sOff: Super = sNormal; stSuper->Caption = IDS_SUPER_NORMAL; break; case sNormal: Super = sGauze; stSuper->Caption = IDS_SUPER_GAUZE; break; case sGauze: Super = sOverlap; stSuper->Caption = IDS_SUPER_OVERLAP; tbOverlap->Visible = true; eOverlap->Visible = true; break; case sOverlap: Super = sOff; stSuper->Caption = IDS_SUPER_OFF; tbOverlap->Visible = false; eOverlap->Visible = false; break; } ExitOverlapChange(); if (FOnSuperChange) FOnSuperChange(Sender); } //--------------------------------------------------------------------------- void __fastcall TFullViewForm::tbOverlapChange(TObject *Sender) { eOverlap->Text = tbOverlap->Position; FOverlapDensity = (tbOverlap->Position / 100.0) * 63.0; #if defined(TEXTILE) && !defined(CARPET) MainImageForm->OverlapChange(); #endif MainImageForm->iMainImageChange(); } //--------------------------------------------------------------------------- void __fastcall TFullViewForm::eOverlapKeyPress(TObject *Sender, char &Key) { TEdit *s; s = (TEdit *)Sender; if (Key == 13) { if (0 > StrToInt(s->Text)) { s->Text = "0"; } if (100 < StrToInt(s->Text)) { s->Text = "100"; } tbOverlap->Position = StrToInt(s->Text); FOverlapDensity = (tbOverlap->Position / 100.0) * 63.0; #if defined(TEXTILE) && !defined(CARPET) MainImageForm->OverlapChange(); #endif MainImageForm->iMainImageChange(); } } //--------------------------------------------------------------------------- void __fastcall TFullViewForm::eOverlapMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { TEdit *s; s = (TEdit *)Sender; s->SetFocus(); s->SelectAll(); } //--------------------------------------------------------------------------- void __fastcall TFullViewForm::TrackBarChange(TObject *Sender) { switch (TrackBar->Position) { case 0: MainImageForm->ZoomChange(1, 16); TrackBar->Hint = "1/16"; break; case 1: MainImageForm->ZoomChange(1, 12); TrackBar->Hint = "1/12"; break; case 2: MainImageForm->ZoomChange(1, 8); TrackBar->Hint = "1/8"; break; case 3: MainImageForm->ZoomChange(1, 6); TrackBar->Hint = "1/6"; break; case 4: MainImageForm->ZoomChange(1, 4); TrackBar->Hint = "1/4"; break; case 5: MainImageForm->ZoomChange(1, 3); TrackBar->Hint = "1/3"; break; case 6: MainImageForm->ZoomChange(1, 2); TrackBar->Hint = "1/2"; break; case 7: MainImageForm->ZoomChange(2, 3); TrackBar->Hint = "2/3"; break; case 8: MainImageForm->ZoomChange(1, 1); TrackBar->Hint = "1"; break; case 9: MainImageForm->ZoomChange(3, 2); TrackBar->Hint = "3/2"; break; case 10: MainImageForm->ZoomChange(2, 1); TrackBar->Hint = "2"; break; case 11: MainImageForm->ZoomChange(3, 1); TrackBar->Hint = "3"; break; case 12: MainImageForm->ZoomChange(4, 1); TrackBar->Hint = "4"; break; case 13: MainImageForm->ZoomChange(6, 1); TrackBar->Hint = "6"; break; case 14: MainImageForm->ZoomChange(8, 1); TrackBar->Hint = "8"; break; case 15: MainImageForm->ZoomChange(12, 1); TrackBar->Hint = "12"; break; case 16: MainImageForm->ZoomChange(16, 1); TrackBar->Hint = "16"; break; } #if defined(PILE) if (FOnChangeZoom) FOnChangeZoom(); #endif } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- // Private Method //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- void __fastcall TFullViewForm::eBox(TRect r) { TPenMode pm; TColor cl; TBrushStyle bs; #ifdef TPDEBUG if (Image==NULL) { SHOWDEBUG; } if (Image->Canvas==NULL) { SHOWDEBUG; } #endif if (r.Right-r.Left<=0 || r.Bottom-r.Top<=0) return; pm = Image->Canvas->Pen->Mode; cl = Image->Canvas->Pen->Color; bs = Image->Canvas->Brush->Style; Image->Canvas->Pen->Mode = pmXor; Image->Canvas->Pen->Color = clWhite; Image->Canvas->Brush->Style = bsClear; Image->Canvas->Rectangle(r.Left, r.Top, r.Right, r.Bottom); Image->Canvas->Pen->Mode = pm; Image->Canvas->Pen->Color = cl; Image->Canvas->Brush->Style = bs; } //--------------------------------------------------------------------------- void __fastcall TFullViewForm::FocusPosition(int X, int Y) { int mx, my, dx, dy; if (MainImage) { if (bDraw) { eBox(rcView); bDraw = false; } if (X<0) X = 0; else if (X>Image->Width) X = Image->Width; if (Y<0) Y = 0; else if (Y>Image->Height) Y = Image->Height; mx = MainImage->Width*MainImage->ZoomOut/MainImage->ZoomIn; if (mx>MainImage->Bitmap->Width) mx = MainImage->Bitmap->Width; if (X<10) { dx = 0; } else if (X>Image->Width-10) { dx = MainImage->Bitmap->Width-mx; } else { if (Image->Width != 20) { // Division by Zero ¿¡·¯ ¼öÁ¤ - by monkman (2009.04.06) dx = (MainImage->Bitmap->Width-mx)*(X-10)/(Image->Width-20); } else { dx = (MainImage->Bitmap->Width-mx)*(X-10); } } mx = bRatio ? dx*ratio : dx/ratio; my = MainImage->Height*MainImage->ZoomOut/MainImage->ZoomIn; if (my>MainImage->Bitmap->Height) my = MainImage->Bitmap->Height; if (MainImage->Bitmap->CoordinateSystem==csTopLeft) { if (Y<10) { dy = 0; } else if (Y>Image->Height-10) { dy = MainImage->Bitmap->Height-my; } else { if (Image->Height != 20) { // Division by Zero ¿¡·¯ ¼öÁ¤ - by monkman (2009.04.06) dy = (MainImage->Bitmap->Height-my)*(Y-10)/(Image->Height-20); } else { dy = (MainImage->Bitmap->Height-my)*(Y-10); } } my = bRatio ? dy*ratio : dy/ratio; rcView = Rect(mx, my, mx+ViewSize.x, my+ViewSize.y); } else { if (Y<10) { dy = MainImage->Bitmap->Height-my; } else if (Y>Image->Height-10) { dy = 0; } else { if (Image->Height != 20) { // Division by Zero ¿¡·¯ ¼öÁ¤ - by monkman (2009.04.06) dy = (MainImage->Bitmap->Height-my)*(Image->Height-Y-10)/(Image->Height-20); } else { dy = (MainImage->Bitmap->Height-my)*(Image->Height-Y-10); } } my = bRatio ? dy*ratio : dy/ratio; rcView = Rect(mx, Image->Height-my-ViewSize.y, mx+ViewSize.x, Image->Height-my); } eBox(rcView); bDraw = true; if (InFocus) MainImage->SetPosition(dx, dy); } } //--------------------------------------------------------------------------- void __fastcall TFullViewForm::ExitLocate() { if (Tapeline>0) { if (step>0) { #ifndef dogtest MainImageForm->DrawLineLocate(First, Second,0); MainImageForm->TempLabel->Visible = false; #endif IsDraw = false; MainImageForm->iMainImage->OnPaintLocate = NULL;/////////////////by jeegeo step = 0; } } } //--------------------------------------------------------------------------- /* void TFullViewForm::WMEXITSIZEMOVE(TMessage &msg) { if ((Left <= MainForm->FullViewFormPos.x + 100) && (Left >= MainForm->FullViewFormPos.x - 100)) { if ((Top <= MainForm->FullViewFormPos.y + 100) && (Top >= MainForm->FullViewFormPos.y - 100)) { Top = MainForm->FullViewFormPos.y; Left = MainForm->FullViewFormPos.x; } } } */ //--------------------------------------------------------------------------- void __fastcall TFullViewForm::RatioCalculate() { int width = MainImage->Bitmap->Width, height = MainImage->Bitmap->Height; if (MainImage) { ratio = 1; if (Panel->Width-8Height-8Width-8>=width/ratio && Panel->Height-8>=height/ratio) { break; } ratio++; } bRatio = false; } else { while (true) { if (Panel->Width-8Height-8SetZoom(ratio, 1); Image->Width = width*ratio; Image->Height = height*ratio; ViewSize.x = MainImage->Width*MainImage->ZoomOut/MainImage->ZoomIn*ratio; ViewSize.y = MainImage->Height*MainImage->ZoomOut/MainImage->ZoomIn*ratio; } else { Image->SetZoom(1, ratio); Image->Width = width/ratio; Image->Height = height/ratio; ViewSize.x = MainImage->Width*MainImage->ZoomOut/MainImage->ZoomIn/ratio; ViewSize.y = MainImage->Height*MainImage->ZoomOut/MainImage->ZoomIn/ratio; } if (MainImage->Bitmap->CoordinateSystem==csTopLeft) { Image->Top = 4; } else { Image->Top = Panel->Height-Image->Height-4; } } } //--------------------------------------------------------------------------- void __fastcall TFullViewForm::SetGrid() { double x, y; if (MainImage) { switch (Grid.Unit) { case uInch: x = Grid.X*MainImageForm->CanvasInfor.DotsPerInch; y = Grid.Y*MainImageForm->CanvasInfor.DotsPerInch; break; case uCm: x = Grid.X*MainImageForm->CanvasInfor.DotsPerInch/2.54; y = Grid.Y*MainImageForm->CanvasInfor.DotsPerInch/2.54; break; default: x = Grid.X; y = Grid.Y; break; } MainImage->GridColor = GridColor; MainImage->GridGapX = x; MainImage->GridGapY = y; MainImage->GridMark = GridMark; MainImage->GridMarkColor = GridMarkColor; #ifndef dogtest if(MainImageForm) if (MainImageForm->CurrentUnit==uDot) { stGridX->Caption = Format("%f", OPENARRAY(TVarRec, (x))); stGridY->Caption = Format("%f", OPENARRAY(TVarRec, (y))); } else if (MainImageForm->CurrentUnit==uInch) { stGridX->Caption = Format("%f", OPENARRAY(TVarRec, (x/MainImageForm->CanvasInfor.DotsPerInch))); stGridY->Caption = Format("%f", OPENARRAY(TVarRec, (y/MainImageForm->CanvasInfor.DotsPerInch))); } else if (MainImageForm->CurrentUnit==uCm) { stGridX->Caption = Format("%f", OPENARRAY(TVarRec, (2.54*x/MainImageForm->CanvasInfor.DotsPerInch))); stGridY->Caption = Format("%f", OPENARRAY(TVarRec, (2.54*y/MainImageForm->CanvasInfor.DotsPerInch))); } #endif } } //--------------------------------------------------------------------------- void __fastcall TFullViewForm::FullViewRectPaint(HDC dcMemV, int sx, int sy, int pw, int ph){ int vw = pw*MainImageForm->iMainImage->ZoomIn/MainImageForm->iMainImage->ZoomOut; int vh = ph*MainImageForm->iMainImage->ZoomIn/MainImageForm->iMainImage->ZoomOut; int fvsx=Image->Width*sx/MainImageForm->iMainImage->Bitmap->Width; int fvsy=Image->Height*sy/MainImageForm->iMainImage->Bitmap->Height; int fvpw=Image->Width*pw/MainImageForm->iMainImage->Bitmap->Width; int fvph=Image->Height*ph/MainImageForm->iMainImage->Bitmap->Height; eBox(rcView); SetStretchBltMode(Image->Canvas->Handle, COLORONCOLOR); StretchBlt(Image->Canvas->Handle, fvsx, fvsy, fvpw, fvph, dcMemV,0,0,vw,vh, SRCCOPY); eBox(rcView); } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- // Public Method //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- void __fastcall TFullViewForm::InitForm(TPItemImage *ti, TTexpiaBitmap *tb) { if (Visible) { ExitForm(); InFocus = false; Tapeline = 0; MainImage = ti; if (MainImage) { Image->OnPaint = MainImage->FullViewPaint; FormResize(this); SetZoom(); SetGrid(); } else { Image->OnPaint = NULL; } Image->Repaint(); } } //--------------------------------------------------------------------------- void __fastcall TFullViewForm::ExitForm() { ExitLocate(); Tapeline = 0; stTapeline->Caption = IDS_SUPER_OFF; } //--------------------------------------------------------------------------- void __fastcall TFullViewForm::SetFont() { SetSmallFont(Font); SetSmallFont(stTapeline->Font); SetSmallFont(stSuper->Font); } //--------------------------------------------------------------------------- void __fastcall TFullViewForm::View() { int sx, sy, dy; Byte *src, *dst; WORD *swp, *dwp; bool ret; if (MainImage) { if (bDraw) { eBox(rcView); bDraw = false; } if (bRatio) { if (Panel->Width-8Bitmap->Width*ratio || Panel->Height-8Bitmap->Height*ratio) { RatioCalculate(); } sx = MainImage->PositionX*ratio; sy = MainImage->PositionY*ratio; } else { if (Panel->Width-8Bitmap->Width/ratio || Panel->Height-8Bitmap->Height/ratio) { RatioCalculate(); } sx = MainImage->PositionX/ratio; sy = MainImage->PositionY/ratio; } if (MainImage->Bitmap->CoordinateSystem==csTopLeft) { rcView = Rect(sx, sy, sx+ViewSize.x, sy+ViewSize.y); } else { rcView = Rect(sx, Image->Height-sy-ViewSize.y, sx+ViewSize.x, Image->Height-sy); } eBox(rcView); bDraw = true; Image->Invalidate(); } } //--------------------------------------------------------------------------- void __fastcall TFullViewForm::SetPositionX(int v) { int p; if (bDraw) { eBox(rcView); bDraw = false; } p = bRatio ? v*ratio : v/ratio; rcView.Left = p; rcView.Right = p+ViewSize.x; eBox(rcView); bDraw = true; } //--------------------------------------------------------------------------- void __fastcall TFullViewForm::SetPositionY(int v) { int p; if (MainImage) { if (bDraw) { eBox(rcView); bDraw = false; } if (MainImage->Bitmap->CoordinateSystem==csTopLeft) { p = bRatio ? v*ratio : v/ratio; rcView.Top = p; rcView.Bottom = p+ViewSize.y; } else { p = Image->Height-(bRatio ? v*ratio : v/ratio); rcView.Top = p-ViewSize.y; rcView.Bottom = p; } eBox(rcView); bDraw = true; } } //--------------------------------------------------------------------------- void __fastcall TFullViewForm::SetSize() { if (MainImage) { if (bRatio) { ViewSize.x = MainImage->Width*MainImage->ZoomOut/MainImage->ZoomIn*ratio; ViewSize.y = MainImage->Height*MainImage->ZoomOut/MainImage->ZoomIn*ratio; } else { ViewSize.x = MainImage->Width*MainImage->ZoomOut/MainImage->ZoomIn/ratio; ViewSize.y = MainImage->Height*MainImage->ZoomOut/MainImage->ZoomIn/ratio; } View(); } } //--------------------------------------------------------------------------- void __fastcall TFullViewForm::SetZoom() { if (MainImage) { if (bRatio) { ViewSize.x = MainImage->Width*MainImage->ZoomOut/MainImage->ZoomIn*ratio; ViewSize.y = MainImage->Height*MainImage->ZoomOut/MainImage->ZoomIn*ratio; } else { ViewSize.x = MainImage->Width*MainImage->ZoomOut/MainImage->ZoomIn/ratio; ViewSize.y = MainImage->Height*MainImage->ZoomOut/MainImage->ZoomIn/ratio; } switch (MainImage->ZoomIn) { case 1: switch (MainImage->ZoomOut) { case 1: TrackBar->Position = 8; break; case 2: TrackBar->Position = 6; break; case 3: TrackBar->Position = 5; break; case 4: TrackBar->Position = 4; break; case 6: TrackBar->Position = 3; break; case 8: TrackBar->Position = 2; break; case 12: TrackBar->Position = 1; break; case 16: TrackBar->Position = 0; break; } break; case 2: switch (MainImage->ZoomOut) { case 1: TrackBar->Position = 10; break; case 3: TrackBar->Position = 7; break; } break; case 3: switch (MainImage->ZoomOut) { case 1: TrackBar->Position = 11; break; case 2: TrackBar->Position = 9; break; } break; case 4: TrackBar->Position = 12; break; case 6: TrackBar->Position = 13; break; case 8: TrackBar->Position = 14; break; case 12: TrackBar->Position = 15; break; case 16: TrackBar->Position = 16; break; } View(); } } //--------------------------------------------------------------------------- void __fastcall TFullViewForm::iMainImageChange() { if (IsDraw) { #ifndef dogtest MainImageForm->TempLabel->Left = 0; MainImageForm->TempLabel->Top = 0; MainImageForm->TempLabel->Caption = ""; #endif IsDraw = false; MainImageForm->iMainImage->OnPaintLocate = NULL;/////////////////by jeegeo } } //--------------------------------------------------------------------------- bool __fastcall TFullViewForm::iMainImageMouseDown(TObject *Sender, int X, int Y) { if (Tapeline==0) return true; if (step>0) { switch (Tapeline) { case 1: Second = Point(X, First.y); break; case 2: Second = Point(First.x, Y); break; case 3: Second = Point(X, Y); break; } #ifndef dogtest MainImageForm->DrawLineLocate(First, Second); MainImageForm->TempLabel->Visible = false; #endif IsDraw = false; MainImageForm->iMainImage->OnPaintLocate = NULL;/////////////////by jeegeo step = 0; } else { First = Point(X, Y); Second = First; #ifndef dogtest MainImageForm->DrawLineLocate(First, Second); MainImageForm->TempLabel->Visible = true; #endif IsDraw = true; step = 1; } return false; } //--------------------------------------------------------------------------- bool __fastcall TFullViewForm::iMainImageMouseMove(TObject *Sender, int X, int Y) { int lx, ly, sx, sy; TSize size; double Len; if (MainImage) { if (Tapeline==0) return true; if (step>0) { if (IsDraw) { #ifndef dogtest MainImageForm->DrawLineLocate(First, Second); #endif } switch (Tapeline) { case 1: Second = Point(X, First.y); lx = Second.x-First.x; Len = abs(lx); #ifndef dogtest switch (MainImageForm->CurrentUnit) { case uInch: Len = Len/MainImageForm->CanvasInfor.DotsPerInch; break; case uCm: Len = 2.54*Len/MainImageForm->CanvasInfor.DotsPerInch; break; } MainImageForm->TempLabel->Caption = Format("%f", OPENARRAY(TVarRec, (Len))); size.cx = MainImageForm->TempLabel->Width; size.cy = MainImageForm->TempLabel->Height; #endif #ifndef dogtest sx = MainImage->BitmapToCanvasX(Second.x); sy = MainImage->BitmapToCanvasY(Second.y); #endif if (lx>0) sx = sx-5-size.cx; else sx = sx+5; if (sy>MainImage->Height/2) sy = sy-5-size.cy; else sy = sy+5; break; case 2: Second = Point(First.x, Y); ly = Second.y-First.y; Len = abs(ly); #ifndef dogtest switch (MainImageForm->CurrentUnit) { case uInch: Len = Len/MainImageForm->CanvasInfor.DotsPerInch; break; case uCm: Len = 2.54*Len/MainImageForm->CanvasInfor.DotsPerInch; break; } MainImageForm->TempLabel->Caption = Format("%f", OPENARRAY(TVarRec, (Len))); size.cx = MainImageForm->TempLabel->Width; size.cy = MainImageForm->TempLabel->Height; #endif #ifndef dogtest sx = MainImage->BitmapToCanvasX(Second.x); sy = MainImage->BitmapToCanvasY(Second.y); #endif if (sx>MainImage->Width/2) sx = sx-5-size.cx; else sx = sx+5; if (ly>0) sy = sy-5-size.cy; else sy = sy+5; break; case 3: Second = Point(X, Y); lx = Second.x-First.x; ly = Second.y-First.y; Len = sqrt(lx*lx+ly*ly); #ifndef dogtest switch (MainImageForm->CurrentUnit) { case uInch: Len = Len/MainImageForm->CanvasInfor.DotsPerInch; break; case uCm: Len = 2.54*Len/MainImageForm->CanvasInfor.DotsPerInch; break; } MainImageForm->TempLabel->Caption = Format("%f", OPENARRAY(TVarRec, (Len))); size.cx = MainImageForm->TempLabel->Width; size.cy = MainImageForm->TempLabel->Height; #endif #ifndef dogtest sx = MainImage->BitmapToCanvasX(Second.x); sy = MainImage->BitmapToCanvasY(Second.y); #endif if (ly>0) { sy = sy-5-size.cy; if (lx>0) sx = sx-5-size.cx; else sx = sx+5; } else { sy = sy+5; if (lx>0) sx = sx-5-size.cx; else sx = sx+5; } break; } #ifndef dogtest MainImageForm->TempLabel->Left = sx; MainImageForm->TempLabel->Top = sy; #endif #if defined(TEXTILE) #if defined(CARPET) MainImageForm->TempLabel->Update(); #else // MainImageForm->TempLabel->Update(); #endif #elif defined(KNIT) #ifndef dogtest MainImageForm->TempLabel->Update(); #endif #else MainImageForm->TempLabel->Update(); #endif #ifndef dogtest MainImageForm->DrawLineLocate(First, Second); #endif IsDraw = true; } } return false; } //--------------------------------------------------------------------------- void __fastcall TFullViewForm::UnitChange() { SetGrid(); } //--------------------------------------------------------------------------- void __fastcall TFullViewForm::ReadyToOverlapChange(TTexpiaBitmap *Bitmap, RECT r, Byte c, bool IsRepeat, TTexpiaBitmap *Mask) { RGBQUAD rgb[256]; HDC dcSrc = NULL, dcDst = NULL; int w, h; OverlapRect = r; preusecolor = c; ExitOverlapChange(); w = r.right - r.left; h = r.bottom - r.top; OverlapBitmap = new TTexpiaBitmap; if (Bitmap->BitsPerPixel == 8) { Bitmap->GetColors(0, 256, rgb); OverlapBitmap->Create(w, h, 8, rgb); } else { OverlapBitmap->Create(w, h, 24); } dcDst = OverlapBitmap->CreateDC(); if (IsRepeat) { if (Mask) { dcSrc = MainImageForm->iMainImage->Bitmap->CreateDC(); BitBlt(dcDst, 0, 0, w, h, dcSrc, r.left, r.top, SRCCOPY); MainImageForm->iMainImage->Bitmap->DeleteDC(dcSrc); dcSrc = Mask->CreateDC(); BitBlt(dcDst, 0, 0, w, h, dcSrc, r.left, r.top, SRCAND); Mask->DeleteDC(dcSrc); dcSrc = Bitmap->CreateDC(); BitBlt(dcDst, 0, 0, w, h, dcSrc, r.left, r.top, SRCPAINT); Bitmap->DeleteDC(dcSrc); } else { dcSrc = Bitmap->CreateDC(); BitBlt(dcDst, 0, 0, w, h, dcSrc, r.left, r.top, SRCCOPY); Bitmap->DeleteDC(dcSrc); } } else { dcSrc = Bitmap->CreateDC(); BitBlt(dcDst, 0, 0, w, h, dcSrc, 0, 0, SRCCOPY); Bitmap->DeleteDC(dcSrc); } OverlapBitmap->DeleteDC(dcDst); #if defined(TEXTILE) && !defined(CARPET) if (MainImageForm->iMainImage->IsBackGround() == 1) { OverlapBack = new TTexpiaBitmap; if (Bitmap->BitsPerPixel == 8) { OverlapBack->Create(w, h, 8, rgb); } else { OverlapBack->Create(w, h, 24); } dcDst = OverlapBack->CreateDC(); dcSrc = MainImageForm->iMainImage->BackGround->CreateDC(); BitBlt(dcDst, 0, 0, w, h, dcSrc, r.left, r.top, SRCCOPY); MainImageForm->iMainImage->BackGround->DeleteDC(dcSrc); OverlapBack->DeleteDC(dcDst); } #endif } //---------------------------------------------------------------------------- void __fastcall TFullViewForm::ExitOverlapChange() { ::doDestroy(OverlapBack); ::doDestroy(OverlapBitmap); } //---------------------------------------------------------------------------