//--------------------------------------------------------------------------- #include #include #pragma hdrstop #include "OneRepeat_F.h" #include "MainImage.h" #include "Environment.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "TPImage" #pragma link "TPWeaveImage" #pragma link "TPRuler2D" #pragma resource "*.dfm" TOneRepeatForm *OneRepeatForm; //--------------------------------------------------------------------------- __fastcall TOneRepeatForm::TOneRepeatForm(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TOneRepeatForm::Weaving() { RGBQUAD c; TIniFile *IniFile = new TIniFile(DirectoryItem+"\\Environment.ini"); if(IniFile){ PatternDPI = IniFile->ReadInteger("Printing", "DPI", 480); delete IniFile; } Ruler->DPI = PatternDPI; Caption = "One Repeat (" + IntToStr(PatternDPI) + " DPI)"; MainImageForm->Plan->MakeYarnMap4HighDPI(PatternDPI); MainImageForm->Plan->calc_weave(NULL,MainImageForm->Palette->ColorData[1]->RGB, 0, PatternDPI); OneRepeatImage->Bitmap->Create(MainImageForm->Plan->HighPatternBitmap->Width, MainImageForm->Plan->HighPatternBitmap->Height, 16); WarpImage->Bitmap->Create(MainImageForm->Plan->HighPatternBitmap->Width, 32*PatternDPI/160, 16); WeftImage->Bitmap->Create(32*PatternDPI/160, MainImageForm->Plan->HighPatternBitmap->Height, 16); MainImageForm->Plan->DrawFront(OneRepeatImage->Bitmap, PatternDPI); MainImageForm->Plan->DrawWarpBar(WarpImage->Bitmap, MainImageForm->Palette->ColorData[1]->RGB, false, PatternDPI); MainImageForm->Plan->DrawWeftBar(WeftImage->Bitmap, MainImageForm->Palette->ColorData[1]->RGB, PatternDPI); FitForm(); Visible = true; OneRepeatImage->Repaint(); WarpImage->Repaint(); WeftImage->Repaint(); } //---------------------------------------------------------------------------- void __fastcall TOneRepeatForm::FitForm() { int w, h, cw, ch; Left = 2; Top =2; Ruler->AUnit = MainImageForm->CurrentUnit; w = OneRepeatImage->Bitmap->Width + WeftImage->Width + sbVert->Width + Ruler->Thick + 6; h = OneRepeatImage->Bitmap->Height + WarpImage->Height + sbHorz->Height + Ruler->Thick +6; cw = w < MainImageForm->Width -10 ? w : MainImageForm->Width - 10; ch = h < MainImageForm->Height -25 ? h : MainImageForm->Height - 25; Ruler->Left = 0; Ruler->Top = WarpImage->Height + 3; Ruler->Width = cw - WeftImage->Width - sbVert->Width - 6; Ruler->Height = ch - WarpImage->Height - sbHorz->Height - 6; Panel->Left = Ruler->Thick; Panel->Top = Ruler->Top; Panel->Width = Ruler->Width - Ruler->Thick; Panel->Height = Ruler->Height - Ruler->Thick; OneRepeatImage->Width = Panel->Width; OneRepeatImage->Height = Panel->Height; WarpImage->Left = Ruler->Thick; WarpImage->Top = 0; WarpImage->Width = Panel->Width; WeftImage->Left = Ruler->Width + 3; WeftImage->Top = Ruler->Top; WeftImage->Height = Panel->Height; sbHorz->Top = Ruler->Top+Ruler->Height + 3; sbHorz->Width = cw - sbVert->Width; sbVert->Left = WeftImage->Left+WeftImage->Width+3; sbVert->Height = ch - sbHorz->Height - 6; Width = cw + 10; Height = ch + GetSystemMetrics(SM_CYSMCAPTION)+15; if (OneRepeatImage->Bitmap->Width <= Panel->Width) sbHorz->Max = 0; else sbHorz->Max = OneRepeatImage->Bitmap->Width - Panel->Width; sbHorz->SmallChange = sbHorz->Max/10; sbHorz->LargeChange = sbHorz->Max/5; if (OneRepeatImage->Bitmap->Height < Panel->Height) sbVert->Max = 0; else sbVert->Max = OneRepeatImage->Bitmap->Height - Panel->Height; sbVert->SmallChange = sbVert->Max/10; sbVert->LargeChange = sbVert->Max/5; OneRepeatImage->SetPosition(0, 0); WarpImage->SetPosition(); WeftImage->SetPosition(); } //--------------------------------------------------------------------------- void __fastcall TOneRepeatForm::sbHorzScroll(TObject *Sender, TScrollCode ScrollCode, int &ScrollPos) { OneRepeatImage->PositionX = sbHorz->Position; } //--------------------------------------------------------------------------- void __fastcall TOneRepeatForm::sbVertScroll(TObject *Sender, TScrollCode ScrollCode, int &ScrollPos) { OneRepeatImage->PositionY = sbVert->Max-sbVert->Position; } //--------------------------------------------------------------------------- void __fastcall TOneRepeatForm::OneRepeatImagePositionChange( TObject *Sender) { Ruler->StartX = OneRepeatImage->PositionX; Ruler->StartY = OneRepeatImage->PositionY; sbHorz->Position = OneRepeatImage->PositionX; sbVert->Position = sbVert->Max-OneRepeatImage->PositionY; WarpImage->PositionX = OneRepeatImage->PositionX; WeftImage->PositionY = OneRepeatImage->PositionY; } //--------------------------------------------------------------------------- void __fastcall TOneRepeatForm::FormResize(TObject *Sender) { /* Ruler->Left = 0; Ruler->Top = WarpImage->Height + 3; Ruler->Width = ClientWidth - WeftImage->Width - sbVert->Width - 6; Ruler->Height = ClientHeight - WarpImage->Height - sbHorz->Height -6; Panel->Left = Ruler->Thick; Panel->Top = Ruler->Top; Panel->Width = Ruler->Width - Ruler->Thick; Panel->Height = Ruler->Height - Ruler->Thick; WarpImage->Left = Ruler->Thick; WarpImage->Top = 0; WarpImage->Width = Panel->Width; WeftImage->Left = Ruler->Width + 3; WeftImage->Top = Ruler->Top; WeftImage->Height = Panel->Height; sbHorz->Top = Ruler->Top+Ruler->Height + 3; sbHorz->Width = ClientWidth - sbVert->Width; sbVert->Left = WeftImage->Left+WeftImage->Width+3; sbVert->Height = ClientHeight - sbHorz->Height -6; OneRepeatImage->SetPosition(0, 0); WarpImage->SetPosition(); WeftImage->SetPosition();*/ } //---------------------------------------------------------------------------