//--------------------------------------------------------------------- #include #include #include #include #pragma hdrstop #include "MainImage1.h" #include "chart.h" #include "ColorLibrary_F.h" #include "FullView.h" #include "History.h" #include "Main.h" #include "MainMenu.h" #include "Palette.h" #include "ProtectCard.h" #include "UserColor_F.h" #include "YarnDesign_F.h" //lhskys YarnDesign ¿¡¼­ ¿£ÅÍ·Î ½ÇÇàÇϱâ À§ÇØ #include "Weaving_F.h" //lhskys Weaqving ¿¡¼­ ¿£ÅÍ·Î ½ÇÇàÇϱâ //--------------------------------------------------------------------- #pragma package(smart_init) #pragma link "TPImage" #pragma link "TPSelectImage" #pragma link "TPWeaveImage" #pragma link "TPRuler2D" #pragma resource "*.dfm" //--------------------------------------------------------------------- #define IDS_WZOOMIN StringTable[0] #define IDS_WZOOMOUT StringTable[1] #define IDS_WRULER StringTable[2] #define IDS_WFRONTBACK StringTable[3] #define IDS_MAINIMAGE_MESSAGE StringTable[4] #define IDS_WEIGHT StringTable[5] #define IDS_WAWIDTH StringTable[6] #define IDS_WEWIDTH StringTable[7] #define IDS_TOTAL StringTable[8] #define IDS_TOTAL1 StringTable[9] TMainImageForm *MainImageForm; int MainImageCount = 0; //--------------------------------------------------------------------- __fastcall TMainImageForm::TMainImageForm(TComponent *Owner) : TForm(Owner) { Number = MainImageCount; MainImageCount++; LineList = new TList; } //--------------------------------------------------------------------- void __fastcall TMainImageForm::FormActivate(TObject *Sender) { if (MainImageForm!=this) { MainMenuForm->ExitForm(); MainImageForm = this; } PaletteForm->UpdateForm(16); WorkAreaChange(); ReviewStatusBar(); } //--------------------------------------------------------------------- void __fastcall TMainImageForm::FormClose(TObject *Sender, TCloseAction &Action) { MainImageForm = NULL; Action = caFree; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::FormCloseQuery(TObject *Sender, bool &CanClose) { AnsiString msg, fn, ext; char *s; ext = ".wea"; if (Plan->Weaving) { msg = Format("Save changes to %s!", OPENARRAY (TVarRec,(FileName))); int Btn = MessageDlg(msg, mtWarning, TMsgDlgButtons()<SaveDialog->Execute()) { s = AnsiStrScan(MainForm->SaveDialog->FileName.c_str(), '.'); if (s==NULL) fn = MainForm->SaveDialog->FileName+ext; else fn = MainForm->SaveDialog->FileName; DirName = ExtractFileDir(fn); FileName = ExtractFileName(fn); SaveToFile(DirName, FileName, MainForm->CompressMethod); CanClose = true; } } else { SaveToFile(DirName, FileName, MainForm->CompressMethod); CanClose = true; } } else if (Btn == mrNo) { CanClose = true; } else { CanClose = false; } } else { CanClose = true; } if (CanClose) { if (FileExists(FileName)) { FileHistory->InsertHistory(DirName, ExtractFileName(FileName), 1, iMainImage->Bitmap->BitsPerPixel); } } MainMenuForm->ExitForm(); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::FormCreate(TObject *Sender) { #ifndef LOCK_CRYPKEY #ifndef LOCK_IFC ProtectCard->Check(); #endif #endif int unit; TIniFile *IniFile = new TIniFile(DirectoryItem+"\\Environment.ini"); if (IniFile) { unit = IniFile->ReadInteger("MainImage", "Unit", 0); delete IniFile; } //================================================= StringTable.Create(DirectoryItem, Language, "MainImage"); SetSmallFont(Font); SetSmallFont(TempLabel->Font); SetSmallFont(sbUnit->Font); sbZoomIn->Hint = IDS_WZOOMIN; sbZoomOut->Hint = IDS_WZOOMOUT; sbGrid->Hint = IDS_COMMON_GRID; sbRuler->Hint = IDS_WRULER; sbFrontBack->Hint = IDS_WFRONTBACK; //================================================= if ((WorkArea = new TPWorkArea(&(iMainImage->Bitmap)))==NULL) goto fail; if ((Palette = new TPalette)==NULL) goto fail; if ((Plan = new TPlan)==NULL) goto fail; MainImageForm = this; CanvasInfor.DotsPerInch = 160; CanvasInfor.SetExtFileOption(); if (unit == 0) { UnitChange(uCm); sbUnit->Caption = AnsiString(IDS_COMMON_UNIT) + " : Cm"; } else { UnitChange(uInch); sbUnit->Caption = AnsiString(IDS_COMMON_UNIT) + " : Inch"; } ApplyEnvironment(); ZoomChange(1, 1); PaletteForm->InitForm(Palette); ReviewStatusBar(); bChoiceExchange = false; return; fail: ::doDestroy(Plan); ::doDestroy(Palette); ::doDestroy(WorkArea); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::FormDestroy(TObject *Sender) { MainMenuForm->ExitForm(); ::doDestroy(Plan); ::doDestroy(Palette); ::doDestroy(WorkArea); FullViewForm->InitForm(NULL); delete LineList; MainImageForm = NULL; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::FormResize(TObject *Sender) { Ruler->Width = ClientWidth-ImageWeft->Width-PanelVert->Width-8; Ruler->Height = ClientHeight-ImageWarp->Height-PanelHorz->Height-8; if (sbRuler->Down) { Panel->Left = Ruler->Thick; Panel->Width = Ruler->Width-Ruler->Thick; Panel->Height = Ruler->Height-Ruler->Thick; ImageWarp->Left = Ruler->Thick; } else { Panel->Left = 0; Panel->Width = Ruler->Width; Panel->Height = Ruler->Height; ImageWarp->Left = 0; } ImageWarp->Width = Panel->Width; ImageWeft->Left = Ruler->Width+4; ImageWeft->Height = Panel->Height; PanelHorz->Top = Ruler->Top+Ruler->Height+4; PanelHorz->Width = ClientWidth-PanelVert->Width; PanelVert->Left = ImageWeft->Left+ImageWeft->Width+4; PanelVert->Height = ClientHeight-PanelHorz->Height; sbHorz->Width = PanelHorz->Width-sbHorz->Left-2; sbVert->Height = PanelVert->Height-sbVert->Top-2; iMainImage->SetPosition(); ImageWarp->SetPosition(); ImageWeft->SetPosition(); FullViewForm->SetSize(); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { if(TextureDesignForm) TextureDesignForm->FormKeyDown(this, Key, Shift); //Á¶Á÷¼³°è Æû ¿£ÅÍŰ½ÇÇà if (Key == 13 && MainMenuForm->YarnMakerStart == 1)YarnDesignForm->MakeButtonClick(this); //lhskys YarnDesign ¿¡¼­ ¿£ÅÍ·Î ½ÇÇàÇϱâ À§ÇØ if(WeavingForm) if (Key == 13 && WeavingForm->btnOK->Enabled)WeavingForm->btnOKClick(this); //lhskys Weaving ¿¡¼­ ¿£ÅÍ·Î ½ÇÇàÇϱâ int Ratio; if(Key == 65){ //'a' switch (iMainImage->ZoomIn) { case 1: switch (iMainImage->ZoomOut) { case 1: Ratio = 2 ; break; case 2: Ratio = 1; break; case 4: Ratio = 12; break; case 8: Ratio = 14; break; case 16: Ratio = 18; break; } break; case 2: Ratio = 4; break; case 4: Ratio = 8; break; case 8: Ratio = 16; break; } RatioZoom(Ratio); } if(Key == 83){ // 's' switch (iMainImage->ZoomIn) { case 1: switch (iMainImage->ZoomOut) { case 1: Ratio = 12 ; break; case 2: Ratio = 14; break; case 4: Ratio = 18; break; case 8: Ratio = 116; break; } break; case 2: Ratio = 1; break; case 4: Ratio = 2; break; case 8: Ratio = 4; break; case 16 : Ratio = 8; break; } RatioZoom(Ratio); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::iMainImageMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { if (Active) { DownState = true; if (Shift.Contains(ssCtrl) && Button==mbLeft) { MouseState = 1; iMainImage->Cursor = crHandPoint; ptFirst = Point(X, iMainImage->Bitmap->Height-1-Y); } else { if (MainMenuForm->iMainImageMouseDown(this, Button, Shift, X, Y)) { PaletteForm->iMainImageMouseDown(Sender, Button, Shift, X, Y); if (Button==mbLeft) { FullViewForm->iMainImageMouseDown(Sender, X, Y); } } } } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::iMainImageMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { POINT pt; COLORREF color; if (Active) { if (X > 0 && X <= iMainImage->Bitmap->Width && Y > 0 && Y <= iMainImage->Bitmap->Height) { CursorPosition.x = X; CursorPosition.y = iMainImage->Bitmap->Height-1-Y; if (MouseState) { ptSecond = Point(X, iMainImage->Bitmap->Height-1-Y); pt.x = ptSecond.x-ptFirst.x; pt.y = ptSecond.y-ptFirst.y; iMainImage->SetPosition(iMainImage->PositionX-pt.x, iMainImage->PositionY-pt.y); ptFirst.x = ptSecond.x-pt.x; ptFirst.y = ptSecond.y-pt.y; } else { if (DownState==false) { if (bChoiceExchange == false) { WORD yarn = Plan->GetYarn(X, CursorPosition.y, sbFrontBack->Down); if (yarn>0) { if (Plan->Yarn->Choice[(yarn>>11)&3].Color[(yarn>>8)&7]) { if (((yarn>>3)&0x1F) < Plan->Yarn->Choice[(yarn>>11)&3].Data->Colors) { PaletteForm->DIB256Palette->CursorIndex = Plan->Yarn->Choice[(yarn>>11)&3].Color[(yarn>>8)&7][(yarn>>3)&0x1F]->Index; } } } else { PaletteForm->DIB256Palette->CursorIndex = 1; } } } if (MainMenuForm->iMainImageMouseMove(this, Shift, X, Y)) { FullViewForm->iMainImageMouseMove(Sender, X, Y); PaletteForm->iMainImageMouseMove(Sender, Shift, X, Y); } } } } else iMainImage->Cursor = crDefault; if (iMainImage->Cross) { iMainImage->SetCrossPos(Point(X, Y)); static int oldx; static int oldy; RECT rc1,rc2; rc1.left = oldx ; rc1.right = oldx + 1; rc1.top = iMainImage->Parent->Top-30; rc1.bottom = iMainImage->Parent->Top + iMainImage->Parent->Height; rc2.left = iMainImage->Parent->Left-30; rc2.right = iMainImage->Parent->Left + iMainImage->Parent->Width; rc2.top = oldy ; rc2.bottom = oldy + 1; InvalidateRect(iMainImage->Parent->Handle, &rc1, false); InvalidateRect(iMainImage->Parent->Handle, &rc2, false); iMainImage->SetCrossPos(Point(X, Y)); iMainImage->Cursor = crNone; rc1.left = iMainImage->BitmapToCanvasX(X) ; rc1.right = iMainImage->BitmapToCanvasX(X) + 1; rc1.top = iMainImage->Parent->Top-30; rc1.bottom = iMainImage->Parent->Top + iMainImage->Parent->Height; rc2.left = iMainImage->Parent->Left-30; rc2.right = iMainImage->Parent->Left + iMainImage->Parent->Width; rc2.top = iMainImage->BitmapToCanvasY(Y) ; rc2.bottom = iMainImage->BitmapToCanvasY(Y) + 1; InvalidateRect(iMainImage->Parent->Handle, &rc1, false); InvalidateRect(iMainImage->Parent->Handle, &rc2, false); oldx = iMainImage->BitmapToCanvasX(X); oldy = iMainImage->BitmapToCanvasY(Y); } else iMainImage->Cursor = crCross; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::iMainImageMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { if (Active) { if (MouseState) { ptSecond = Point(X, iMainImage->Bitmap->Height-1-Y); iMainImage->SetPosition(iMainImage->PositionX-(ptSecond.x-ptFirst.x), iMainImage->PositionY-(ptSecond.y-ptFirst.y)); MouseState = 0; } else { MainMenuForm->iMainImageMouseUp(this, Button, Shift, X, Y); FullViewForm->View(); DownState = false; } } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::iMainImagePaint(TObject *Sender) { if (MainMenuForm->iMainImagePaint(this)) { PaletteForm->iMainImagePaint(); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::iMainImagePositionChange(TObject *Sender) { UpdateImage(); Ruler->StartX = iMainImage->PositionX; Ruler->StartY = iMainImage->PositionY; sbHorz->Position = iMainImage->PositionX; sbVert->Position = sbVert->Max-iMainImage->PositionY; FullViewForm->SetPositionX(iMainImage->PositionX); FullViewForm->SetPositionY(iMainImage->PositionY); ImageWarp->PositionX = iMainImage->PositionX; ImageWeft->PositionY = iMainImage->PositionY; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::sbUnitClick(TObject *Sender) { if (CurrentUnit==uCm) UnitChange(uInch); else if (CurrentUnit==uInch) UnitChange(uCm); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::sbHorzScroll(TObject *Sender, TScrollCode ScrollCode, int &ScrollPos) { iMainImageChange(); iMainImage->PositionX = sbHorz->Position; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::sbZoomInClick(TObject *Sender) { switch (iMainImage->ZoomIn) { case 1: switch (iMainImage->ZoomOut) { case 1: ZoomChange(2, 1); break; case 2: ZoomChange(1, 1); break; case 4: ZoomChange(1, 2); break; case 8: ZoomChange(1, 4); break; case 16: ZoomChange(1, 8); break; } break; case 2: ZoomChange(4, 1); break; case 4: ZoomChange(8, 1); break; case 8: ZoomChange(16, 1); break; } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::sbZoomOutClick(TObject *Sender) { switch (iMainImage->ZoomIn) { case 1: switch (iMainImage->ZoomOut) { case 1: ZoomChange(1, 2); break; case 2: ZoomChange(1, 4); break; case 4: ZoomChange(1, 8); break; case 8: ZoomChange(1, 16); break; } break; case 2: ZoomChange(1, 1); break; case 4: ZoomChange(2, 1); break; case 8: ZoomChange(4, 1); break; case 16: ZoomChange(8, 1); break; } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::sbGridClick(TObject *Sender) { iMainImageChange(); iMainImage->Grid = sbGrid->Down; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::sbRulerClick(TObject *Sender) { iMainImageChange(); FormResize(this); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::sbFrontBackClick(TObject *Sender) { bool dweft = false; if (MainImageForm->bChoiceExchange) { //ÀÓÀÇ·Î ½ÇÀ» ¹Ù²Ù°í weavingÀº ¾ÈÇÑ °æ¿ì if (Plan->Finish) { Plan->calc_weave(iMainImage->Bitmap); MainImageForm->bChoiceExchange = false; dweft = true; } else return; // ¸Þ½ÃÁö º¸³¾±î? ¸»±î? } if (sbFrontBack->Down) { Plan->DrawBack(iMainImage->Bitmap, Palette->ColorData[1]->RGB); } else { Plan->DrawFront(iMainImage->Bitmap, Palette->ColorData[1]->RGB); } DrawWarpBar(); if (dweft) { DrawWeftBar(); ::RepaintImage(); } else { iMainImage->Repaint(); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::sbVertScroll(TObject *Sender, TScrollCode ScrollCode, int &ScrollPos) { iMainImageChange(); iMainImage->PositionY = sbVert->Max-sbVert->Position; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::PopupMenu1Popup(TObject *Sender) { GetCursorPos(&ptScreen); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::ZoomClick(TObject *Sender) { if (Sender==Zoom1161) ZoomChange(1, 16, &ptScreen); else if (Sender==Zoom181) ZoomChange(1, 8, &ptScreen); else if (Sender==Zoom141) ZoomChange(1, 4, &ptScreen); else if (Sender==Zoom121) ZoomChange(1, 2, &ptScreen); else if (Sender==Zoom11) ZoomChange(1, 1, &ptScreen); else if (Sender==Zoom21) ZoomChange(2, 1, &ptScreen); else if (Sender==Zoom41) ZoomChange(4, 1, &ptScreen); else if (Sender==Zoom81) ZoomChange(8, 1, &ptScreen); else if (Sender==Zoom161) ZoomChange(16, 1, &ptScreen); } //--------------------------------------------------------------------------- // Private Function //--------------------------------------------------------------------------- void __fastcall TMainImageForm::SetCaption() { AnsiString fn = ExtractFileName(FileName); Caption = (DirName.Length()>0 ? DirName+"\\"+ fn: fn); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::UnitChange(TUnit unit) { CurrentUnit = unit; Ruler->AUnit = CurrentUnit; if (CurrentUnit==uInch) sbUnit->Caption = AnsiString(IDS_COMMON_UNIT) + " : Inch"; else if (CurrentUnit==uCm) sbUnit->Caption = AnsiString(IDS_COMMON_UNIT) + " : Cm"; FullViewForm->UnitChange(); MainMenuForm->UnitChange(); ReviewStatusBar(); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::ReviewStatusBar() { MainForm->StatusBar->Panels->Items[StatusBarSize]->Text = "Size : " + CanvasInfor.Name(CurrentUnit, iMainImage->Bitmap->Width, iMainImage->Bitmap->Height); MainForm->StatusBar->Panels->Items[StatusBarDPI]->Text = Format("DPI : %d", OPENARRAY(TVarRec, (CanvasInfor.DotsPerInch))); } //--------------------------------------------------------------------------- TPException __fastcall TMainImageForm::LoadFromFile(AnsiString FileName, TTexpiaBitmap *pBitmap, TPalette *pPalette, TPCanvasInfor &ci) { TEXPIAFILEHEADER tpfh; HANDLE hFile = INVALID_HANDLE_VALUE; TPException ec = EC_NONE; if ((hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_FILE_NOT_OPEN; goto fail; } if ((ec = LoadFromTexpiaFile(hFile, pPalette, tpfh, pBitmap)) != EC_NONE) goto fail; if ((ec = Plan->LoadFromFile(hFile, tpfh)) != EC_NONE) goto fail; UserColorLibForm->ThisFileHasUserColor(pPalette); ci = tpfh.CanvasInfor; CloseHandle(hFile); return EC_NONE; fail: if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile); if (ec == EC_NONE) ec = EC_FILE_NOT_READ; return ec; } //--------------------------------------------------------------------------- //Print Private Method// //---------------------------------------------------------------------------- int __fastcall TMainImageForm::GetYarnHeight() { int i, j, H, totalH = 0; int LH[6] = {0, 0, 0, 0, 0, 0}; int warpcnt, weftcnt, colorcnt, cnt = 0; bool IsWeft; TYarnArray *ya; warpcnt = Plan->Yarn->Array[0]->Count; weftcnt = Plan->Yarn->Array[1]->Count; for (i = 1; i <= 32; i++) { IsWeft = true; for (j = 0; j < warpcnt; j++) { ya = (TYarnArray *) Plan->Yarn->Array[0]->Items[j]; if (i == ya->code) { colorcnt = Plan->Yarn->Choice[((i-1)/8)].Data->Colors; H = (colorcnt / 2 + colorcnt % 2) * 70 + 70; if (H > LH[cnt % 6]) LH[cnt % 6] += H; cnt++; IsWeft = false; break; } } if (IsWeft) { for (j = 0; j < weftcnt; j++) { ya = (TYarnArray *) Plan->Yarn->Array[1]->Items[j]; if (i == ya->code) { colorcnt = Plan->Yarn->Choice[((i-1)/8)].Data->Colors; H = (colorcnt / 2 + colorcnt % 2) * 70 + 70; if (H > LH[cnt % 6]) LH[cnt % 6] += H; cnt++; break; } } } } // for (i = 0; i < 6; i++) totalH += LH[i]; totalH = LH[0]; for(i = 1 ; i < 6;i++){ if(LH[i] > totalH) totalH = LH[i]; } return totalH; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::GetTextureHeight(int w, int &h) { int i, k, sy, lx, ly, wid, hei; int ds[4] = {16, 8, 4, 2}; if (Plan->Texture->InitTexture() == false) return false; h = 0; for (i = 0; i < Plan->Texture->ChoiceCount; i++) { wid = Plan->Texture->Choice[i].width; hei = Plan->Texture->Choice[i].height; for (k = 0; k < 4; k++) { lx = ChartSx*2 + (wid+Plan->Texture->tm[i].cnt)*ds[k] + 12; ly = ChartSy*2 + (hei+Plan->Texture->tm[i].cnt)*ds[k] + 42; if (lx < w - 22) break; } h += ly; } Plan->Texture->ExitTexture(); return true; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::DrawOutLine(TTexpiaBitmap *Pattern, int H) { int w, h, x; AnsiString str, company = "", date, time; TCanvas *Canvas = NULL; TRegIniFile *Reg = NULL; Reg = new TRegIniFile(""); if (Reg) { Reg->RootKey = HKEY_LOCAL_MACHINE; if (Reg->OpenKey("\\SOFTWARE\\MicroSoft\\Windows", false)) company = Reg->ReadString("CurrentVersion", "RegisteredOrganization", ""); delete Reg; } if ((Canvas = Pattern->CreateCanvas()) == NULL) return false; w = A4Width-1; h = A4Height-1; Canvas->Font->Size = 15; Canvas->Font->Color = clPurple; Canvas->MoveTo(0, H); Canvas->LineTo(w, H); Canvas->LineTo(w, H+30); Canvas->LineTo(0, H+30); Canvas->LineTo(0, H); str = "PATTERN NAME : " + FileName; Canvas->TextOut(30, H+5, str); switch (Plan->WeaveCondition.HairEffect) { case 1: str = "HAIR EFFECT : FICTION (SHORT)"; break; case 2: str = "HAIR EFFECT : FICTION (NORMAL)"; break; case 3: str = "HAIR EFFECT : FICTION (LONG)"; break; case 4: str = "HAIR EFFECT : ACTUAL"; break; default: str = "HAIR EFFECT : NONE"; break; } x = (w - Canvas->TextWidth(str)) / 2; Canvas->TextOut(x, H+5, str); date = DateToStr(Date()); time = TimeToStr(Time()); str = Format("%s %s", OPENARRAY(TVarRec, (date.c_str(), time.c_str()))); x = w - Canvas->TextWidth(str) - 20; Canvas->TextOut(x, H+5, str); Canvas->Font->Size = 12; Canvas->Font->Color = clBlack; Canvas->MoveTo(0, H+35); Canvas->LineTo(w, H+35); Canvas->LineTo(w, H+h-22); Canvas->LineTo(0, H+h-22); Canvas->LineTo(0, H+35); x = Canvas->TextWidth(company); Canvas->TextOut(w-x-80, H+h-19, company); Pattern->DeleteCanvas(Canvas); return true; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::YarnDraw(TTexpiaBitmap *Pattern, int x, int &y, bool product, int h) { TYarnData *yd; TYarnInfor *yi; int Hei, i, Index; AnsiString str, c, unit; TCanvas *Canvas = NULL; if ((Canvas = Pattern->CreateCanvas()) == NULL) return false; for (i = 0; i < 4; i++) { if (Plan->Yarn->Choice[i].Data) { if (FindABCD(i)) { switch (i) { case 0: str = "A> "; break; case 1: str = "B> "; break; case 2: str = "C> "; break; case 3: str = "D> "; break; } yd = Plan->Yarn->Choice[i].Data; unit = yd->Unit.Name(); yi = &yd->Infor; if (yi->Detail.SZ) c = "Z"; else c = "S"; str = Format("%s %4d %s, %2d twist yarn, %s twist, %.2f TPI.", OPENARRAY( TVarRec, (str.c_str(), yi->Detail.Count, unit.c_str(), yi->Detail.TYC, c.c_str(), yi->Detail.TPI))); Canvas->Font->Color = clBlue; Canvas->TextOut(x, y, str); y += 20; } } } Pattern->DeleteCanvas(Canvas); x = 5; Hei = 0; Index = 1; for (i = 0; i < 4; i++) { if (Plan->Yarn->Choice[i].Data) { if (FindABCD(i)) { if (product) h = ((y / h) + 1 ) * h; if (YarnSubDraw(Pattern, i, x, y, Index, Hei, product, h) == false) return false; } } } if (x != 5) y = y + Hei + 10; return true; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::YarnSubDraw(TTexpiaBitmap *Pattern, int i, int &xxx, int &yyy, int &Ind, int &Hi, bool product, int h) { TYarnArray *ya; int colors, wid, chipw, chiph; int k, m, n, p, warpcnt, weftcnt; int a, b, x; bool IsWeft; TPoint sp; TSize sz; RECT Dst, Src, trect, brect; AnsiString str, abcd; TColorData *cd; TTexpiaBitmap *YarnBit = NULL; //Graphics::TBitmap *YarnBit = NULL; TCanvas *Canvas = NULL, *YarnCanvas = NULL; // YarnBit = new Graphics::TBitmap; YarnBit = new TTexpiaBitmap; if (YarnBit == NULL) return false; // YarnBit->PixelFormat = pf15bit; wid = (Pattern->Width / 6) - 10; // YarnBit->Width = wid; chipw = wid / 2; colors = Plan->Yarn->Choice[i].Data->Colors; // YarnBit->Height = 150 + ((colors-1) / 2) * 70; if (!YarnBit->Create(wid,150 + ((colors-1) / 2) * 70, 16)) goto fail; if (xxx == 5) Hi = YarnBit->Height; else { if (Hi < YarnBit->Height) Hi = YarnBit->Height; } warpcnt = Plan->Yarn->Array[0]->Count; weftcnt = Plan->Yarn->Array[1]->Count; sp.x = 0; sp.y = 20 + (50 - Plan->Yarn->Choice[i].Data->Width) / 2; sz.cx = YarnBit->Width; sz.cy = 50; Src = Rect(0, 0, YarnBit->Width, YarnBit->Height); Dst = Rect(xxx, yyy, xxx+YarnBit->Width, yyy+YarnBit->Height); if (product) { if (yyy+YarnBit->Height > h) { yyy = h + 45; Dst = Rect(xxx, yyy, xxx+YarnBit->Width, yyy+YarnBit->Height); h = h + A4Height; } } switch (i) { case 0: abcd = "A: "; break; case 1: abcd = "B: "; break; case 2: abcd = "C: "; break; case 3: abcd = "D: "; break; } n = i*8; if ((Canvas = Pattern->CreateCanvas()) == NULL) return false; if ((YarnCanvas = YarnBit->CreateCanvas()) == NULL) return false; Canvas->CopyMode = cmSrcCopy; for (k = 1; k <= 8; k++) { IsWeft = true; YarnCanvas->Brush->Color = clWhite; YarnCanvas->FillRect(Src); for (m = 0; m < warpcnt; m++) { ya = (TYarnArray *) Plan->Yarn->Array[0]->Items[m]; if ((n+k) == ya->code) { YarnCanvas->Font->Size = 12; if (IsThereWarp(n+k)) str = abcd + Ind + ": WARP / WEFT"; else str = abcd + Ind + ": WARP"; Ind++; YarnCanvas->TextOut(10, 4, str); Plan->Yarn->Choice[i].Data->Draw(YarnCanvas, sp, sz, Plan->Yarn->Choice[i].Color[k-1]); YarnCanvas->Font->Size = 8; for (p = 0; p < colors; p++) { a = p / 2; b = p % 2; brect = Rect(2+b*chipw, 70+a*70, (2+chipw-5)+b*chipw, 120+a*70); trect = Rect(2+b*chipw, 120+a*70, (2+chipw-5)+b*chipw, 140+a*70); cd = Plan->Yarn->Choice[i].Color[k-1][p]->GetColor(0); PrintColorChip15(YarnBit, brect, cd->RGB.rgbRed, cd->RGB.rgbGreen, cd->RGB.rgbBlue); YarnCanvas->Brush->Color = clWhite; str = GetColorName(cd); x = ((chipw-5) - YarnCanvas->TextWidth(str)) / 2; YarnCanvas->TextRect(trect, trect.left+x, trect.top+4, str); } Canvas->CopyRect(Dst, YarnCanvas, Src); xxx = Dst.right + 10; yyy = Dst.top; if (xxx+YarnBit->Width > Pattern->Width-1) { xxx = 5; yyy = Dst.top + Hi + 10; Hi = YarnBit->Height; } Dst = Rect(xxx, yyy, xxx + YarnBit->Width, yyy + YarnBit->Height); if (product) { if (yyy+YarnBit->Height > h) { yyy = h + 45; Dst = Rect(xxx, yyy, xxx+YarnBit->Width, yyy+YarnBit->Height); h = h + A4Height; } } IsWeft = false; break; } // YarnBit->DeleteCanvas(YarnCanvas); } if (IsWeft) { for (m = 0; m < weftcnt; m++) { ya = (TYarnArray *) Plan->Yarn->Array[1]->Items[m]; if ((n+k) == ya->code) { YarnCanvas->Font->Size = 12; str = abcd + Ind + ": WEFT"; Ind++; YarnCanvas->TextOut(10, 4, str); Plan->Yarn->Choice[i].Data->Draw(YarnCanvas, sp, sz, Plan->Yarn->Choice[i].Color[k-1]); YarnCanvas->Font->Size = 8; for (p = 0; p < colors; p++) { a = p / 2; b = p % 2; brect = Rect(2+b*chipw, 70+a*70, (2+chipw-5)+b*chipw, 120+a*70); trect = Rect(2+b*chipw, 120+a*70, (2+chipw-5)+b*chipw, 140+a*70); cd = Plan->Yarn->Choice[i].Color[k-1][p]->GetColor(0); PrintColorChip15(YarnBit, brect, cd->RGB.rgbRed, cd->RGB.rgbGreen, cd->RGB.rgbBlue); YarnCanvas->Brush->Color = clWhite; str = GetColorName(cd); x = ((chipw-5) - YarnCanvas->TextWidth(str)) / 2; YarnCanvas->TextRect(trect, trect.left+x, trect.top+4, str); } Canvas->CopyRect(Dst, YarnCanvas, Src); xxx = Dst.right + 10; yyy = Dst.top; if (xxx+YarnBit->Width > Pattern->Width-1) { xxx = 5; yyy = Dst.top + Hi + 10; Hi = YarnBit->Height; } Dst = Rect(xxx, yyy, xxx + YarnBit->Width, yyy + YarnBit->Height); if (product) { if (yyy+YarnBit->Height > h) { yyy = h + 45; Dst = Rect(xxx, yyy, xxx+YarnBit->Width, yyy+YarnBit->Height); h = h + A4Height; } } break; } } } } Pattern->DeleteCanvas(Canvas); YarnBit->DeleteCanvas(YarnCanvas); delete YarnBit; return true; fail: if(YarnBit) delete YarnBit; return false; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::FindABCD(int i) { TYarnArray *ya; for (int m = 0; m < 2; m++) { for (int n = 0; n < Plan->Yarn->Array[m]->Count; n++) { ya = (TYarnArray *) Plan->Yarn->Array[m]->Items[n]; if (i == ((ya->code - 1) /8)) return true; } } return false; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::IsThereWarp(int i) { TYarnArray *ya; int cnt = Plan->Yarn->Array[1]->Count; for (int k = 0; k < cnt; k++) { ya = (TYarnArray *) Plan->Yarn->Array[1]->Items[k]; if (ya->code == i) return true; } return false; } //--------------------------------------------------------------------------- int __fastcall TMainImageForm::SubTableDraw(TTexpiaBitmap *Pattern, int nty) { int warpsx, warpex, weftsx, weftex; int cellw, sw, temp; int wsx, wsy, wex, wey; int H, w, h, A4H, rest; int warpcnt, weftcnt; int x, ty, i; AnsiString str, len, yar; TYarnArray *pd; TCanvas *Canvas = NULL; A4H = GetDeviceCaps(Printer()->Handle, VERTRES)*160/ GetDeviceCaps(Printer()->Handle, LOGPIXELSY); warpcnt = Plan->Yarn->PData[0]->Count; weftcnt = Plan->Yarn->PData[1]->Count; rest = A4H - (nty % A4H) - 25; if (warpcnt > weftcnt) { h = 30 + (warpcnt+2)*25; //Warp(Text)_H + cnt*Cell_H*25 } else { h = 30 + (weftcnt+2)*25; } if (rest < h) { nty = nty + rest + 25 + 45; // ´ÙÀ½ ÆäÀÌÁöÀÇ ½ÃÀÛÀ§Ä¡·Î ³Ñ±è. } // Array Draw Cell w = Pattern->Width - 1; warpsx = 5; warpex = w/2 - 5; weftsx = w/2 + 5; weftex = w - 5; cellw = (warpex - warpsx) / 7; H = nty + 6; if ((Canvas = Pattern->CreateCanvas()) == NULL) goto fail; Canvas->Font->Size = 12; Canvas->Font->Color = clBlue; str = "<>"; Canvas->TextOut(warpsx + 20, H, str); str = "<>"; Canvas->TextOut(weftsx + 20, H, str); if (CurrentUnit == uCm) str = ""; else str = ""; sw = Canvas->TextWidth(str) + 20; Canvas->TextOut(warpex - sw, H, str); Canvas->TextOut(weftex - sw, H, str); if (warpcnt) { wsy = H + 24; //30 = 24+6; for (i = 0; i <= warpcnt+2; i++) { wey = wsy + i * 25; Canvas->MoveTo(warpsx, wey); Canvas->LineTo(warpex, wey); } for (i = 0; i < 7; i++) { wex = warpsx + i * cellw; Canvas->MoveTo(wex , wsy); Canvas->LineTo(wex , wey); } Canvas->MoveTo(warpex , wsy); Canvas->LineTo(warpex , wey); } if (weftcnt) { wsy = H + 24; //30 = 24+6; for (i = 0; i <= weftcnt+2; i++) { wey = wsy + i * 25; Canvas->MoveTo(weftsx, wey); Canvas->LineTo(weftex, wey); } for (i = 0; i < 7; i++) { wex = weftsx + i * cellw; Canvas->MoveTo(wex , wsy); Canvas->LineTo(wex , wey); } Canvas->MoveTo(weftex , wsy); Canvas->LineTo(weftex , wey); } // Array Draw string ty = wsy + 4; Canvas->Font->Color = clBlue; for (i = 0; i < 7; i++) { switch (i) { case 0: str = "No."; break; case 1: str = "Code"; break; case 2: str = "Method"; break; case 3: str = "Length"; break; case 4: str = "Yarns"; break; case 5: str = "Density"; break; case 6: str = "Repeat"; break; } x = (cellw - Canvas->TextWidth(str)) / 2; if (warpcnt) Canvas->TextOut(warpsx+x+i*cellw, ty, str); if (weftcnt) Canvas->TextOut(weftsx+x+i*cellw, ty, str); } Canvas->Font->Color = clBlack; for (i = 0; i < warpcnt; i++) { ty = wsy + 4 + (i+1)*25; str = i+1; x = (cellw - Canvas->TextWidth(str)) / 2; Canvas->TextOut(warpsx+x, ty, str); pd = (TYarnArray *)Plan->Yarn->PData[0]->Items[i]; temp = (int) pd->code; str = temp; x = (cellw - Canvas->TextWidth(str)) / 2; Canvas->TextOut(warpsx+x+cellw, ty, str); switch (pd->method) { case 0: str = "Normal"; break; case 1: str = "Reverse"; break; case 2: str = "Center"; break; } x = (cellw - Canvas->TextWidth(str)) / 2; Canvas->TextOut(warpsx+x+cellw*2, ty, str); if (CurrentUnit == uCm) str = Format("%.2f", OPENARRAY(TVarRec, (pd->length * 2.54))); else str = Format("%.2f", OPENARRAY(TVarRec, (pd->length))); x = (cellw - Canvas->TextWidth(str)) / 2; Canvas->TextOut(warpsx+x+cellw*3, ty, str); str = pd->yarns; x = (cellw - Canvas->TextWidth(str)) / 2; Canvas->TextOut(warpsx+x+cellw*4, ty, str); if (CurrentUnit == uCm) str = Format("%.2f", OPENARRAY(TVarRec, (pd->density / 2.54))); else str = Format("%.2f", OPENARRAY(TVarRec, (pd->density))); x = (cellw - Canvas->TextWidth(str)) / 2; Canvas->TextOut(warpsx+x+cellw*5, ty, str); str = pd->repeat; x = (cellw - Canvas->TextWidth(str)) / 2; Canvas->TextOut(warpsx+x+cellw*6, ty, str); } if (warpcnt) { ty = wsy + 4 + (warpcnt+1)*25; str = "Total"; x = (cellw - Canvas->TextWidth(str)) / 2; Canvas->TextOut(warpsx+x, ty, str); len = ""; yar = ""; ExtractTotal(-1, 0, len, yar); if (len != "") { x = (cellw - Canvas->TextWidth(len)) / 2; Canvas->TextOut(warpsx+x+cellw*3, ty, len); x = (cellw - Canvas->TextWidth(yar)) / 2; Canvas->TextOut(warpsx+x+cellw*4, ty, yar); } } for (i = 0; i < weftcnt; i++) { ty = wsy + 4 + (i+1)*25; str = i+1; x = (cellw - Canvas->TextWidth(str)) / 2; Canvas->TextOut(weftsx+x, ty, str); pd = (TYarnArray *)Plan->Yarn->PData[1]->Items[i]; temp = pd->code; str = temp; x = (cellw - Canvas->TextWidth(str)) / 2; Canvas->TextOut(weftsx+x+cellw, ty, str); switch (pd->method) { case 0: str = "Normal"; break; case 1: str = "Reverse"; break; case 2: str = "Center"; break; } x = (cellw - Canvas->TextWidth(str)) / 2; Canvas->TextOut(weftsx+x+cellw*2, ty, str); if (CurrentUnit == uCm) str = Format("%.2f", OPENARRAY(TVarRec, (pd->length * 2.54))); else str = Format("%.2f", OPENARRAY(TVarRec, (pd->length))); x = (cellw - Canvas->TextWidth(str)) / 2; Canvas->TextOut(weftsx+x+cellw*3, ty, str); str = pd->yarns; x = (cellw - Canvas->TextWidth(str)) / 2; Canvas->TextOut(weftsx+x+cellw*4, ty, str); if (CurrentUnit == uCm) str = Format("%.2f", OPENARRAY(TVarRec, (pd->density / 2.54))); else str = Format("%.2f", OPENARRAY(TVarRec, (pd->density))); x = (cellw - Canvas->TextWidth(str)) / 2; Canvas->TextOut(weftsx+x+cellw*5, ty, str); str = pd->repeat; x = (cellw - Canvas->TextWidth(str)) / 2; Canvas->TextOut(weftsx+x+cellw*6, ty, str); } if (weftcnt) { ty = wsy + 4 + (weftcnt+1)*25; str = "Total"; x = (cellw - Canvas->TextWidth(str)) / 2; Canvas->TextOut(weftsx+x, ty, str); len = ""; yar = ""; ExtractTotal(-1, 1, len, yar); if (len != "") { x = (cellw - Canvas->TextWidth(len)) / 2; Canvas->TextOut(weftsx+x+cellw*3, ty, len); x = (cellw - Canvas->TextWidth(yar)) / 2; Canvas->TextOut(weftsx+x+cellw*4, ty, yar); } } Pattern->DeleteCanvas(Canvas); if (warpcnt > weftcnt){ H = nty + (warpcnt+2)*25 + 30 + 20; // ¿©À¯ºÐÀ» À§ÇØ 20À» ´õÇØÁÜ. } else { H = nty + (weftcnt+2)*25 + 30 + 20; } w = (H % A4H) - 45; // ½ÃÀÛÁ¡ÀÌ FileNameÀ» ¾²´Â ¹üÀ§¿¡ ÀÖ´Â °æ¿ì¿¡ À§Ä¡¸¦ Á¶Á¤ÇØÁÜ. if (w < 0) H -= w; return H; fail: ShowMessage("Can't Create Canvas"); return nty; } //--------------------------------------------------------------------------- int __fastcall TMainImageForm::TableDraw(TTexpiaBitmap *Pattern, int H, String waWidth, String weWidth) { //ÆäÀÌÁö°¡ ³Ñ¾î°¥¶§ ©¸®´Â Çö»óÀ» ¼öÁ¤ÇÑ ÈÄÀÇ ÇÔ¼ö(2000. 5. 17) int weftsx, weftex, warpsx, warpex, wex, wsy, wey, wesy, weey; int cellw, w, ty, ety, cellw1; AnsiString str, /*len, yar,*/ weight, tstr, tyar, tlen; int i, j, x, cw3, sw, temp; double tWidth;//, wasum = 0.0, wasum1 = 0.0, tDen = 0.0, tDen1 = 0.0; int warpcnt, weftcnt, tWayar = 0, tWeyar = 0; TYarnArray *pd, *ya, *waave, *weave; TCanvas *Canvas = NULL; int weH; double waaverage = 0.0, weaverage = 0.0; wasum = 0.0; wasum1 = 0.0; tDen = 0.0; tDen1 = 0.0; densityCnt = 0; densityCnt = 0; if ((Plan->Yarn->PData[0]->Count == 0) && (Plan->Yarn->PData[1]->Count == 0)) { for (i=0; i<2; i++) { for (j=0; jYarn->Array[i]->Count; j++) { ya = (TYarnArray *)Plan->Yarn->Array[i]->Items[j]; pd = new TYarnArray; pd->code = ya->code; pd->method = ya->method; pd->length = ya->length; pd->yarns = ya->yarns; pd->density = ya->density; pd->repeat = ya->repeat; Plan->Yarn->PData[i]->Add(pd); } } } w = Pattern->Width - 1; // account Draw Cell warpsx = 5; warpex = w - 5; weftsx = 5; weftex = w - 5; cellw1 = (warpex - warpsx) / 16; weH = H + 325; //Cell_Count*Cell_H * Warp_H = 12*25+25 = 325 if ((Canvas = Pattern->CreateCanvas()) == NULL) return false; Canvas->Font->Size = 12; Canvas->Font->Color = clBlue; str = "<>"; Canvas->TextOut(warpsx + 20, H, str); str = "<>"; Canvas->TextOut(weftsx + 20, weH, str); if (CurrentUnit == uCm) str = ""; else str = ""; sw = Canvas->TextWidth(str) + 20; Canvas->TextOut(warpex - sw, H, str); Canvas->TextOut(weftex - sw, weH, str); wsy = H + 22; wesy = weH + 22; for (i = 0; i <= 12; i++) { wey = wsy + i * 25; Canvas->MoveTo(warpsx, wey); Canvas->LineTo(warpex, wey); weey = wesy + i * 25; Canvas->MoveTo(weftsx, weey); Canvas->LineTo(weftex, weey); } wex = warpsx; for (i = 0; i < 16; i++) { if (i % 4) Canvas->MoveTo(wex, wsy + 25); else Canvas->MoveTo(wex, wsy); Canvas->LineTo(wex, wey); if (i % 4) Canvas->MoveTo(wex, wesy + 25); else Canvas->MoveTo(wex, wesy); Canvas->LineTo(wex, weey); if (!(i % 4)) cellw = cellw1 * 0.8; else if ((i % 4) == 3) cellw = cellw1 * 1.2; else cellw = cellw1; wex += cellw; } Canvas->MoveTo(warpex, wsy); Canvas->LineTo(warpex, wey); Canvas->MoveTo(weftex, wesy); Canvas->LineTo(weftex, weey); // account Draw string Canvas->Font->Size = 10; Canvas->Font->Color = clBlack; ty = wsy + 4; ety = wesy + 4; Canvas->Font->Color = clRed; cw3 = cellw1 * 4; x = (cw3 - Canvas->TextWidth("A")) / 2; for (j = 0; j < 4; j++) { switch (j) { case 0: str = "A"; break; case 1: str = "B"; break; case 2: str = "C"; break; case 3: str = "D"; break; } Canvas->TextOut(warpsx+x + cw3*j, ty, str); Canvas->TextOut(weftsx+x + cw3*j, ety, str); } ty = wsy + 4 + 25; ety = wesy + 4 + 25; Canvas->Font->Color = clBlue; wex = warpsx; for (i = 0; i < 16; i++) { if (!(i % 4)) cellw = cellw1 * 0.8; else if ((i % 4) == 3) cellw = cellw1 * 1.2; else cellw = cellw1; switch (i % 4) { case 0: str = "Code"; break; case 1: str = "Len."; break; case 2: str = "Yarns"; break; case 3: str = "Weight"; break; //<--IDS_WEIGHT; break; lhskys } x = (cellw - Canvas->TextWidth(str)) / 2; Canvas->TextOut(wex + x, ty, str); Canvas->TextOut(wex + x, ety, str); wex += cellw; } // for (j = 0 ; j < 4 ; j++) { // ExtractTotal(j, 0, tlen, tyar); // if (tlen != "") { tWayar += StrToInt(tyar); } // ExtractTotal(j, 1, tlen, tyar); // if (tlen != "") { tWeyar += StrToInt(tyar); } // } for (j = 1; j <= 32; j++) { //lhskys Extractdensity(j, 0);//, len[j-1], yar[j-1]); Extractdensity1(j, 1);//, len[j-1], yar[j-1]); } // for ( int k = 0 ; k < Plan->Yarn->PData[0]->Count ; k++) { // waave = (TYarnArray *)Plan->Yarn->PData[0]->Items[k]; // if (CurrentUnit == uCm) { // tDen = waave->density / 2.54; // } else { // tDen = waave->density; // } // wasum += tDen; // } waaverage = wasum / densityCnt; //lhskys // wasum = 0.0; tDen = 0.0; // for ( k = 0 ; k < Plan->Yarn->PData[1]->Count ; k++) { // weave = (TYarnArray *)Plan->Yarn->PData[1]->Items[k]; // if (CurrentUnit == uCm) { // tDen = weave->density / 2.54; // } else { // tDen = weave->density; // } // wasum += tDen; // } weaverage = wasum1 / densityCnt1; for (j = 0; j <= 31; j++){ len[j]=0; yar[j]=0; len1[j]=0; yar1[j]=0; } for (j = 1; j <= 32; j++) { //lhskys ExtractLengthYarns(j, 0);//, len[j-1], yar[j-1]); ExtractLengthYarns1(j, 1);//, len[j-1], yar[j-1]); } for (j = 1; j <= 32; j++) { if(yar[j-1] != NULL) tWayar += yar[j-1]; if(yar1[j-1] != NULL) tWeyar += yar1[j-1]; } for (j = 1; j <= 32; j++) { double totlen = 0.0; int totyar = 0; if (len[j-1] != 0){ totlen = len[j-1]; totyar = yar[j-1]; } if (totlen) { if (CurrentUnit == uCm) len[j-1] = double(int (totlen*254.0))/100.0; else len[j-1] = double(int (totlen*100.0))/100.0; yar[j-1] = totyar; } else { len[j-1] = 0; yar[j-1] = 0; } ty = wsy + 4 + 25*((j-1)%8 + 2); ety = wesy + 4 + 25*((j-1)%8 + 2); i = (j-1) / 8; str = j; cellw = cellw1 * 0.8; Canvas->Font->Color = clPurple; x = (cellw - Canvas->TextWidth(str)) / 2; Canvas->TextOut(warpsx+x+i*cw3, ty, str); //code WARP Canvas->TextOut(weftsx+x+i*cw3, ety, str); //code WEFT cellw = cellw1 * 0.8; Canvas->Font->Color = clBlack; // len[j-i] = ""; yar[j-1] = ""; // ExtractLengthYarns(j, 0, len, yar); if (len[j-1] != 0) { tWidth = StrToFloat(waWidth) * waaverage; x = (cellw1 - Canvas->TextWidth(len[j-1])) / 2; Canvas->TextOut(warpsx+x+cellw+i*cw3, ty, len[j-1]); //data len x = (cellw1 - Canvas->TextWidth(yar[j-1])) / 2; Canvas->TextOut(warpsx+x+cellw+cellw1+i*cw3, ty, yar[j-1]); //data yarn if (Plan->Yarn->Choice[i].Data->Infor.Detail.Count) { tWidth = (yar[j-1]* tWidth / tWayar) / (1000 * Plan->Yarn->Choice[i].Data->Infor.Detail.Count); //weught °è»êºÎºÐ weight = Format("%.4f", OPENARRAY (TVarRec,(tWidth))); x = (cellw1*1.2 - Canvas->TextWidth(weight)) / 2; Canvas->TextOut(warpsx+x+cellw1*2+cellw+i*cw3, ty, weight); //data weight } else { x = (cellw1*1.2 - Canvas->TextWidth("-")) / 2; Canvas->TextOut(warpsx+x+cellw1*2+cellw+i*cw3, ty, "-"); } } cellw = cellw1 * 0.8; // len = ""; yar = ""; // ExtractLengthYarns(j, 1, len, yar); double totlen1 = 0.0; int totyar1 = 0; //lhskys if (len1[j-1] != 0){ totlen1 = len1[j-1]; totyar1 = yar1[j-1]; } if (totlen1) { if (CurrentUnit == uCm) len1[j-1] = double(int (totlen1*254.0))/100.0; else len1[j-1] = double(int (totlen1*100.0))/100.0; yar1[j-1] = totyar1; } else { len1[j-1] = 0; yar1[j-1] = 0; } if (len1[j-1] != 0) { //lhskys tWidth = StrToFloat(weWidth) * StrToFloat(waWidth); x = (cellw1 - Canvas->TextWidth(len1[j-1])) / 2; Canvas->TextOut(warpsx+x+cellw+i*cw3, ety, len1[j-1]); x = (cellw1 - Canvas->TextWidth(yar1[j-1])) / 2; Canvas->TextOut(warpsx+x+cellw+cellw1+i*cw3, ety, yar1[j-1]); if (Plan->Yarn->Choice[i].Data->Infor.Detail.Count) { tWidth = (yar1[j-1] * 0.9144 * tWidth / tWeyar) / (1000 * Plan->Yarn->Choice[i].Data->Infor.Detail.Count); //weight °ª °è»êºÎºÐ weight = Format("%.4f", OPENARRAY (TVarRec,(tWidth))); x = (cellw1*1.2 - Canvas->TextWidth(weight)) / 2; Canvas->TextOut(warpsx+x+cellw1*2+cellw+i*cw3, ety, weight); } else { x = (cellw1*1.2 - Canvas->TextWidth("-")) / 2; Canvas->TextOut(warpsx+x+cellw1*2+cellw+i*cw3, ety, "-"); } } totlen = 0; totyar = 0; totlen1 = 0; totyar1 = 0; } ty = wsy + 4 + 250; ety = wesy + 4 + 250; cellw = cellw1 * 0.8; //***************************************************************************** lhskys double len_tot_A = 0.0, len_tot_B = 0.0, len_tot_C = 0.0, len_tot_D = 0.0; double len_tot_A1 = 0.0, len_tot_B1 = 0.0, len_tot_C1 = 0.0, len_tot_D1 = 0.0; int yar_tot_A = 0, yar_tot_B = 0, yar_tot_C = 0, yar_tot_D = 0; int yar_tot_A1 = 0, yar_tot_B1 = 0, yar_tot_C1 = 0, yar_tot_D1 = 0; bool A=false, B=false, C=false, D=false; int q; for (q = 0 ; q < 8 ; q++) if (len[q] != NULL) A = true; for (q = 8 ; q < 16 ; q++) if (len[q] != NULL) B = true; for (q = 16 ; q < 24 ; q++)if (len[q] != NULL) C = true; for (q = 24 ; q < 32 ; q++)if (len[q] != NULL) D = true; if (A){ for (int v = 0 ; v < 8 ; v++){ len_tot_A += len[v]; yar_tot_A += yar[v]; } } if (B){ for (int v = 8 ; v < 16 ; v++){ len_tot_B += len[v]; yar_tot_B += yar[v]; } } if (C){ for (int v = 16 ; v < 24 ; v++){ len_tot_C += len[v]; yar_tot_C += yar[v]; } } if (D){ for (int v = 24 ; v < 32 ; v++){ len_tot_D += len[v]; yar_tot_D += yar[v]; } } //***************************************************************************** lhskys // for (j = 0; j < 4; j++) { // str = "Total"; // len = ""; yar = ""; // ExtractTotal(j, 0, len, yar); // if (len != "") { // x = (cellw - Canvas->TextWidth(str)) / 2; // Canvas->TextOut(warpsx+x+j*cw3, ty, str); // x = (cellw1 - Canvas->TextWidth(len)) / 2; // Canvas->TextOut(warpsx+x+cellw + j*cw3, ty, len); // x = (cellw1 - Canvas->TextWidth(yar)) / 2; // Canvas->TextOut(warpsx+x+cellw1+cellw+j*cw3, ty, yar); // } str = "Total"; if(A){ x = (cellw - Canvas->TextWidth(str)) / 2; Canvas->TextOut(warpsx+x+0*cw3, ty, str); x = (cellw1 - Canvas->TextWidth(len_tot_A)) / 2; Canvas->TextOut(warpsx+x+cellw + 0*cw3, ty, len_tot_A); x = (cellw1 - Canvas->TextWidth(yar_tot_A)) / 2; Canvas->TextOut(warpsx+x+cellw1+cellw+0*cw3, ty, yar_tot_A); } if(B){ x = (cellw - Canvas->TextWidth(str)) / 2; Canvas->TextOut(warpsx+x+1*cw3, ty, str); x = (cellw1 - Canvas->TextWidth(len_tot_B)) / 2; Canvas->TextOut(warpsx+x+cellw + 1*cw3, ty, len_tot_B); x = (cellw1 - Canvas->TextWidth(yar_tot_B)) / 2; Canvas->TextOut(warpsx+x+cellw1+cellw+1*cw3, ty, yar_tot_B); } if(C){ x = (cellw - Canvas->TextWidth(str)) / 2; Canvas->TextOut(warpsx+x+2*cw3, ty, str); x = (cellw1 - Canvas->TextWidth(len_tot_C)) / 2; Canvas->TextOut(warpsx+x+cellw + 2*cw3, ty, len_tot_C); x = (cellw1 - Canvas->TextWidth(yar_tot_C)) / 2; Canvas->TextOut(warpsx+x+cellw1+cellw+2*cw3, ty, yar_tot_C); } if(D){ x = (cellw - Canvas->TextWidth(str)) / 2; Canvas->TextOut(warpsx+x+3*cw3, ty, str); x = (cellw1 - Canvas->TextWidth(len_tot_D)) / 2; Canvas->TextOut(warpsx+x+cellw + 3*cw3, ty, len_tot_D); x = (cellw1 - Canvas->TextWidth(yar_tot_D)) / 2; Canvas->TextOut(warpsx+x+cellw1+cellw+3*cw3, ty, yar_tot_D); } for (j = 0; j < 4; j++) { if ( j == 0 ) { tstr = AnsiString(IDS_WAWIDTH); x = (cellw - Canvas->TextWidth(tstr)) / 2; Canvas->TextOut(warpsx+x+j*cw3, ty+25, tstr); tWidth = StrToFloat(waWidth); weight = Format("%.0f", OPENARRAY (TVarRec, (tWidth))); x = (cellw1 - Canvas->TextWidth(weight)) / 2; Canvas->TextOut(warpsx+x+cellw+j*cw3, ty+25, weight); tstr = AnsiString(IDS_TOTAL); x = (cellw1 - Canvas->TextWidth(tstr)) / 2; Canvas->TextOut(warpsx+x+cellw1+cellw+j*cw3, ty+25, tstr); tWidth = StrToFloat(waWidth) * waaverage; weight = Format("%.0f", OPENARRAY (TVarRec,(tWidth))); x = (cellw1 - Canvas->TextWidth(weight)) / 2; Canvas->TextOut(warpsx+x+2*cellw1+cellw+j*cw3, ty+25, weight); } } //***************************************************************************** lhskys bool A1=false, B1=false, C1=false, D1=false; int q1; for (q1 = 0 ; q1 < 8 ; q1++) if (len1[q1] != NULL) A1 = true; for (q1 = 8 ; q1 < 16 ; q1++) if (len1[q1] != NULL) B1 = true; for (q1 = 16 ; q1 < 24 ; q1++)if (len1[q1] != NULL) C1 = true; for (q1 = 24 ; q1 < 32 ; q1++)if (len1[q1] != NULL) D1 = true; if (A1){ for (int v = 0 ; v < 8 ; v++){ len_tot_A1 += len1[v]; yar_tot_A1 += yar1[v]; } } if (B1){ for (int v = 8 ; v < 16 ; v++){ len_tot_B1 += len1[v]; yar_tot_B1 += yar1[v]; } } if (C1){ for (int v = 16 ; v < 24 ; v++){ len_tot_C1 += len1[v]; yar_tot_C1 += yar1[v]; } } if (D1){ for (int v = 24 ; v < 32 ; v++){ len_tot_D1 += len1[v]; yar_tot_D1 += yar1[v]; } } //***************************************************************************** lhskys // str = "Total"; // len = ""; yar = ""; // ExtractTotal(j, 1, len, yar); // if (len != "") { // x = (cellw - Canvas->TextWidth(str)) / 2; // Canvas->TextOut(warpsx+x+j*cw3, ety, str); // x = (cellw1 - Canvas->TextWidth(len)) / 2; // Canvas->TextOut(warpsx+x+cellw + j*cw3, ety, len); // x = (cellw1 - Canvas->TextWidth(yar)) / 2; // Canvas->TextOut(warpsx+x+cellw1+cellw+j*cw3, ety, yar); // } str = "Total"; if(A1){ x = (cellw - Canvas->TextWidth(str)) / 2; Canvas->TextOut(warpsx+x+0*cw3, ety, str); x = (cellw1 - Canvas->TextWidth(len_tot_A1)) / 2; Canvas->TextOut(warpsx+x+cellw + 0*cw3, ety, len_tot_A1); x = (cellw1 - Canvas->TextWidth(yar_tot_A1)) / 2; Canvas->TextOut(warpsx+x+cellw1+cellw+0*cw3, ety, yar_tot_A1); } if(B1){ x = (cellw - Canvas->TextWidth(str)) / 2; Canvas->TextOut(warpsx+x+1*cw3, ety, str); x = (cellw1 - Canvas->TextWidth(len_tot_B1)) / 2; Canvas->TextOut(warpsx+x+cellw + 1*cw3, ety, len_tot_B1); x = (cellw1 - Canvas->TextWidth(yar_tot_B1)) / 2; Canvas->TextOut(warpsx+x+cellw1+cellw+1*cw3, ety, yar_tot_B1); } if(C1){ x = (cellw - Canvas->TextWidth(str)) / 2; Canvas->TextOut(warpsx+x+2*cw3, ety, str); x = (cellw1 - Canvas->TextWidth(len_tot_C1)) / 2; Canvas->TextOut(warpsx+x+cellw + 2*cw3, ety, len_tot_C1); x = (cellw1 - Canvas->TextWidth(yar_tot_C1)) / 2; Canvas->TextOut(warpsx+x+cellw1+cellw+2*cw3, ety, yar_tot_C1); } if(D1){ x = (cellw - Canvas->TextWidth(str)) / 2; Canvas->TextOut(warpsx+x+3*cw3, ety, str); x = (cellw1 - Canvas->TextWidth(len_tot_D1)) / 2; Canvas->TextOut(warpsx+x+cellw + 3*cw3, ety, len_tot_D1); x = (cellw1 - Canvas->TextWidth(yar_tot_D1)) / 2; Canvas->TextOut(warpsx+x+cellw1+cellw+3*cw3, ety, yar_tot_D1); } for (j = 0; j < 4; j++) { if ( j == 0 ) { tstr = AnsiString(IDS_WEWIDTH); x = (cellw - Canvas->TextWidth(tstr)) / 2; Canvas->TextOut(warpsx+x+j*cw3, ety+25, tstr); tWidth = StrToFloat(weWidth); weight = Format("%.2f", OPENARRAY (TVarRec, (tWidth))); x = (cellw1 - Canvas->TextWidth(weight)) / 2; Canvas->TextOut(warpsx+x+cellw+j*cw3, ety+25, weight); // tstr = AnsiString(IDS_TOTAL); tstr = AnsiString(IDS_TOTAL1); x = (cellw1 - Canvas->TextWidth(tstr)) / 2; Canvas->TextOut(warpsx+x+cellw1+cellw+j*cw3, ety+25, tstr); // tWidth = StrToFloat(waWidth) * tWidth; tWidth = StrToFloat(weWidth) * weaverage; weight = Format("%.0f", OPENARRAY (TVarRec,(tWidth))); x = (cellw1 - Canvas->TextWidth(weight)) / 2; Canvas->TextOut(warpsx+x+2*cellw1+cellw+j*cw3, ety+25, weight); } } Pattern->DeleteCanvas(Canvas); H = SubTableDraw(Pattern, weey); return H; } //---------------------------------------------------------------------------- void __fastcall TMainImageForm::ExtractLengthYarns(int Index, int i)//, AnsiString &length, AnsiString &yarn) { TYarnArray *pd; int cnt = Plan->Yarn->PData[i]->Count, l; if (cnt) { double totlen = 0.0; int totyar = 0; for (int m = 0; m < cnt; m++) { pd = (TYarnArray *)Plan->Yarn->PData[i]->Items[m]; if (Index == pd->code) { //============================================================================== lhskys int j, k, method1; method1 = 0; int repeat1; //Center À϶§ÀÇ repeatÀ» ¾Ë±âÀ§ÇØ if(pd->method == 2){ //****************************************************************************** l = pd->code-1; // len[l] += pd->length*pd->repeat; // yar[l] += pd->yarns*pd->repeat; // //****************************************************************************** repeat1 = pd->repeat; for (j=m-1;j>-1;j--){ pd = (TYarnArray *)Plan->Yarn->PData[i]->Items[j]; if (pd->method == 1){ //****************************************************************************** l = pd->code-1; // len[l] += pd->length*(repeat1*2 - 1); // yar[l] += pd->yarns*(repeat1*2 - 1); // //****************************************************************************** method1 = 1; //reverse ¼öÇàÈ®ÀÎ ¾Æ´Ï¸é nomal À» ¼öÇàÇÏ¿©¾ß Çϱ⶧¹®¿¡ }else j = -1; } for (k=m-1;k>-1;k--){ pd = (TYarnArray *)Plan->Yarn->PData[i]->Items[k]; if (method1 == 0){ //****************************************************************************** l = pd->code-1; // len[l] += pd->length*(repeat1 - 1); // yar[l] += pd->yarns*(repeat1 - 1); // //****************************************************************************** }else k = -1; } }else { //****************************************************************************** l = pd->code-1; // len[l] += pd->length*pd->repeat; // yar[l] += pd->yarns*pd->repeat; // //****************************************************************************** } } } //============================================================================== // totlen += pd->length * pd->repeat; // totyar += pd->yarns * pd->repeat; // } // } /* if (len[l] != 0){ totlen = len[l]; totyar = yar[l]; } if (totlen) { if (CurrentUnit == uCm) //length = Format("%.2f", OPENARRAY(TVarRec, (totlen * 2.54))); len[l] = double(int (totlen*254.0))/100.0; //len[l] = Format("%.2f", OPENARRAY(TVarRec, (totlen * 2.54))); else //Length = Format("%.2f", OPENARRAY(TVarRec, (totlen))); len[l] = double(int (totlen*100.0))/100.0; yar[l] = totyar; } else { len[l] = 0; yar[l] = 0; }*/ } } //---------------------------------------------------------------------------- void __fastcall TMainImageForm::ExtractLengthYarns1(int Index, int i)//, AnsiString &length, AnsiString &yarn) { TYarnArray *pd; int cnt = Plan->Yarn->PData[i]->Count, l; if (cnt) { double totlen = 0.0; int totyar = 0; for (int m = 0; m < cnt; m++) { pd = (TYarnArray *)Plan->Yarn->PData[i]->Items[m]; if (Index == pd->code) { int j, k, method1; method1 = 0; int repeat1; //Center À϶§ÀÇ repeatÀ» ¾Ë±âÀ§ÇØ if(pd->method == 2){ //****************************************************************************** lhskys l = pd->code-1; // len1[l] += pd->length*pd->repeat; // yar1[l] += pd->yarns*pd->repeat; // //****************************************************************************** repeat1 = pd->repeat; for (j=m-1;j>-1;j--){ pd = (TYarnArray *)Plan->Yarn->PData[i]->Items[j]; if (pd->method == 1){ //****************************************************************************** l = pd->code-1; // len1[l] += pd->length*(repeat1*2 - 1); // yar1[l] += pd->yarns*(repeat1*2 - 1); // //****************************************************************************** method1 = 1; //reverse ¼öÇàÈ®ÀÎ ¾Æ´Ï¸é nomal À» ¼öÇàÇÏ¿©¾ß Çϱ⶧¹®¿¡ }else j = -1; } for (k=m-1;k>-1;k--){ pd = (TYarnArray *)Plan->Yarn->PData[i]->Items[k]; if (method1 == 0){ //****************************************************************************** l = pd->code-1; // len1[l] += pd->length*(repeat1 - 1); // yar1[l] += pd->yarns*(repeat1 - 1); // //****************************************************************************** }else k = -1; } }else { //****************************************************************************** l = pd->code-1; // len1[l] += pd->length*pd->repeat; // yar1[l] += pd->yarns*pd->repeat; // //****************************************************************************** } } } } } //---------------------------------------------------------------------------- void __fastcall TMainImageForm::ExtractTotal(int Index, int i, AnsiString &length, AnsiString &yarn) { TYarnArray *pd; int cnt = Plan->Yarn->PData[i]->Count; double totlen = 0.0; int totyar = 0; if (cnt) { if (Index >= 0) { for (int m = 0; m < cnt; m++) { pd = (TYarnArray *)Plan->Yarn->PData[i]->Items[m]; if (Index == (pd->code-1)/8) { totlen += pd->length * pd->repeat; totyar += pd->yarns * pd->repeat; } } } else { for (int m = 0; m < cnt; m++) { pd = (TYarnArray *)Plan->Yarn->PData[i]->Items[m]; //============================================================================== lhskys int j, k, method1; method1 = 0; int repeat1; //Center À϶§ÀÇ repeatÀ» ¾Ë±âÀ§ÇØ if(pd->method == 2){ totlen += pd->length*pd->repeat; //*unit; totyar += pd->yarns*pd->repeat; repeat1 = pd->repeat; for (j=m-1;j>-1;j--){ pd = (TYarnArray *)Plan->Yarn->PData[i]->Items[j]; if (pd->method == 1){ totlen += pd->length*(repeat1*2 - 1); //*unit; totyar += pd->yarns*(repeat1*2 - 1); method1 = 1; //reverse ¼öÇàÈ®ÀÎ ¾Æ´Ï¸é nomal À» ¼öÇàÇÏ¿©¾ß Çϱ⶧¹®¿¡ }else j = -1; } for (k=m-1;k>-1;k--){ pd = (TYarnArray *)Plan->Yarn->PData[i]->Items[k]; if (method1 == 0){ totlen += pd->length*(repeat1 - 1); //*unit; totyar += pd->yarns*(repeat1 - 1); }else k = -1; } }else { totlen += pd->length*pd->repeat; //*unit; totyar += pd->yarns*pd->repeat; } //============================================================================== // totlen += pd->length * pd->repeat; // totyar += pd->yarns * pd->repeat; } } if (totlen) { if (CurrentUnit == uCm) length = Format("%.2f", OPENARRAY(TVarRec, (totlen * 2.54))); else length = Format("%.2f", OPENARRAY(TVarRec, (totlen))); yarn = totyar; } else { length = ""; yarn = ""; } } } //---------------------------------------------------------------------------- void __fastcall TMainImageForm::point(TCanvas *area, int sx, int sy, int lx, int ly, Byte *p, int sizex, int sizey, double g) { TPChart *chart = NULL; chart = new TPChart(area, sx, sy, lx, ly, g, g); chart->outline(7); for (int y = 0; y < sizey; y++) { for (int x=0; x < sizex; x++) { if (*p++) chart->point(x, y, clRed); } } delete chart; } //---------------------------------------------------------------------------- bool __fastcall TMainImageForm::ProductDrawTexture (TTexpiaBitmap *Pattern, int &H) { short lx, ly, sy, g[4], tsx[2], tsy[2], tex[2], tey[2]; short ds[4] = { 16, 8, 4, 2}; int i, k, cnt, wid, hei, tempH, rest, tmCnt, nopi; int dstH[4], srcH[4]= {0, 0, 0, 0}; Byte *td, *tmMap[2]; TRect Dst, Src; AnsiString str; TCanvas *Canvas = NULL; Graphics::TBitmap *TexBit = NULL; bool btex = false; btex = Plan->Texture->InitTexture(); if (btex == false) goto fail; sy = 0; dstH[0] = H; for (i = 0; i < Plan->Texture->ChoiceCount; i++) { rest = A4Height - (dstH[i] % A4Height) - 25; wid = Plan->Texture->Choice[i].width; hei = Plan->Texture->Choice[i].height; if (rest < ChartSy*2 + (hei+Plan->Texture->tm[i].cnt)*2 +42) { dstH[i] = dstH[i] + rest + 70; // 25+ 45 rest = A4Height - 70; } for (k = 0; k < 4; k++) { lx = ChartSx*2 + (wid+Plan->Texture->tm[i].cnt)* ds[k]+12; ly = ChartSy*2 + (hei+Plan->Texture->tm[i].cnt)* ds[k]+42; if (lx < A4Width-22 && ly < rest) break; } g[i] = ds[k]; sy += ly; srcH[i] = ly; dstH[i+1] = dstH[i] + ly; } if ((TexBit = new Graphics::TBitmap) == NULL) goto fail; TexBit->PixelFormat = pf15bit; TexBit->Width = Pattern->Width - 22; TexBit->Height = sy; TexBit->Canvas->Pen->Color = clBlack; sy = 0; for (cnt = 0; cnt < Plan->Texture->ChoiceCount; cnt++) { tmCnt = Plan->Texture->tm[cnt].cnt; tmMap[0] = Plan->Texture->tm[cnt].map[0]; tmMap[1] = Plan->Texture->tm[cnt].map[1]; td = Plan->Texture->Choice[cnt].data; wid = Plan->Texture->Choice[cnt].width; hei = Plan->Texture->Choice[cnt].height; TexBit->Canvas->Brush->Color = clWhite; str = Format("Texture size : %d x %d", OPENARRAY(TVarRec, (wid, hei))); TexBit->Canvas->TextOut(11, sy, str); point(TexBit->Canvas, 11, sy+20, wid, hei, td, wid, hei, g[cnt]); lx = ChartSx*2+(wid + tmCnt)*g[cnt]+12; ly = ChartSy*2+(hei + tmCnt)*g[cnt]+42; tsx[0] = 11+ChartSx+wid*g[cnt]+10; tsy[0] = sy+20; point(TexBit->Canvas, tsx[0], tsy[0], tmCnt, hei, tmMap[0], wid, hei, g[cnt]); tsx[1] = 11; tsy[1] = sy + ChartSy + hei * g[cnt] + 31; point(TexBit->Canvas, tsx[1], tsy[1], wid, tmCnt, tmMap[1], wid, hei, g[cnt]); tsx[0] += ChartSx; tex[0] = tsx[0] + tmCnt * g[cnt]; tey[0] = tsy[0] + hei * g[cnt]; tsx[1] += ChartSx; tex[1] = tsx[1] + wid * g[cnt]; tey[1] = tsy[1] + tmCnt * g[cnt]; TexBit->Canvas->MoveTo(tex[1]+10, tsy[1]); TexBit->Canvas->LineTo(tex[0], tsy[1]); TexBit->Canvas->MoveTo(tex[0], tey[0]+ChartSy); TexBit->Canvas->LineTo(tex[0], tsy[1]); TexBit->Canvas->MoveTo(tex[1]+10, tey[1]); TexBit->Canvas->LineTo(tsx[0], tey[1]); TexBit->Canvas->MoveTo(tsx[0], tey[0]+ChartSy); TexBit->Canvas->LineTo(tsx[0], tey[1]); sy += ChartSy * 2 + (hei + tmCnt) * g[cnt] + 42; } Plan->Texture->ExitTexture(); sy = 0; cnt = Plan->Texture->ChoiceCount; if ((Canvas = Pattern->CreateCanvas()) == NULL) return false; for (k = 0; k < Plan->Texture->ChoiceCount; k++) { Dst = Rect(10, dstH[k], TexBit->Width, dstH[k] + srcH[k]); Src = Rect(0, sy, TexBit->Width, sy + srcH[k]); Canvas->CopyRect(Dst, TexBit->Canvas, Src); sy += srcH[k]; } Pattern->DeleteCanvas(Canvas); delete TexBit; H = dstH[cnt-1] + srcH[cnt-1]; return true; fail: if (btex) Plan->Texture->ExitTexture(); if (TexBit) delete TexBit; return false; } //---------------------------------------------------------------------------- int __fastcall TMainImageForm::HeaderYesDrawTexture(TTexpiaBitmap *Pattern, int H) { char *tp; short x, y, sx, syy; int i, j, wid, hei; TCanvas *Canvas = NULL; struct { short size, gap, ld, ru; } ht[4] = { { 10, 20, 2, 18 }, { 20, 10, 2, 8 }, { 40, 5, 1, 4 }, { 50, 4, 1, 3 } }; Byte *td; AnsiString str; sx = 11; syy = H+220; if ((Canvas = Pattern->CreateCanvas()) == NULL) return false; for (i = 0; i < Plan->Texture->ChoiceCount; i++) { td = Plan->Texture->Choice[i].data; wid = Plan->Texture->Choice[i].width; hei = Plan->Texture->Choice[i].height; str = Format("Texture size : %d x %d", OPENARRAY (TVarRec, (wid, hei))); Canvas->Font->Color = clBlack; Canvas->Pen->Color = clBlack; Canvas->Brush->Color = clWhite; Canvas->TextOut(sx, H, str); Canvas->Rectangle(sx, syy-200, sx+200, syy); for (j = 0; j < 4; j++) { if (ht[j].size > wid && ht[j].size > hei) break; } if (j<4) { for (y = 1; y < ht[j].size; y++) { for (x = 1; x < ht[j].size; x++) { Canvas->Pixels[sx+x*ht[j].gap][syy-y*ht[j].gap] = clBlue; } } x = 0; while (1) { x += wid; if (x < ht[j].size) { Canvas->Pen->Color = clBlue; Canvas->MoveTo(sx+x*ht[j].gap, syy-199); Canvas->LineTo(sx+x*ht[j].gap, syy+1); } else break; } y = 0; while (1) { y += hei; if (y < ht[j].size) { Canvas->Pen->Color = clBlue; Canvas->MoveTo(sx+1, syy-y*ht[j].gap); Canvas->LineTo(sx+199, syy-y*ht[j].gap); } else break; } for (y = 0; y < ht[j].size; y++) { tp = td + wid * (y % hei); for (x = 0; x < ht[j].size; x++) { if (*(tp + x % wid)) { Canvas->Pen->Color = clRed; Canvas->Brush->Color = clRed; Canvas->Rectangle(sx+x*ht[j].gap+ht[j].ld, syy-y*ht[j].gap-ht[j].ru, sx+x*ht[j].gap+ht[j].ru, syy-y*ht[j].gap-ht[j].ld); } } } } else { for (y = 0; y < 199; y++) { tp = td + wid * (y % hei); for (x = 0; x < 199; x++) { if (*(tp + x % wid)) { Canvas->Pixels[sx+x+1][syy-y-1] = clRed; } } } } sx += 211; } Pattern->DeleteCanvas(Canvas); return H+231; } //--------------------------------------------------------------------------- // Public Function //--------------------------------------------------------------------------- TPException __fastcall TMainImageForm::InitForm(TPCanvasInfor &ci) { PALETTEENTRY peEntry[256]; RGBQUAD rgb[256]; MainMenuForm->YarnMakerStart = 0; //lhskys ½Ç¸¸µé±â ½ÇÇàÀ» ¾Ë¸² if (Palette==NULL || WorkArea==NULL || Plan==NULL) return EC_MEMORY_LACK; Top = 0; Left = 0; if (Palette->LoadFromFile((DirectoryColor+"\\Textile.fcr").c_str())==false) { GetSystemPaletteEntries(Canvas->Handle, 0, 256, peEntry); Palette->SetNormal(0, 0, 0, 0); Palette->SetNormal(1, 255, 255, 255); Palette->SetNormal(2, 0, 0, 0); for (int i=3; i<255; i++) { Palette->SetNormal(i, peEntry[i].peRed, peEntry[i].peGreen, peEntry[i].peBlue); } Palette->SetNormal(255, 255, 255, 255); } if (!ResizePattern(ci)) return EC_MEMORY_LACK; COLORREF c = PaletteForm->DIB256Palette->GetBGCOLORREF(iMainImage->Bitmap->BitsPerPixel); iMainImage->Bitmap->FillRect(Rect(0, 0, CanvasInfor.Width, CanvasInfor.Height), c); iMainImage->Repaint(); ImageWarp->Bitmap->FillRect(Rect(0, 0, CanvasInfor.Width, 32), c); ImageWarp->Repaint(); ImageWeft->Bitmap->FillRect(Rect(0, 0, 32, CanvasInfor.Height), c); ImageWeft->Repaint(); FileName = Format("Noname%d.wea", OPENARRAY(TVarRec, (Number+1))); iMainImage->Bitmap->FillRect(Rect(0, 0, CanvasInfor.Width, CanvasInfor.Height), PaletteForm->DIB256Palette->GetBGCOLORREF(iMainImage->Bitmap->BitsPerPixel)); ClientWidth = MainForm->ClientWidth-267; ClientHeight = MainForm->ClientHeight-MainForm->StatusBar->Height -GetSystemMetrics(SM_CYSMCAPTION)-GetSystemMetrics(SM_CYMENU)+3; SetCaption(); iMainImage->SetPosition(0, 0); MainForm->UpdateMenuItems(NULL); return EC_NONE; } //--------------------------------------------------------------------------- TPException __fastcall TMainImageForm::InitFormFile(AnsiString dn, AnsiString fn) { int pw, ph, sw, sh, x, y; RGBQUAD rgb[256]; TTexpiaBitmap *tb = NULL; TPCanvasInfor ci; Byte c[256], *bp; TPException ec = EC_NONE; AnsiString Ext; if (Palette==NULL || WorkArea==NULL || Plan==NULL) return EC_MEMORY_LACK; Top = 0; Left = 0; sw = MainForm->ClientWidth-267; sh = MainForm->ClientHeight-MainForm->StatusBar->Height -GetSystemMetrics(SM_CYSMCAPTION)-GetSystemMetrics(SM_CYMENU)+3; if ((tb = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } tb->CoordinateSystem = csBottomLeft; if ((ec = LoadFromFile(fn, tb, Palette, ci))!=EC_NONE) goto fail; if (!ResizePattern(ci)) { ec = EC_MEMORY_LACK; goto fail; } DrawWarpBar(); DrawWeftBar(); if (Plan->Weaving) { if (!iMainImage->Bitmap->Copy(tb, SRCCOPY)) { ec = EC_MEMORY_LACK; goto fail; } } else { Plan->calc_weave(iMainImage->Bitmap); if (sbFrontBack->Down) { Plan->DrawBack(iMainImage->Bitmap, Palette->ColorData[1]->RGB); } else { Plan->DrawFront(iMainImage->Bitmap, Palette->ColorData[1]->RGB); } } pw = iMainImage->Bitmap->Width+PanelVert->Width; ph = iMainImage->Bitmap->Height+PanelHorz->Height; if (sbRuler->Down) { pw += Ruler->Thick; ph += Ruler->Thick; } if (pwSetPosition(0, 0); MainForm->UpdateMenuItems(NULL); return EC_NONE; fail: if (tb) delete tb; return ec; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::ResizePattern(TPCanvasInfor &pi) { if (pi.SizeType!=cstFree) { pi.Width = pi.GetWidth(); pi.Height = pi.GetHeight(); } CanvasInfor = pi; CanvasInfor.SetExtFileOption(); Ruler->DPI = CanvasInfor.DotsPerInch; if (!iMainImage->Create(CanvasInfor.Width, CanvasInfor.Height)) return false; if (!ImageWarp->Bitmap->Create(CanvasInfor.Width, 32, 16)) return false; ImageWeft->Bitmap->CoordinateSystem = csBottomLeft; if (!ImageWeft->Bitmap->Create(32, CanvasInfor.Height, 16)) return false; if (!Plan->Init(CanvasInfor.Width, CanvasInfor.Height)) return false; ReviewStatusBar(); return true; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::EnlargeCanvas(int w, int h) { COLORREF bc = PaletteForm->DIB256Palette->GetBGCOLORREF(iMainImage->Bitmap->BitsPerPixel); WorkArea->ResetRegion(iMainImage); CanvasInfor.SetSize(cstFree, w, h); iMainImage->Bitmap->Resize(w, h, bc); ImageWarp->Bitmap->Resize(w, 32, bc); ImageWeft->Bitmap->Resize(32, h, bc); Plan->Init(w, h); DrawWarpBar(); DrawWeftBar(); if (Plan->Finish) { Plan->calc_weave(iMainImage->Bitmap); if (sbFrontBack->Down) { Plan->DrawBack(iMainImage->Bitmap, Palette->ColorData[1]->RGB); } else { Plan->DrawFront(iMainImage->Bitmap, Palette->ColorData[1]->RGB); } } ::RepaintImage(); ReviewStatusBar(); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::ZoomChange(int zi, int zo, POINT *ptScreen) { POINT ptClient, pt; AnsiString sbZoom; if (zi!=iMainImage->ZoomIn || zo!=iMainImage->ZoomOut) { iMainImageChange(); if (ptScreen) { ptClient = iMainImage->ScreenToClient(*ptScreen); ptClient.y = iMainImage->Height - ptClient.y; iMainImage->SetZoom(zi, zo, &ptClient); pt = Point(ptClient.x, 0); ImageWarp->SetZoom(zi, zo, &ptClient); pt = Point(0, ptClient.y); ImageWeft->SetZoom(zi, zo, &ptClient); } else { iMainImage->SetZoom(zi, zo); ImageWarp->SetZoom(zi, zo); ImageWeft->SetZoom(zi, zo); } ImageWarp->PositionX = iMainImage->PositionX; ImageWeft->PositionY = iMainImage->PositionY; Ruler->Zoom = (double)zi/zo; FullViewForm->SetZoom(); } switch (iMainImage->ZoomIn) { case 1: switch (iMainImage->ZoomOut) { case 1: sbZoom = "Zoom : 1"; break; case 2: sbZoom = "Zoom : 1/2"; break; case 4: sbZoom = "Zoom : 1/4"; break; case 8: sbZoom = "Zoom : 1/8"; break; case 16: sbZoom = "Zoom : 1/16"; break; } break; case 2: sbZoom = "Zoom : 2"; break; case 4: sbZoom = "Zoom : 4"; break; case 8: sbZoom = "Zoom : 8"; break; case 16: sbZoom = "Zoom : 16"; break; } MainForm->StatusBar->Panels->Items[StatusBarZoom]->Text = sbZoom; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::ZoomChangeIn(POINT ptScreen) { switch (iMainImage->ZoomIn) { case 1: switch (iMainImage->ZoomOut) { case 1: ZoomChange(2, 1, &ptScreen); break; case 2: ZoomChange(1, 1, &ptScreen); break; case 4: ZoomChange(1, 2, &ptScreen); break; case 8: ZoomChange(1, 4, &ptScreen); break; case 16: ZoomChange(1, 8, &ptScreen); break; } break; case 2: ZoomChange(4, 1, &ptScreen); break; case 4: ZoomChange(8, 1, &ptScreen); break; case 8: ZoomChange(16, 1, &ptScreen); break; } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::ZoomChangeOut(POINT ptScreen) { switch (iMainImage->ZoomIn) { case 1: switch (iMainImage->ZoomOut) { case 1: ZoomChange(1, 2, &ptScreen); break; case 2: ZoomChange(1, 4, &ptScreen); break; case 4: ZoomChange(1, 8, &ptScreen); break; case 8: ZoomChange(1, 16, &ptScreen); break; } break; case 2: ZoomChange(1, 1, &ptScreen); break; case 4: ZoomChange(2, 1, &ptScreen); break; case 8: ZoomChange(4, 1, &ptScreen); break; case 16: ZoomChange(8, 1, &ptScreen); break; } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::iMainImageChange() { FullViewForm->iMainImageChange(); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::WorkAreaChange() { if (WorkArea->Mask) { MainForm->ECopyItem->Enabled = true; } else { MainForm->ECopyItem->Enabled = false; } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::UpdateImage() { TPoint Size; Size.x = Panel->Width*iMainImage->ZoomOut/iMainImage->ZoomIn; Size.y = Panel->Height*iMainImage->ZoomOut/iMainImage->ZoomIn; if (iMainImage->Bitmap->WidthMax = 0; else sbHorz->Max = iMainImage->Bitmap->Width-Size.x; // sbHorz->SmallChange = Size.x/4; sbHorz->SmallChange = sbHorz->Max/10; sbHorz->LargeChange = sbHorz->Max/5; // ½ºÅ©·Ñ¹Ù À̵¿¹®Á¦ By GreenFish // ¿©±â¼­´Â FormÀÇ Å©±â·Î °áÁ¤ÇÏ¿´´Âµ¥ // ¸·¾Æ¹ö¸®°í FormÀÇ Å©±â°¡ ¾Æ´Ñ // Àüü »çÀÌÁî ±âÁØÀ¸·Î ¹Ù²Þ if (iMainImage->Bitmap->HeightMax = 0; else sbVert->Max = iMainImage->Bitmap->Height-Size.y; sbVert->SmallChange = sbVert->Max/10; // SmallChange´Â Àüü »çÀÌÁîÀÇ 1/10 sbVert->LargeChange = sbVert->Max/5; // LargeChange´Â Àüü »çÀÌÁîÀÇ 1/5 // sbVert->SmallChange = Size.y/4; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Timer200ms() { if (CurrentUnit==uInch) { MainForm->StatusBar->Panels->Items[StatusBarAxis]->Text = Format("%f : %f", OPENARRAY(TVarRec, ((double)CursorPosition.x/CanvasInfor.DotsPerInch, (double)CursorPosition.y/CanvasInfor.DotsPerInch))); } else if (CurrentUnit==uCm) { MainForm->StatusBar->Panels->Items[StatusBarAxis]->Text = Format("%f : %f", OPENARRAY(TVarRec, (2.54*CursorPosition.x/CanvasInfor.DotsPerInch, 2.54*CursorPosition.y/CanvasInfor.DotsPerInch))); } if (sbRuler->Down) Ruler->PositionBar(CursorPosition); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Timer1000ms() { if (iMainImage) iMainImage->OutlineBitmapRgn(); } //--------------------------------------------------------------------- TPException __fastcall TMainImageForm::DrawWarpBar() { TPException ec = EC_NONE; if (sbFrontBack->Down) { if ((ec = Plan->DrawWarpBarBack(ImageWarp->Bitmap)) != EC_NONE) return ec; } else { if ((ec = Plan->DrawWarpBarFront(ImageWarp->Bitmap)) != EC_NONE) return ec; } ImageWarp->Repaint(); return ec; } //--------------------------------------------------------------------- TPException __fastcall TMainImageForm::DrawWeftBar() { TPException ec = EC_NONE; if ((ec = Plan->DrawWeftBar(ImageWeft->Bitmap)) != EC_NONE) return ec; ImageWeft->Repaint(); return ec; } //--------------------------------------------------------------------- void __fastcall TMainImageForm::Weaving() { TPException ec = EC_NONE; if ((ec = DrawWarpBar()) != EC_NONE) goto fail; if ((ec = DrawWeftBar()) != EC_NONE) goto fail; Plan->calc_weave(iMainImage->Bitmap); if (sbFrontBack->Down) { Plan->DrawBack(iMainImage->Bitmap, Palette->ColorData[1]->RGB); } else { Plan->DrawFront(iMainImage->Bitmap, Palette->ColorData[1]->RGB); } ::RepaintImage(); return; fail : EXCEPTION_MESSAGE_OK(ec); } //--------------------------------------------------------------------- TPException __fastcall TMainImageForm::SaveToFile(AnsiString dn, AnsiString fn, TCompressMethod cm) { HANDLE hFile = INVALID_HANDLE_VALUE; int ec = EC_NONE; TEXPIAFILEHEADER tpfh; TRect src; RGBQUAD rgb[256]; TTexpiaBitmap *tag = NULL; if ((hFile = CreateFile((FullPathName(dn, fn)).c_str(), GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_FILE_NOT_CREATE; goto fail; } tpfh.Version = TexVersion('P', 'T', 230); tpfh.CanvasInfor = CanvasInfor; tpfh.BitsPerPixel = iMainImage->Bitmap->BitsPerPixel; tpfh.Compress = cm; src.Left = 0; src.Top = 0; src.Right = iMainImage->Bitmap->Width; src.Bottom = iMainImage->Bitmap->Height; if ((tag = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } MakeTexpiaTag(tag, iMainImage->Bitmap, src, 0); if (!SaveToTexpiaFile(hFile, Palette, tpfh, tag, iMainImage->Bitmap)) goto fail; delete tag; tag = NULL; if ((ec = Plan->SaveToFile(hFile, tpfh.Compress)) != EC_NONE) goto fail; CloseHandle(hFile); DirName = dn; FileName = fn; SetCaption(); return EC_NONE; fail: if (tag) delete tag; if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile); if (ec == EC_NONE) ec = EC_FILE_NOT_WRITE; return ec; } //--------------------------------------------------------------------- bool __fastcall TMainImageForm::FreeNoPrint(TTexpiaBitmap *Pattern) { HDC dc = NULL; int Warp_w, Warp_h, Weft_w, Weft_h; //Width and Height of Images int left, top, iMain_w, iMain_h; TCanvas *Canvas = NULL; RECT range; Warp_h = ImageWarp->Bitmap->Height; Weft_w = ImageWeft->Bitmap->Width; if (WorkArea->Mask) { left = WorkArea->Range.left; top = WorkArea->Range.top; iMain_w = WorkArea->Range.right - WorkArea->Range.left; iMain_h = WorkArea->Range.bottom - WorkArea->Range.top; } else { left = 0; top = 0; iMain_w = iMainImage->Bitmap->Width; iMain_h = iMainImage->Bitmap->Height; } if (!Pattern->Create(iMain_w + 5 + Weft_w,Warp_h + 5 + iMain_h, 16)) goto fail; range.left = 0; range.right = Pattern->Width; range.top = 0; range.bottom = Pattern->Height; Pattern->FillRect(range,clWhite); if ((Canvas = Pattern->CreateCanvas()) == NULL) return false; dc = ImageWarp->Bitmap->CreateDC(); // Create HDC of ImageWarp if (dc) { BitBlt(Canvas->Handle, 0, 0, iMain_w, Warp_h, dc, left, 0, SRCCOPY); ImageWarp->Bitmap->DeleteDC(dc); dc = NULL; } else { #ifdef TPDEBUG SHOWDEBUG; return false; #endif } dc = iMainImage->Bitmap->CreateDC(); //Create HDC of iMainImage if (dc) { BitBlt(Canvas->Handle, 0, Warp_h + 5, iMain_w, iMain_h, dc, left, top, SRCCOPY); iMainImage->Bitmap->DeleteDC(dc); dc = NULL; } else { #ifdef TPDEBUG SHOWDEBUG; return false; #endif } dc = ImageWeft->Bitmap->CreateDC(); // Create HDC of ImageWeft if (dc) { BitBlt(Canvas->Handle, iMain_w + 5, Warp_h + 5, Weft_w, iMain_h, dc, 0, top, SRCCOPY); ImageWeft->Bitmap->DeleteDC(dc); } else { #ifdef TPDEBUG SHOWDEBUG; return false; #endif } Pattern->DeleteCanvas(Canvas); return true; fail: return false; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::FreeYesPrint(TTexpiaBitmap *Pattern) { int w, h, weftW, warpH, Mwid, Mhei, left, top, ttt; TPoint current; HDC hdc = NULL; TRect Dst, Src; TCanvas *Canvas = NULL,*YesCanvas = NULL; TTexpiaBitmap *YesBit = NULL; RECT range; w = GetDeviceCaps(Printer()->Handle, HORZRES)*160/ GetDeviceCaps(Printer()->Handle, LOGPIXELSX); h = GetDeviceCaps(Printer()->Handle, VERTRES)*160/ GetDeviceCaps(Printer()->Handle, LOGPIXELSY); if((YesBit = new TTexpiaBitmap) == NULL) goto fail; if (!YesBit->Create(w,h, 16)) goto fail; range.left = 0; range.right = YesBit->Width; range.top = 0; range.bottom = YesBit->Height; YesBit->FillRect(range,clWhite); current.x = 10; current.y = 20; ttt = 20; if (YarnDraw(YesBit, current.x, ttt) == false) goto fail; current.y = HeaderYesDrawTexture(YesBit, ttt); weftW = ImageWeft->Bitmap->Width; warpH = ImageWarp->Bitmap->Height; if (WorkArea->Mask) { left = WorkArea->Range.left; top = WorkArea->Range.top; Mwid = WorkArea->Range.right - WorkArea->Range.left; Mhei = WorkArea->Range.bottom - WorkArea->Range.top; } else { left = 0; top = 0; Mwid = iMainImage->Bitmap->Width; Mhei = iMainImage->Bitmap->Height; } if (w > Mwid + weftW + 5){ if (!Pattern->Create(w,Mhei + current.y + warpH + 5,16)) goto fail; } else { if (!Pattern->Create(Mwid + weftW + 5,Mhei + current.y + warpH + 5,16)) goto fail; } range.left = 0; range.right = Pattern->Width; range.top = 0; range.bottom = Pattern->Height; Pattern->FillRect(range,clWhite); if ((Canvas = Pattern->CreateCanvas()) == NULL) return false; hdc = ImageWarp->Bitmap->CreateDC(); if (hdc) { BitBlt(Canvas->Handle, 0, 0, Mwid, warpH, hdc, left, 0, SRCCOPY); ImageWarp->Bitmap->DeleteDC(hdc); hdc = NULL; } else { #ifdef TPDEBUG SHOWDEBUG; return false; #endif } hdc = iMainImage->Bitmap->CreateDC(); if (hdc) { BitBlt(Canvas->Handle, 0, warpH + 5, Mwid, Mhei, hdc, left, top, SRCCOPY); iMainImage->Bitmap->DeleteDC(hdc); hdc = NULL; } else { #ifdef TPDEBUG SHOWDEBUG; return false; #endif } hdc = ImageWeft->Bitmap->CreateDC(); if (hdc) { BitBlt(Canvas->Handle, Mwid + 5, warpH + 5, weftW, Mhei, hdc, 0, top, SRCCOPY); ImageWeft->Bitmap->DeleteDC(hdc); hdc = NULL; } else { #ifdef TPDEBUG SHOWDEBUG; return false; #endif } Dst = Rect(0, Mhei + 5 + warpH, w, Pattern->Height); Src = Rect(0, 0, w, current.y); if ((YesCanvas = YesBit->CreateCanvas()) == NULL) return false; Canvas->CopyRect(Dst, YesCanvas, Src); YesBit->DeleteCanvas(YesCanvas); Pattern->DeleteCanvas(Canvas);; delete YesBit; return true; fail: if (YesBit) delete YesBit; return false; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::A4NoPrint(TTexpiaBitmap *Pattern) { int weftW, warpH, Mwid, Mhei, left, Hei_gab; HDC dcSrc[3] = { NULL, NULL, NULL }, dcDst = NULL; RECT range; if (!Pattern->Create( GetDeviceCaps(Printer()->Handle, HORZRES)*160/ GetDeviceCaps(Printer()->Handle, LOGPIXELSX), GetDeviceCaps(Printer()->Handle, VERTRES)*160/ GetDeviceCaps(Printer()->Handle, LOGPIXELSY), 16)) goto fail; range.left = 0; range.right = Pattern->Width; range.top = 0; range.bottom = Pattern->Height; Pattern->FillRect(range,clWhite); A4Width = Pattern->Width; A4Height = Pattern->Height; DrawOutLine(Pattern, 0); weftW = ImageWeft->Bitmap->Width; warpH = ImageWarp->Bitmap->Height; left = 0; Mwid = iMainImage->Bitmap->Width; Mhei = iMainImage->Bitmap->Height; if (Mwid > A4Width - weftW - 16) Mwid = A4Width - weftW - 16; if (Mhei > A4Height - warpH - 76) Mhei = A4Height - warpH - 76; Hei_gab = iMainImage->Bitmap->Height - Mhei; //Determine the start point if ((dcDst = Pattern->CreateDC()) == NULL) goto fail; if ((dcSrc[0] = ImageWarp->Bitmap->CreateDC()) == NULL) goto fail; BitBlt(dcDst, 5, 40, Mwid, warpH, dcSrc[0], left, 0, SRCCOPY); ImageWarp->Bitmap->DeleteDC(dcSrc[0]); dcSrc[0] = NULL; if ((dcSrc[1] = iMainImage->Bitmap->CreateDC()) == NULL) goto fail; BitBlt(dcDst, 5, warpH + 45, Mwid, Mhei, dcSrc[1], 0, Hei_gab, SRCCOPY); iMainImage->Bitmap->DeleteDC(dcSrc[1]); dcSrc[1] = NULL; if ((dcSrc[2] = ImageWeft->Bitmap->CreateDC()) == NULL) goto fail; BitBlt(dcDst, Mwid + 10, warpH + 45, weftW, Mhei, dcSrc[2], 0, Hei_gab, SRCCOPY); ImageWeft->Bitmap->DeleteDC(dcSrc[2]); dcSrc[2] = NULL; Pattern->DeleteDC(dcDst); return true; fail: if (dcDst) Pattern->DeleteDC(dcDst); if (dcSrc[2]) ImageWeft->Bitmap->DeleteDC(dcSrc[2]); if (dcSrc[1]) iMainImage->Bitmap->DeleteDC(dcSrc[1]); if (dcSrc[0]) ImageWarp->Bitmap->DeleteDC(dcSrc[0]); return false; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::A4YesPrint(TTexpiaBitmap *Pattern) { int weftW, warpH, Mwid, Mhei, dh, left, Hei_gab, ttt; TPoint current; HDC hdc = NULL,dcDst; TRect Dst, Src; TCanvas *Canvas = NULL,*YesCanvas; TTexpiaBitmap *YesBit = NULL; RECT range; if (!Pattern->Create( GetDeviceCaps(Printer()->Handle, HORZRES)*160/ GetDeviceCaps(Printer()->Handle, LOGPIXELSX), GetDeviceCaps(Printer()->Handle, VERTRES)*160/ GetDeviceCaps(Printer()->Handle, LOGPIXELSY), 16)) goto fail; range.left = 0; range.right = Pattern->Width; range.top = 0; range.bottom = Pattern->Height; Pattern->FillRect(range,clWhite); A4Width = Pattern->Width; A4Height = Pattern->Height; DrawOutLine(Pattern, 0); YesBit = new TTexpiaBitmap; if (YesBit == NULL) goto fail; if (!YesBit->Create(A4Width - 1,A4Height - 1, 16)) goto fail; range.left = 0; range.right = YesBit->Width; range.top = 0; range.bottom = YesBit->Height; YesBit->FillRect(range,clWhite); current.x = 10; current.y = 20; ttt = 20; if (YarnDraw(YesBit, current.x, ttt) == false) goto fail; current.y = HeaderYesDrawTexture(YesBit, ttt); weftW = ImageWeft->Bitmap->Width; warpH = ImageWarp->Bitmap->Height; left = 0; Mwid = iMainImage->Bitmap->Width; Mhei = iMainImage->Bitmap->Height; dh = A4Height - current.y - 70 - warpH; if (Mwid > A4Width - weftW - 16) Mwid = A4Width - weftW - 16; if (Mhei > dh) Mhei = dh; Hei_gab = iMainImage->Bitmap->Height - Mhei; //Determine the start point if ((dcDst = Pattern->CreateDC()) == NULL) goto fail; hdc = ImageWarp->Bitmap->CreateDC(); if (hdc) { BitBlt(dcDst, 5, 40, Mwid, warpH, hdc, left, 0, SRCCOPY); ImageWarp->Bitmap->DeleteDC(hdc); hdc = NULL; } else goto fail; hdc = iMainImage->Bitmap->CreateDC(); if (hdc) { BitBlt(dcDst, 5, warpH + 45, Mwid, Mhei, hdc, 0, Hei_gab, SRCCOPY); iMainImage->Bitmap->DeleteDC(hdc); hdc = NULL; } else goto fail; hdc = ImageWeft->Bitmap->CreateDC(); if (hdc) { BitBlt(dcDst, Mwid + 10, warpH + 45, weftW, Mhei, hdc, 0, Hei_gab, SRCCOPY); ImageWeft->Bitmap->DeleteDC(hdc); hdc = NULL; } else goto fail; Dst = Rect(5, Mhei + 45 + warpH, A4Width - 6, Mhei + 45 + warpH + current.y); Src = Rect(5, 0, A4Width - 6, current.y); Pattern->DeleteDC(dcDst); if ((Canvas = Pattern->CreateCanvas()) == NULL) return false; if(( YesCanvas = YesBit->CreateCanvas()) == NULL) return false; Canvas->CopyRect(Dst, YesCanvas, Src); Pattern->DeleteCanvas(Canvas); Pattern->DeleteCanvas(YesCanvas); delete YesBit; return true; fail: if (dcDst) Pattern->DeleteDC(dcDst); if (YesBit) delete YesBit; return false; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::A4ProductDataPrint(TTexpiaBitmap *Pattern, String waWidth, String weWidth) { int currentH, clientH, w, h, temp, sheet; int DTextHeight, DYarnHeight, DTableHeight, DTextureHeight; int warpcnt, weftcnt; int i; POINT p; RECT range; int number; warpcnt = Plan->Yarn->Array[0]->Count; weftcnt = Plan->Yarn->Array[1]->Count; w = GetDeviceCaps(Printer()->Handle, HORZRES)*160/ GetDeviceCaps(Printer()->Handle, LOGPIXELSX); h = GetDeviceCaps(Printer()->Handle, VERTRES)*160/ GetDeviceCaps(Printer()->Handle, LOGPIXELSY); A4Height = h; A4Width = w; clientH = h - 70; // (45+25) DTextHeight = Plan->Yarn->ChoiceCount * 20; DYarnHeight = GetYarnHeight(); if (warpcnt > weftcnt) DTableHeight = 30*3 + 25*12*2 + 25*(2+warpcnt); //Warp(Weft)_H*2 + TableCells_H*Cell_Count + TableCells_H*Cell_Count; else DTableHeight = 30*3 + 25*12*2 + 25 * (2 + weftcnt); if (GetTextureHeight(w, DTextureHeight) == false) return false; temp = DTextHeight + DYarnHeight + DTableHeight + DTextureHeight; sheet = temp / clientH + 1; p.x = 10; p.y = 45; currentH = 45; if(!Pattern->Create(w, temp + 2000, 16)) goto fail; Pattern->FillRect(Rect(0, 0, Pattern->Width, Pattern->Height), clWhite); if (YarnDraw(Pattern, p.x, currentH, true, h) == false) return false; /* // page°¡ ³Ñ¾î°¥¶§ À߸®´Â Çö»ó ¼öÁ¤ Àü(2000.5.17) if(DTableHeight > (A4Height - currentH)){ number = (A4Height - currentH) /25 - 15; currentH = TableDraw(Pattern, currentH, number, waWidth, weWidth); } else { currentH = TableDraw(Pattern, currentH, 39, waWidth, weWidth); } // currentH += 20; SubTableDtaw¿¡¼­ ÇØÁØ´Ù. */ currentH = TableDraw(Pattern, currentH, waWidth, weWidth); // page°¡ ³Ñ¾î°¥¶§ À߸®´Â Çö»ó ¼öÁ¤(2000.5.17) if (ProductDrawTexture(Pattern, currentH) == false) return false; sheet = (currentH / A4Height) + 1; Pattern->Resize(w,sheet * A4Height,clWhite); for (i = 0; i < sheet; i++) DrawOutLine(Pattern, A4Height*i); return true; fail: return false; } //---------------------------------------------------------------------------- bool __fastcall TMainImageForm::A4FrontBackPrint(TTexpiaBitmap *Pattern, bool &back) { int weftW, warpH, Mwid, Mhei, str_length; HDC hdc = NULL; TRect Temp; AnsiString F_str, B_str; TTexpiaBitmap *TempBitmap = NULL; TCanvas *Canvas = NULL; RECT range; if (Plan->CheckFrontBackPrint()) { if(!Pattern->Create(GetDeviceCaps(Printer()->Handle, HORZRES)*160/ GetDeviceCaps(Printer()->Handle, LOGPIXELSX), GetDeviceCaps(Printer()->Handle, VERTRES)*160/ GetDeviceCaps(Printer()->Handle, LOGPIXELSY), 16)) goto fail; range.left = 0; range.right = Pattern->Width; range.top = 0; range.bottom = Pattern->Height; Pattern->FillRect(range,clWhite); A4Width = Pattern->Width; A4Height = Pattern->Height; DrawOutLine(Pattern, 0); if ((Canvas = Pattern->CreateCanvas()) == NULL) return false; Canvas->Font->Size = 18; Canvas->Font->Color = clBlue; Canvas->Font->Name=fsItalic; F_str = "[ FRONT SIDE ]"; B_str = "[ BACK SIDE ]"; Canvas->TextOut(70, 48 ,F_str ); Canvas->TextOut(70, A4Height/2 + 19 -3, B_str); str_length = Canvas->TextWidth(F_str); Canvas->Pen->Width = 3; Canvas->MoveTo(80 + str_length, 62); Canvas->LineTo(A4Width-10, 62); Canvas->LineTo(A4Width - 10, A4Height/2 + 3); Canvas->LineTo(10, A4Height/2 +3); Canvas->LineTo(10, 62); Canvas->LineTo(60, 62); str_length = Canvas->TextWidth(B_str); Canvas->MoveTo(80 + str_length, A4Height/2 + 30); Canvas->LineTo(A4Width-10, A4Height/2 + 30); Canvas->LineTo(A4Width - 10, A4Height - 31); Canvas->LineTo(10, A4Height - 31); Canvas->LineTo(10, A4Height/2 + 30); Canvas->LineTo(60, A4Height/2 + 30); weftW = ImageWeft->Bitmap->Width; warpH = ImageWarp->Bitmap->Height; Mwid = iMainImage->Bitmap->Width; Mhei = iMainImage->Bitmap->Height; if (Mwid > A4Width - weftW - 46) Mwid = A4Width - weftW - 46; if (Mhei > A4Height/2 - warpH - 89) Mhei = A4Height/2 - warpH - 89; TempBitmap = new TTexpiaBitmap; if (TempBitmap == NULL) goto fail; //Front of ImageWarp if (TempBitmap->Create(Mwid, warpH, 16) == false) goto fail; Plan->DrawWarpBarFront(TempBitmap); hdc = TempBitmap->CreateDC(); if (hdc) { BitBlt(Canvas->Handle, 20, 80, Mwid, warpH, hdc, 0, 0, SRCCOPY); TempBitmap->DeleteDC(hdc); hdc = NULL; } else goto fail; //Front of iMainImage if (TempBitmap->Create(Mwid, Mhei, 16) == false) goto fail; Plan->DrawFront(TempBitmap, Palette->ColorData[1]->RGB); hdc = TempBitmap->CreateDC(); if (hdc) { BitBlt(Canvas->Handle, 20, warpH + 85, Mwid, Mhei, hdc, 0, 0, SRCCOPY); TempBitmap->DeleteDC(hdc); hdc = NULL; } else goto fail; //Front and Back of ImageWeft if (TempBitmap->Create(weftW, Mhei, 16) == false) goto fail; Plan->DrawWeftBar(TempBitmap); hdc = TempBitmap->CreateDC(); if (hdc) { BitBlt(Canvas->Handle, Mwid + 30, warpH + 85, weftW, Mhei, hdc, 0, 0, SRCCOPY); BitBlt(Canvas->Handle, Mwid + 30, A4Height/2 + warpH + 53, weftW, Mhei, hdc, 0, 0, SRCCOPY); TempBitmap->DeleteDC(hdc); hdc = NULL; } else goto fail; //Back of ImageWarp if (TempBitmap->Create(Mwid, warpH, 16) == false) goto fail; Plan->DrawWarpBarBack(TempBitmap); hdc = TempBitmap->CreateDC(); if (hdc) { BitBlt(Canvas->Handle, 20, A4Height/2 + 48, Mwid, warpH, hdc, 0, 0, SRCCOPY); TempBitmap->DeleteDC(hdc); hdc = NULL; } else goto fail; //Back of iMainImage if (TempBitmap->Create(Mwid, Mhei, 16) == false) goto fail; Plan->DrawBack(TempBitmap, Palette->ColorData[1]->RGB); hdc = TempBitmap->CreateDC(); if (hdc) { BitBlt(Canvas->Handle, 20, A4Height/2 + warpH + 53, Mwid, Mhei, hdc, 0, 0, SRCCOPY); TempBitmap->DeleteDC(hdc); hdc = NULL; } else goto fail; delete TempBitmap; Pattern->DeleteCanvas(Canvas); back = true; return true; } else { ShowMessage(IDS_MAINIMAGE_MESSAGE); back = false; return true; } fail: if (TempBitmap) delete TempBitmap; return false; } //---------------------------------------------------------------------------- void __fastcall TMainImageForm::EditCopy() { RGBQUAD rgb[256]; BITMAPHANDLE bh, *pbh; int w, h, i, x, y; HDC dcSrc = NULL, dcDst = NULL, dcMask = NULL; HGLOBAL hMem = NULL; Byte *lpData = NULL; TClipboardInfo cbi; TColorData *cd; Byte *mp, *bp; COLORREF c; bool bClipboard = false; TPException ec = EC_NONE; TCursor cursor = Screen->Cursor; Screen->Cursor = crHourGlass; if (WorkArea->Mask) { memset(&bh, 0, sizeof(BITMAPHANDLE)); w = WorkArea->Range.right-WorkArea->Range.left; h = WorkArea->Range.bottom-WorkArea->Range.top; // if (L_CreateBitmap(&bh, TYPE_CONV, w, h, iMainImage->Bitmap->BitsPerPixel, ORDER_BGR, NULL, TOP_LEFT)<1) goto next1; if ((dcDst = L_CreateLeadDC(&bh))==NULL) goto next1; if ((dcSrc = iMainImage->Bitmap->CreateDC())==NULL) goto next1; BitBlt(dcDst, 0, 0, w, h, dcSrc, WorkArea->Range.left, WorkArea->Range.top, SRCCOPY); iMainImage->Bitmap->DeleteDC(dcSrc); dcSrc = NULL; if ((dcMask = WorkArea->Mask->CreateDC())==NULL) goto next1; BitBlt(dcDst, 0, 0, w, h, dcMask, 0, 0, SRCAND); WorkArea->Mask->DeleteDC(dcMask); dcMask = NULL; L_DeleteLeadDC(dcDst); dcDst = NULL; if (L_CopyToClipboard(MainForm->Handle, &bh)<1) goto next1; L_FreeBitmap(&bh); goto next2; next1: if (dcDst) { if (dcMask) WorkArea->Mask->DeleteDC(dcMask); if (dcSrc) iMainImage->Bitmap->DeleteDC(dcSrc); L_DeleteLeadDC(dcDst); } L_FreeBitmap(&bh); next2: // if (!OpenClipboard(MainForm->Handle)) { ec = EC_CLIPBOARD_NOT_OPEN; goto fail; } bClipboard = true; if (MainForm->ClipboardFormat) { cbi.Version = 0; cbi.Time = clock(); cbi.Width = w; cbi.Height = h; cbi.Mask = true; cbi.BitsPerPixel = 15; if ((hMem = GlobalAlloc(GHND, sizeof(TClipboardInfo)+sizeof(COLORREF)+ 2*cbi.Width*cbi.Height+WorkArea->Mask->BytesPerLine*cbi.Height))==NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((lpData = (Byte *)GlobalLock(hMem))==NULL) { ec = EC_MEMORY_LACK; goto fail; } memcpy(lpData, &cbi, sizeof(TClipboardInfo)); lpData += sizeof(TClipboardInfo); c = Palette->Color[1]; memcpy(lpData, &c, sizeof(COLORREF)); lpData += sizeof(COLORREF); if (!iMainImage->Bitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; yBitmap->GetScanLine(WorkArea->Range.top+y)+2*WorkArea->Range.left; memcpy(lpData, bp, 2*cbi.Width); lpData += 2*cbi.Width; } iMainImage->Bitmap->StopScanLine(); if (!WorkArea->Mask->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; yMask->GetScanLine(y); for (x=0; xMask->BytesPerLine; x++) { *(lpData+x) = ~*(mp+x); } lpData += WorkArea->Mask->BytesPerLine; } WorkArea->Mask->StopScanLine(); GlobalUnlock(hMem); SetClipboardData(MainForm->ClipboardFormat, hMem); } CloseClipboard(); } else { if ((pbh = iMainImage->Bitmap->Handle)==NULL) { ec = EC_CLIPBOARD_NOT_OPEN; goto fail; } // L_CopyToClipboard(MainForm->Handle, &bh); // if (!OpenClipboard(MainForm->Handle)) { ec = EC_CLIPBOARD_NOT_OPEN; goto fail; } bClipboard = true; if (MainForm->ClipboardFormat) { cbi.Version = 0; cbi.Time = clock(); cbi.Width = iMainImage->Bitmap->Width; cbi.Height = iMainImage->Bitmap->Height; cbi.Mask = false; cbi.BitsPerPixel = 15; if ((hMem = GlobalAlloc(GHND, sizeof(TClipboardInfo)+sizeof(COLORREF)+2*cbi.Width*cbi.Height))) { ec = EC_MEMORY_LACK; goto fail; } if ((lpData = (Byte *)GlobalLock(hMem))==NULL) { ec = EC_MEMORY_LACK; goto fail; } memcpy(lpData, &cbi, sizeof(TClipboardInfo)); lpData += sizeof(TClipboardInfo); c = Palette->Color[1]; memcpy(lpData, &c, sizeof(COLORREF)); lpData += sizeof(COLORREF); if (!iMainImage->Bitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; yBitmap->GetScanLine(y); memcpy(lpData, bp, 2*cbi.Width); lpData += 2*cbi.Width; } iMainImage->Bitmap->StopScanLine(); GlobalUnlock(hMem); GlobalFree(hMem); SetClipboardData(MainForm->ClipboardFormat, hMem); } CloseClipboard(); } Screen->Cursor = cursor; return; fail: if (bClipboard) { if (hMem) { if (lpData) { if (WorkArea->Mask) WorkArea->Mask->StopScanLine(); iMainImage->Bitmap->StopScanLine(); GlobalUnlock(hMem); } GlobalFree(hMem); } CloseClipboard(); } if (WorkArea->Mask) { if (dcDst) { if (dcMask) WorkArea->Mask->DeleteDC(dcMask); if (dcSrc) iMainImage->Bitmap->DeleteDC(dcSrc); L_DeleteLeadDC(dcDst); } L_FreeBitmap(&bh); } Screen->Cursor = cursor; EXCEPTION_MESSAGE_OK(ec); } //---------------------------------------------------------------------------- void __fastcall TMainImageForm::ChangeColor(int i) { int k, m, n, cnt, num = 0; TYarnChoice *yarnchoice; WORD *yc, bgc; if (PaletteForm->DIB256Palette->ChoiceIndex == 1) { bgc = RGBToColor15(Palette->ColorData[1]->RGB); if (sbFrontBack->Down) Plan->ChangeBackGroundColorBack(iMainImage->Bitmap, bgc); else Plan->ChangeBackGroundColorFront(iMainImage->Bitmap, bgc); iMainImage->Repaint(); FullViewForm->InitForm(iMainImage); } else { if (Plan->Yarn->ChoiceCount > 0) { yarnchoice = Plan->Yarn->Choice; for (k = 0; k < Plan->Yarn->ChoiceCount; k++) { if (yarnchoice[k].Data) { num += 8*yarnchoice[k].Data->Colors; } } yc = (WORD *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, num*sizeof(WORD)); num = 0; for (k = 0; k < Plan->Yarn->ChoiceCount; k++) { if (yarnchoice[k].Data) { cnt = yarnchoice[k].Data->Colors; for (m = 0; m < 8; m++) { if (yarnchoice[k].Color[m]) { for (n = 0; n < cnt; n++) { if (i == yarnchoice[k].Color[m][n]->Index) { yarnchoice[k].Color[m][n]->SetColor(Palette->ColorData[i], i); yarnchoice[k].Data->Color[n]->SetColor(Palette->ColorData[i]); yc[num] = (k<<11)|(m<<8)|(n<<3); num++; if (FOnYarnColorChange) FOnYarnColorChange(k, m, n, i); } } } } } } DrawWarpBar(); DrawWeftBar(); if (sbFrontBack->Down) Plan->ChangeColorBack(iMainImage->Bitmap, yc, num); else Plan->ChangeColorFront(iMainImage->Bitmap, yc, num); HeapFree(GetProcessHeap(), 0, yc); iMainImage->Repaint(); FullViewForm->InitForm(iMainImage); } } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::RearrangeColor() { int i, k, m, n, cnt, num = 0; WORD *yc, bgc; TYarnChoice *yarnchoice; if (PaletteForm->DIB256Palette->ChoiceIndex == 1) { bgc = RGBToColor15(Palette->ColorData[1]->RGB); if (sbFrontBack->Down) Plan->ChangeBackGroundColorBack(iMainImage->Bitmap, bgc); else Plan->ChangeBackGroundColorFront(iMainImage->Bitmap, bgc); } else { if (Plan->Yarn->ChoiceCount > 0) { yarnchoice = Plan->Yarn->Choice; for (k = 0; k < Plan->Yarn->ChoiceCount; k++) { if (yarnchoice[k].Data) { num += 8*yarnchoice[k].Data->Colors; } } yc = (WORD *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, num*sizeof(WORD)); num = 0; for (k = 0; k < Plan->Yarn->ChoiceCount; k++) { if (yarnchoice[k].Data) { cnt = yarnchoice[k].Data->Colors; for (m = 0; m < 8; m++) { if (yarnchoice[k].Color[m]) { for (n = 0; n < cnt; n++) { i = yarnchoice[k].Color[m][n]->Index; yarnchoice[k].Color[m][n]->SetColor(Palette->ColorData[i], i); yarnchoice[k].Data->Color[n]->SetColor(Palette->ColorData[i]); yc[num] = (k<<11)|(m<<8)|(n<<3); num++; if (FOnYarnColorChange) FOnYarnColorChange(k, m, n, i); } } } } } DrawWarpBar(); DrawWeftBar(); if (sbFrontBack->Down) Plan->ChangeColorBack(iMainImage->Bitmap, yc, num); else Plan->ChangeColorFront(iMainImage->Bitmap, yc, num); HeapFree(GetProcessHeap(), 0, yc); } } } //--------------------------------------------------------------------------- // External Function //--------------------------------------------------------------------------- void __fastcall RepaintImage() { if (MainImageForm) { MainImageForm->iMainImage->Repaint(); FullViewForm->InitForm(MainImageForm->iMainImage); } } //--------------------------------------------------------------------- void __fastcall RepaintColor() { if (MainImageForm) { MainImageForm->iMainImage->Repaint(); FullViewForm->InitForm(MainImageForm->iMainImage); PaletteForm->InitForm(MainImageForm->Palette); ColorLibraryForm->View(); } } //--------------------------------------------------------------------------- void __fastcall RepaintYarnColor() { if (MainImageForm) { MainImageForm->RearrangeColor(); MainImageForm->iMainImage->Repaint(); FullViewForm->InitForm(MainImageForm->iMainImage); PaletteForm->InitForm(MainImageForm->Palette); ColorLibraryForm->View(); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::ApplyEnvironment() { TIniFile *IniFile = new TIniFile(DirectoryItem+"\\Environment.ini"); if (IniFile) { WorkArea->undoMax = IniFile->ReadInteger("Window", "MaxUndo", 5); delete IniFile; } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::RatioZoom(int r) //by qe { GetCursorPos(&ptScreen); switch (r){ case 116 : ZoomChange(1, 16, &ptScreen); break; case 18 : ZoomChange(1, 8, &ptScreen); break; case 14 : ZoomChange(1, 4, &ptScreen); break; case 12 : ZoomChange(1, 2, &ptScreen); break; case 1 : ZoomChange(1, 1, &ptScreen); break; case 2 : ZoomChange(2, 1, &ptScreen); break; case 4 : ZoomChange(4, 1, &ptScreen); break; case 8 : ZoomChange(8, 1, &ptScreen); break; case 16 : ZoomChange(16, 1, &ptScreen); break; } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::sbCrossLineClick(TObject *Sender) { if (sbCrossLine->Down) { // for CrossLine MainImageForm->iMainImage->Cross = true; // by playzzang MainImageForm->iMainImage->CrossLine = true; MainImageForm->iMainImage->OnPaintCrossLine=PaintCrossLine; } else { MainImageForm->iMainImage->Cross = false; MainImageForm->iMainImage->CrossLine = false; MainImageForm->iMainImage->OnPaintCrossLine=NULL; } } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintLineLocate(TObject *Sender, HDC formDC) { // HDC formDC; HBRUSH hOldBrush; HPEN hOldPen; int nDrawMode; int NOL=NumberOfLine; hOldBrush = SelectObject(formDC, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(formDC); hOldPen = SelectObject(formDC, GetStockObject(BLACK_PEN)); SetROP2(formDC, R2_NOT); // formDC = iMainImage->Canvas->Handle; POINT pt; POINT First; POINT Second; LineListData *line; for(int i=0;iItems[i]; First=line->First; Second=line->Second; pt.x = iMainImage->BitmapToCanvasX(First.x); pt.y = iMainImage->BitmapToCanvasY(First.y); MoveToEx(formDC, pt.x, pt.y, NULL); pt.x = iMainImage->BitmapToCanvasX(Second.x); pt.y = iMainImage->BitmapToCanvasY(Second.y); LineTo(formDC, pt.x, pt.y); } SetROP2(formDC, nDrawMode); SelectObject(formDC, hOldBrush); SelectObject(formDC, hOldPen); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::DrawLineLocate(POINT First, POINT Second, int NOL) { NumberOfLine=NOL; static RECT oldlines=Rect(0,0,0,0); if(NOL==0) { LineList->Clear(); iMainImage->OnPaintLocate = NULL; InvalidateRect(iMainImage->Parent->Handle,&oldlines,false); } else { iMainImage->OnPaintLocate = PaintLineLocate;/////////////////by jeegeo LineListData *line=new LineListData; static int cnt = 0; if(cnt==0)LineList->Clear(); cnt++; line->First=First; line->Second=Second; LineList->Add(line); if(NOL==cnt) { cnt=0; line=(LineListData *)LineList->Items[0]; int minx,miny,maxx,maxy; minx = iMainImage->BitmapToCanvasX(min( line->First.x, line->Second.x )); maxx = iMainImage->BitmapToCanvasX(max( line->First.x, line->Second.x )); miny = iMainImage->BitmapToCanvasY(min( line->First.y, line->Second.y )); maxy = iMainImage->BitmapToCanvasY(max( line->First.y, line->Second.y )); for(int i=1;iItems[i]; minx = min(minx,iMainImage->BitmapToCanvasX(min(line->First.x,line->Second.x))); maxx = max(maxx,iMainImage->BitmapToCanvasX(max(line->First.x,line->Second.x))); miny = min(miny,iMainImage->BitmapToCanvasY(min(line->First.y,line->Second.y))); maxy = max(maxy,iMainImage->BitmapToCanvasY(max(line->First.y,line->Second.y))); } RECT rc = {minx-1,miny-1,maxx+1,maxy+1}; #if defined(TEXTILE) #if defined(CARPET) InvalidateRect(iMainImage->Parent->Handle,&oldlines,false); InvalidateRect(iMainImage->Parent->Handle,&rc,false); #else #endif #else InvalidateRect(iMainImage->Parent->Handle,&oldlines,false); InvalidateRect(iMainImage->Parent->Handle,&rc,false); #endif oldlines=rc; } } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintFreeLineLocate(TObject *Sender, HDC formDC) { // HDC formDC; HBRUSH hOldBrush; HPEN hOldPen; int nDrawMode; // int NOL=NumberOfLine; hOldBrush = SelectObject(formDC, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(formDC); hOldPen = SelectObject(formDC, GetStockObject(BLACK_PEN)); SetROP2(formDC, R2_NOT); // formDC = iMainImage->Canvas->Handle; POINT pt; POINT First; POINT Second; LineListData *line; if(LineList->Count>0){ line=(LineListData *)LineList->Items[0]; Second=line->Second; pt.x = iMainImage->BitmapToCanvasX(Second.x); pt.y = iMainImage->BitmapToCanvasY(Second.y); MoveToEx(formDC, pt.x, pt.y, NULL); } for(int i=1;iCount;i++){ line=(LineListData *)LineList->Items[i]; First=line->First; Second=line->Second; pt.x = iMainImage->BitmapToCanvasX(First.x); pt.y = iMainImage->BitmapToCanvasY(First.y); MoveToEx(formDC, pt.x, pt.y, NULL); pt.x = iMainImage->BitmapToCanvasX(Second.x); pt.y = iMainImage->BitmapToCanvasY(Second.y); LineTo(formDC, pt.x, pt.y); } SetROP2(formDC, nDrawMode); SelectObject(formDC, hOldBrush); SelectObject(formDC, hOldPen); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::DrawFreeLineLocate(POINT Second, int resetCount) { static RECT oldlines=Rect(0,0,0,0); static POINT First = Second; if(resetCount==0) { First=Second; LineList->Clear(); iMainImage->OnPaintLocate = NULL; InvalidateRect(iMainImage->Parent->Handle,&oldlines,false); } else { iMainImage->OnPaintLocate = PaintFreeLineLocate;/////////////////by jeegeo LineListData *line; if(resetCount==-1||resetCount==-2){ line=new LineListData; line->First=First; line->Second=Second; LineList->Add(line); First=Second; } else { while(LineList->Count>resetCount){ line = (LineListData *)LineList->Last(); LineList->Remove(line); } First= ((LineListData *)LineList->Last())->Second; } line=(LineListData *)LineList->Items[0]; int minx,miny,maxx,maxy; minx = iMainImage->BitmapToCanvasX(min( line->First.x, line->Second.x )); maxx = iMainImage->BitmapToCanvasX(max( line->First.x, line->Second.x )); miny = iMainImage->BitmapToCanvasY(min( line->First.y, line->Second.y )); maxy = iMainImage->BitmapToCanvasY(max( line->First.y, line->Second.y )); for(int i=1;iCount;i++){ line=(LineListData *)LineList->Items[i]; minx = min(minx,iMainImage->BitmapToCanvasX(min(line->First.x,line->Second.x))); maxx = max(maxx,iMainImage->BitmapToCanvasX(max(line->First.x,line->Second.x))); miny = min(miny,iMainImage->BitmapToCanvasY(min(line->First.y,line->Second.y))); maxy = max(maxy,iMainImage->BitmapToCanvasY(max(line->First.y,line->Second.y))); } RECT rc = {minx-1,miny-1,maxx+1,maxy+1}; if(resetCount!=-2){ #if defined(TEXTILE) #if defined(CARPET) InvalidateRect(iMainImage->Parent->Handle,&oldlines,false); InvalidateRect(iMainImage->Parent->Handle,&rc,false); #else #endif #else InvalidateRect(iMainImage->Parent->Handle,&oldlines,false); InvalidateRect(iMainImage->Parent->Handle,&rc,false); #endif } oldlines=rc; } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::DrawRectangleLocate(RECT rc,int NOR) { static RECT oldrc=Rect(0,0,0,0); if(NOR==0) { iMainImage->OnPaintLocate = NULL; InvalidateRect(iMainImage->Parent->Handle,&oldrc,false); } else { iMainImage->OnPaintLocate = PaintRectangleLocate;/////////////////by jeegeo FloatingRect.left = iMainImage->BitmapToCanvasX(min(rc.left,rc.right)); FloatingRect.right = iMainImage->BitmapToCanvasX(max(rc.left,rc.right)); FloatingRect.top = iMainImage->BitmapToCanvasY(min(rc.top,rc.bottom)); FloatingRect.bottom = iMainImage->BitmapToCanvasY(max(rc.top,rc.bottom)); #if defined(TEXTILE) #if defined(CARPET) InvalidateRect(iMainImage->Parent->Handle,&oldrc,false); InvalidateRect(iMainImage->Parent->Handle,&FloatingRect,false); #else #endif #else InvalidateRect(iMainImage->Parent->Handle,&oldrc,false); InvalidateRect(iMainImage->Parent->Handle,&FloatingRect,false); #endif oldrc=FloatingRect; } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintRectangleLocate(TObject *Sender, HDC formDC) { RECT rc = FloatingRect; // HDC formDC; HBRUSH hOldBrush; HPEN hOldPen; int nDrawMode; hOldBrush = SelectObject(formDC, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(formDC); hOldPen = SelectObject(formDC, GetStockObject(BLACK_PEN)); SetROP2(formDC, R2_NOT); // formDC = iMainImage->Canvas->Handle; Rectangle(formDC, min(rc.left, rc.right)+1, min(rc.top, rc.bottom)+1, max(rc.left, rc.right), max(rc.top, rc.bottom)); SetROP2(formDC, nDrawMode); SelectObject(formDC, hOldBrush); SelectObject(formDC, hOldPen); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::DrawEllipseLocate(RECT rc,int NOE) { static RECT oldrc=Rect(0,0,0,0); if(NOE==0) { iMainImage->OnPaintLocate = NULL; InvalidateRect(iMainImage->Parent->Handle,&oldrc,false); } else { iMainImage->OnPaintLocate = PaintEllipseLocate;/////////////////by jeegeo FloatingRect.left = iMainImage->BitmapToCanvasX(min(rc.left,rc.right)); FloatingRect.right = iMainImage->BitmapToCanvasX(max(rc.left,rc.right)); FloatingRect.top = iMainImage->BitmapToCanvasY(min(rc.top,rc.bottom)); FloatingRect.bottom = iMainImage->BitmapToCanvasY(max(rc.top,rc.bottom)); #if defined(TEXTILE) #if defined(CARPET) InvalidateRect(iMainImage->Parent->Handle,&oldrc,false); InvalidateRect(iMainImage->Parent->Handle,&FloatingRect,false); #else #endif #else InvalidateRect(iMainImage->Parent->Handle,&oldrc,false); InvalidateRect(iMainImage->Parent->Handle,&FloatingRect,false); #endif oldrc=FloatingRect; } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintEllipseLocate(TObject *Sender, HDC formDC) { RECT rc = FloatingRect; // HDC formDC; HBRUSH hOldBrush; HPEN hOldPen; int nDrawMode; hOldBrush = SelectObject(formDC, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(formDC); hOldPen = SelectObject(formDC, GetStockObject(BLACK_PEN)); SetROP2(formDC, R2_NOT); // formDC = iMainImage->Canvas->Handle; Ellipse(formDC, min(rc.left, rc.right)+1, min(rc.top, rc.bottom)+1, max(rc.left, rc.right), max(rc.top, rc.bottom)); SetROP2(formDC, nDrawMode); SelectObject(formDC, hOldBrush); SelectObject(formDC, hOldPen); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::DrawArcLocate(POINT center2, double LRadius2, double SRadius2, double angleS2, double angleE2, bool isFan2, bool isClosed2, int NOA) { //////isFanÀÌ trueÀ̸é fanÀ̰í falseÀ̸é tubeÀÌ´Ù center=center2; //////tube¿¡¼­´Â SRadius°¡ Æ©ºê ¾çÂÊ ³¡ÀÇ ¼±ºÐÀÇ ±æÀÌÀÌ´Ù LRadius=LRadius2; //////angleS´Â ½ÃÀæ°¢µµÀ̰í SRadius=SRadius2; //////angleE´Â ³¡°¢µµÀÌ´Ù angleS=angleS2; angleE=angleE2; isFan=isFan2; isClosed=isClosed2; RECT rc = Rect(center.x-LRadius-SRadius,center.y-LRadius-SRadius, center.x+LRadius+SRadius,center.y+LRadius+SRadius); static RECT oldrc=Rect(0,0,0,0); if(NOA==0) { iMainImage->OnPaintLocate = NULL; InvalidateRect(iMainImage->Parent->Handle,&oldrc,false); } else { iMainImage->OnPaintLocate = PaintArcLocate;/////////////////by jeegeo FloatingRect.left = iMainImage->BitmapToCanvasX(min(rc.left,rc.right)); FloatingRect.right = iMainImage->BitmapToCanvasX(max(rc.left,rc.right)); FloatingRect.top = iMainImage->BitmapToCanvasY(min(rc.top,rc.bottom)); FloatingRect.bottom = iMainImage->BitmapToCanvasY(max(rc.top,rc.bottom)); #if defined(TEXTILE) #if defined(CARPET) InvalidateRect(iMainImage->Parent->Handle,&oldrc,false); InvalidateRect(iMainImage->Parent->Handle,&FloatingRect,false); #else #endif #else InvalidateRect(iMainImage->Parent->Handle,&oldrc,false); InvalidateRect(iMainImage->Parent->Handle,&FloatingRect,false); #endif oldrc=FloatingRect; } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintArcLocate(TObject *Sender, HDC formDC) /////by jeegeo { RECT rc,rr; POINT p,ps,pe; // HDC formDC; HBRUSH hOldBrush; HPEN hOldPen; int nDrawMode; hOldBrush = SelectObject(formDC, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(formDC); hOldPen = SelectObject(formDC, GetStockObject(BLACK_PEN)); SetROP2(formDC, R2_NOT); // formDC = iMainImage->Canvas->Handle; if(isFan){ rc = Rect(center.x - LRadius,center.y - LRadius, center.x + LRadius,center.y + LRadius); rr.left = iMainImage->BitmapToCanvasX(rc.left); rr.top = iMainImage->BitmapToCanvasY(rc.top); rr.right = iMainImage->BitmapToCanvasX(rc.right); rr.bottom = iMainImage->BitmapToCanvasY(rc.bottom); p = Point(center.x+cos(angleS)*LRadius,center.y-sin(angleS)*LRadius); ps.x = iMainImage->BitmapToCanvasX(p.x); ps.y = iMainImage->BitmapToCanvasY(p.y); p = Point(center.x+cos(angleE)*LRadius,center.y-sin(angleE)*LRadius); pe.x = iMainImage->BitmapToCanvasX(p.x); pe.y = iMainImage->BitmapToCanvasY(p.y); Arc(formDC,rr.left,rr.top,rr.right,rr.bottom,ps.x,ps.y,pe.x,pe.y); rc = Rect(center.x - SRadius,center.y - SRadius, center.x + SRadius,center.y + SRadius); rr.left = iMainImage->BitmapToCanvasX(rc.left); rr.top = iMainImage->BitmapToCanvasY(rc.top); rr.right = iMainImage->BitmapToCanvasX(rc.right); rr.bottom = iMainImage->BitmapToCanvasY(rc.bottom); p = Point(center.x+cos(angleS)*SRadius,center.y-sin(angleS)*SRadius); ps.x = iMainImage->BitmapToCanvasX(p.x); ps.y = iMainImage->BitmapToCanvasY(p.y); p = Point(center.x+cos(angleE)*SRadius,center.y-sin(angleE)*SRadius); pe.x = iMainImage->BitmapToCanvasX(p.x); pe.y = iMainImage->BitmapToCanvasY(p.y); Arc(formDC,rr.left,rr.top,rr.right,rr.bottom,ps.x,ps.y,pe.x,pe.y); if(isClosed) { /////////Arc¸¦ ´Ý´Â ¼±ºÐÀ» ±×¸°´Ù p = Point(center.x+cos(angleS)*LRadius,center.y-sin(angleS)*LRadius); p.x = iMainImage->BitmapToCanvasX(p.x); p.y = iMainImage->BitmapToCanvasY(p.y); MoveToEx(formDC,p.x,p.y,NULL); p = Point(center.x+cos(angleS)*SRadius,center.y-sin(angleS)*SRadius); p.x = iMainImage->BitmapToCanvasX(p.x); p.y = iMainImage->BitmapToCanvasY(p.y); LineTo(formDC,p.x,p.y); p = Point(center.x+cos(angleE)*LRadius,center.y-sin(angleE)*LRadius); p.x = iMainImage->BitmapToCanvasX(p.x); p.y = iMainImage->BitmapToCanvasY(p.y); MoveToEx(formDC,p.x,p.y,NULL); p = Point(center.x+cos(angleE)*SRadius,center.y-sin(angleE)*SRadius); p.x = iMainImage->BitmapToCanvasX(p.x); p.y = iMainImage->BitmapToCanvasY(p.y); LineTo(formDC,p.x,p.y); } } else { rc = Rect(center.x - LRadius,center.y - LRadius, center.x + LRadius,center.y + LRadius); rr.left = iMainImage->BitmapToCanvasX(rc.left); rr.top = iMainImage->BitmapToCanvasY(rc.top); rr.right = iMainImage->BitmapToCanvasX(rc.right); rr.bottom = iMainImage->BitmapToCanvasY(rc.bottom); p = Point(center.x+cos(angleS)*LRadius,center.y-sin(angleS)*LRadius); ps.x = iMainImage->BitmapToCanvasX(p.x); ps.y = iMainImage->BitmapToCanvasY(p.y); p = Point(center.x+cos(angleE)*LRadius,center.y-sin(angleE)*LRadius); pe.x = iMainImage->BitmapToCanvasX(p.x); pe.y = iMainImage->BitmapToCanvasY(p.y); Arc(formDC,rr.left,rr.top,rr.right,rr.bottom,ps.x,ps.y,pe.x,pe.y); double midAngle=(angleS+angleE)/2.0; float ratio=(float)iMainImage->ZoomIn/(float)iMainImage->ZoomOut; POINT plus = Point(-SRadius*cos(midAngle)*ratio,SRadius*sin(midAngle)*ratio); rc = Rect(center.x - LRadius,center.y - LRadius, center.x + LRadius,center.y + LRadius); rr.left = iMainImage->BitmapToCanvasX(rc.left); rr.top = iMainImage->BitmapToCanvasY(rc.top); rr.right = iMainImage->BitmapToCanvasX(rc.right); rr.bottom = iMainImage->BitmapToCanvasY(rc.bottom); p = Point(center.x+cos(angleS)*LRadius,center.y-sin(angleS)*LRadius); ps.x = iMainImage->BitmapToCanvasX(p.x); ps.y = iMainImage->BitmapToCanvasY(p.y); p = Point(center.x+cos(angleE)*LRadius,center.y-sin(angleE)*LRadius); pe.x = iMainImage->BitmapToCanvasX(p.x); pe.y = iMainImage->BitmapToCanvasY(p.y); Arc(formDC,rr.left+plus.x,rr.top+plus.y,rr.right+plus.x,rr.bottom+plus.y, ps.x+plus.x,ps.y+plus.y,pe.x+plus.x,pe.y+plus.y); if(isClosed) { /////////Arc¸¦ ´Ý´Â ¼±ºÐÀ» ±×¸°´Ù p = Point(center.x+cos(angleS)*LRadius,center.y-sin(angleS)*LRadius); p.x = iMainImage->BitmapToCanvasX(p.x); p.y = iMainImage->BitmapToCanvasY(p.y); MoveToEx(formDC,p.x,p.y,NULL); LineTo(formDC,p.x+plus.x,p.y+plus.y); p = Point(center.x+cos(angleE)*LRadius,center.y-sin(angleE)*LRadius); p.x = iMainImage->BitmapToCanvasX(p.x); p.y = iMainImage->BitmapToCanvasY(p.y); MoveToEx(formDC,p.x,p.y,NULL); LineTo(formDC,p.x+plus.x,p.y+plus.y); } } SetROP2(formDC, nDrawMode); SelectObject(formDC, hOldBrush); SelectObject(formDC, hOldPen); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintCrossLine(TObject *Sender, HDC formDC) { HPEN hOldPen; HBRUSH hOldBrush; int nDrawMode; POINT cp=iMainImage->GetCrossPos(); RGBQUAD rgb; hOldBrush = SelectObject(formDC, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(formDC); hOldPen = SelectObject(formDC, GetStockObject(BLACK_PEN)); SetROP2(formDC, R2_NOT); #ifdef WEAVE MoveToEx(formDC, cp.x, iMainImage->Parent->Top-30, NULL); LineTo(formDC, cp.x, iMainImage->Parent->Top + iMainImage->Parent->Height); MoveToEx(formDC, iMainImage->Parent->Left-30, cp.y, NULL); LineTo(formDC, iMainImage->Parent->Left + iMainImage->Parent->Width, cp.y); #else MoveToEx(formDC, cp.x, iMainImage->Parent->Top, NULL); LineTo(formDC, cp.x, iMainImage->Parent->Top + iMainImage->Parent->Height); MoveToEx(formDC, iMainImage->Parent->Left, cp.y, NULL); LineTo(formDC, iMainImage->Parent->Left + iMainImage->Parent->Width, cp.y); #endif SetROP2(formDC, nDrawMode); SelectObject(formDC, hOldBrush); SelectObject(formDC, hOldPen); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintDirectly(HDC dcDst, int px, int py, int vw, int vh){ if(!isPaintDirectlyClean){ if(!isFirst){ if(iMainImage->OnPaintCursor) iMainImage->OnPaintCursor(iMainImage,dcDst,Pen.x,Pen.y); if(iMainImage->OnPaintCrossLine) iMainImage->OnPaintCrossLine(iMainImage,dcDst); } if(iMainImage->OnPaintZoom) iMainImage->OnPaintZoom(iMainImage, dcDst); if(iMainImage->OnPaintLocate) iMainImage->OnPaintLocate(iMainImage, dcDst); } } //--------------------------------------------------------------------------- int __fastcall TMainImageForm::GetLineListCount(void){ return LineList->Count; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::ResetDraw(bool repaint){ iMainImage->OnPaintLocate=NULL; LineList->Clear(); FloatingRect=Rect(0,0,0,0); NumberOfLine=0; center=Point(0,0); SRadius=0;LRadius=0;angleS=0;angleE=0; isClosed=false;isFan=true; if(repaint)iMainImage->Repaint(); } //------------------------------------------------------------------------------lhskys void __fastcall TMainImageForm::Extractdensity(int Index, int i) { TYarnArray *pd; int cnt = Plan->Yarn->PData[i]->Count, l; if (cnt) { for (int m = 0; m < cnt; m++) { pd = (TYarnArray *)Plan->Yarn->PData[i]->Items[m]; if (Index == pd->code) { int j, k, method1; method1 = 0; int repeat1; //Center À϶§ÀÇ repeatÀ» ¾Ë±âÀ§ÇØ if(pd->method == 2){ if (CurrentUnit == uCm) { tDen = pd->density / 2.54; } else { tDen = pd->density; } wasum += tDen*pd->repeat; densityCnt += 1*pd->repeat; repeat1 = pd->repeat; for (j=m-1;j>-1;j--){ pd = (TYarnArray *)Plan->Yarn->PData[i]->Items[j]; if (pd->method == 1){ if (CurrentUnit == uCm) { tDen = pd->density / 2.54; } else { tDen = pd->density; } wasum += tDen*(repeat1*2 - 1); densityCnt += 1*(repeat1*2 - 1); method1 = 1; //reverse ¼öÇàÈ®ÀÎ ¾Æ´Ï¸é nomal À» ¼öÇàÇÏ¿©¾ß Çϱ⶧¹®¿¡ }else j = -1; } for (k=m-1;k>-1;k--){ pd = (TYarnArray *)Plan->Yarn->PData[i]->Items[k]; if (method1 == 0){ if (CurrentUnit == uCm) { tDen = pd->density / 2.54; } else { tDen = pd->density; } wasum += tDen*(repeat1 - 1); densityCnt += 1*(repeat1 - 1); }else k = -1; } }else { if (CurrentUnit == uCm) { tDen = pd->density / 2.54; } else { tDen = pd->density; } wasum += tDen*pd->repeat; densityCnt += 1*pd->repeat; } } } } } //------------------------------------------------------------------------------ lhskys void __fastcall TMainImageForm::Extractdensity1(int Index, int i) { TYarnArray *pd; int cnt = Plan->Yarn->PData[i]->Count, l; if (cnt) { for (int m = 0; m < cnt; m++) { pd = (TYarnArray *)Plan->Yarn->PData[i]->Items[m]; if (Index == pd->code) { int j, k, method1; method1 = 0; int repeat1; //Center À϶§ÀÇ repeatÀ» ¾Ë±âÀ§ÇØ if(pd->method == 2){ if (CurrentUnit == uCm) { tDen1 = pd->density / 2.54; } else { tDen1 = pd->density; } wasum1 += tDen1*pd->repeat; densityCnt1 += 1*pd->repeat; repeat1 = pd->repeat; for (j=m-1;j>-1;j--){ pd = (TYarnArray *)Plan->Yarn->PData[i]->Items[j]; if (pd->method == 1){ if (CurrentUnit == uCm) { tDen1 = pd->density / 2.54; } else { tDen1 = pd->density; } wasum1 += tDen1*(repeat1*2 - 1); densityCnt1 += 1*(repeat1*2 - 1); method1 = 1; //reverse ¼öÇàÈ®ÀÎ ¾Æ´Ï¸é nomal À» ¼öÇàÇÏ¿©¾ß Çϱ⶧¹®¿¡ }else j = -1; } for (k=m-1;k>-1;k--){ pd = (TYarnArray *)Plan->Yarn->PData[i]->Items[k]; if (method1 == 0){ if (CurrentUnit == uCm) { tDen1 = pd->density / 2.54; } else { tDen1 = pd->density; } wasum1 += tDen1*(repeat1 - 1); densityCnt1 += 1*(repeat1 - 1); }else k = -1; } }else { if (CurrentUnit == uCm) { tDen1 = pd->density / 2.54; } else { tDen1 = pd->density; } wasum1 += tDen1*pd->repeat; densityCnt1 += 1*pd->repeat; } } } } } //------------------------------------------------------------------------------