//--------------------------------------------------------------------------- #include #pragma hdrstop #include "Simulation_F.h" #include "Main_F.h" #include "treatment.h" #include "YarnCompositionData.h" #include "Palette.h" #include "Viewer.h" #include "GuideBar.h" #include "ProtectCard.h" #include "SimulationAdvSet_F.h" #include "jpeg.hpp" #ifdef LOCK_TEX #include "Seedx.h" #endif //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "RzButton" #pragma link "RzEdit" #pragma link "RzPanel" #pragma link "RzRadChk" #pragma resource "*.dfm" //--------------------------------------------------------------------------- #define IDS_SIMULATION StringTable[0] #define IDS_SIMULATION_SETTING_MENU StringTable[1] #define IDS_ZOOM StringTable[2] #define IDS_WHOLE_VIEWER StringTable[3] #define IDS_COPY StringTable[4] #define IDS_CPC StringTable[5] #define IDS_WIDTH StringTable[6] #define IDS_FUZZ StringTable[7] #define IDS_BACK StringTable[8] #define IDS_REPEATV StringTable[9] #define IDS_REPEATH StringTable[10] #define IDS_BGCOLOR StringTable[11] #define IDS_INITIALIZING StringTable[12] #define IDS_OPTIMIZING StringTable[13] #define IDS_SIMULATING StringTable[14] #define IDS_TREATING StringTable[15] #define IDS_SAVE StringTable[16] #define IDS_SPANDEX_EFFECT StringTable[17] #define IDS_ADVANCED StringTable[18] #define IDS_TENSION_EFFECT StringTable[19] #define IDS_ZOOM2 StringTable[20] #define IDS_WRONGNUMBER StringTable[21] #define IDS_WARNING StringTable[22] //--------------------------------------------------------------------------- TSimulationForm *SimulationForm; //--------------------------------------------------------------------------- __fastcall TSimulationForm::TSimulationForm(TComponent* Owner) : TForm(Owner) { StringTable.Create(BaseDir, Language, "Simulation"); Caption=IDS_SIMULATION; //gbSimulation->Caption=IDS_SIMULATION_SETTING_MENU; lbSimulation->Caption=IDS_SIMULATION_SETTING_MENU; sbSimulation->Hint=IDS_SIMULATION; lbSimulationW->Caption=IDS_WIDTH; lbCPC->Caption=IDS_CPC; lbFuzz->Caption=IDS_FUZZ; lbBack->Caption=IDS_BACK; lbBGColor->Caption=IDS_BGCOLOR; pmsmZoom->Caption=IDS_ZOOM; pmsmViewer->Caption=IDS_WHOLE_VIEWER; pmsmToClipBoard->Caption=IDS_COPY; pmsmSave->Caption=IDS_SAVE; sbAdvanced->Caption=IDS_ADVANCED; CaptureVisible=true; lbSimulationZoom->Caption=IDS_ZOOM2; } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::sbSimulationClick(TObject *Sender) { if(image) { MakeImage(); ShowImage(); } } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::FormCreate(TObject *Sender) { image = new TTexpiaBitmap; SetFont(); ShowSimulationData(); SavePictureDialog->InitialDir=BaseDir+"\\bmp"; SavePictureDialog->DefaultExt = "bmp"; SavePictureDialog->FileName = "Noname1"; SavePictureDialog->Filter="Bitmaps (*.bmp)|*.bmp|JPEG Image File (*.jpg)|*.jpg"; if(IsVivien()){ #ifdef NO_SIM_VERSION lbSystem->Caption = PROGRAM_NAME + " " + VERSION + MINOR_VERSION + " (Vivien)"; //lbSystem->Caption = PROGRAM_NAME + " " + VERSION + MINOR_VERSION + " (Vivien) - Restricted Version"; #else lbSystem->Caption = PROGRAM_NAME + " " + VERSION + MINOR_VERSION + " (Vivien)"; #endif } else { #ifdef NO_SIM_VERSION lbSystem->Caption = PROGRAM_NAME + " " + VERSION + MINOR_VERSION; //lbSystem->Caption = PROGRAM_NAME + " " + VERSION + MINOR_VERSION + " - Restricted Version"; #else lbSystem->Caption = PROGRAM_NAME + " " + VERSION + MINOR_VERSION; #endif } http->Font->Color=clBlue; http->Font->Style = TFontStyles()<ReadInteger("Simulation", "Zoom", 4); //ÀåÁø¸¸ : ¼³Á¤ ·Îµå sd.sub_zoom = IniFile->ReadInteger("Simulation", "Sub_zoom", 0); sd.width = IniFile->ReadFloat("Simulation", "Width", 42); sd.cpc = IniFile->ReadFloat("Simulation", "Cpc", 20); sd.fuzz = IniFile->ReadInteger("Simulation", "Fuzz", 0); sd.back = IniFile->ReadBool("Simulation", "Back", false); delete IniFile; } edSZoom->Text=IntToStr(sd.zoom) + "." + IntToStr(sd.sub_zoom); edSWidth->Text=FloatToStr(sd.width); edSCPC->Text=FloatToStr(sd.cpc); edFuzz->Text=IntToStr(sd.fuzz); cbBack->Checked = sd.back; */ } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::UpdateMenu(){ //¸Þ´º¿Í ÆË¾÷¸Å´º¸¦ ¾÷µ¥ÀÌÆ®ÇÑ´Ù if(image->Width){ pmsmViewer->Enabled=true; pmsmToClipBoard->Enabled=true; pmsmSave->Enabled=true; pmsmTex3D->Enabled=true; } else { pmsmViewer->Enabled=false; pmsmToClipBoard->Enabled=false; pmsmSave->Enabled=false; pmsmTex3D->Enabled=false; } pmsmx1->Checked=false; pmsmx1_2->Checked=false; pmsmx1_5->Checked=false; pmsmx2->Checked=false; pmsmx4->Checked=false; pmsmx8->Checked=false; pmsmx16->Checked=false; switch(sd.zoom){ case 1: { if(sd.sub_zoom==0){ pmsmx1->Checked=true; } else if(sd.sub_zoom==2){ pmsmx1_2->Checked=true; } else { pmsmx1_5->Checked=true; } break; } case 2: { pmsmx2->Checked=true; break; } case 4: { pmsmx4->Checked=true; break; } case 8: { pmsmx8->Checked=true; break; } case 16: { pmsmx16->Checked=true; break; } default: break; } GetTex3DInstallVersion(); } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::edSZoomKeyPress(TObject *Sender, char &Key) //ÀåÁø¸¸ : ÁÜ ´Ü°è ¸¶À½´ë·Î Á¶Àý { HotKeyPress(Key); if(Key==VK_RETURN){ if (!SetSimulationData()) { Application->MessageBox("Please, check the setting menu !", "Warning", MB_OK); return; // by maxleo21c (06.11.04) } UpdateMenu(); sbSimulationClick(NULL); } if((Key<'0' || Key>'9') && Key!='.' && Key!='\b'){ Key = 0; } } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::edSWidthKeyPress(TObject *Sender, char &Key) { HotKeyPress(Key); if(Key==VK_RETURN){ if (!SetSimulationData()) return; // by maxleo21c (06.11.04) if(YarnCompositionData_F&&YarnCompositionData_F->Visible)YarnCompositionData_F->Repaint(); sbSimulationClick(NULL); edSCPC->SetFocus(); } } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::edSCPCKeyPress(TObject *Sender, char &Key) { HotKeyPress(Key); if(Key==VK_RETURN){ if (!SetSimulationData()) return; // by maxleo21c (06.11.04) if(YarnCompositionData_F&&YarnCompositionData_F->Visible)YarnCompositionData_F->Repaint(); sbSimulationClick(NULL); } } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::pmsmx1Click(TObject *Sender) { TMenuItem *menuItem; menuItem = (TMenuItem*)Sender; if (menuItem->Name=="pmsmx1") { sd.zoom=1; sd.sub_zoom=0; edSZoom->Text = "1.0"; } else if (menuItem->Name=="pmsmx1_2") { sd.zoom=1; sd.sub_zoom=2; edSZoom->Text = "1.2"; } else if (menuItem->Name=="pmsmx1_5") { sd.zoom=1; sd.sub_zoom=5; edSZoom->Text = "1.5"; } else if (menuItem->Name=="pmsmx2") { sd.zoom=2; sd.sub_zoom=0; edSZoom->Text = "2.0"; } else if (menuItem->Name=="pmsmx4") { sd.zoom=4; sd.sub_zoom=0; edSZoom->Text = "4.0"; } else if (menuItem->Name=="pmsmx8") { sd.zoom=8; sd.sub_zoom=0; edSZoom->Text = "8.0"; } else if (menuItem->Name=="pmsmx16") { sd.zoom=16; sd.sub_zoom=0; edSZoom->Text = "16.0"; } if (!SetSimulationData()) { Application->MessageBox("Please, check the setting menu !", "Warning", MB_OK); return; // by maxleo21c (06.11.04) } UpdateMenu(); sbSimulationClick(NULL); } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::edFuzzKeyPress(TObject *Sender, char &Key) { HotKeyPress(Key); if(Key==VK_RETURN){ // int i=StrToInt(edFuzz->Text); int i; if (!::TryStrToInt(edFuzz->Text, i)) return; if(i<0)i=0; if(i>99)i=99; edFuzz->Text=IntToStr(i); if (!SetSimulationData()) return; // by maxleo21c (06.11.04) sbSimulationClick(NULL); } } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::spBGColorMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { if(!Shift.Contains(ssLeft))return; TColor c; PaletteForm->Left=Mouse->CursorPos.x; PaletteForm->Top=Mouse->CursorPos.y; PaletteForm->Visible=true; PaletteForm->InitForm(PaletteForm->Palette);//visible »óÅ¿¡¼­ ÃʱâÈ­ÇØ¾ß ½ºÅ©·Ñ¹Ù°¡ ¿òÁ÷¿©Áø´Ù PaletteForm->Visible=false; if(PaletteForm->ShowModal()==mrOk){ spBGColor->Brush->Color=PaletteForm->DIB256Palette->FGColor; if (!SetSimulationData()) return; // by maxleo21c (06.11.04) sbSimulationClick(NULL); } } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::SaveImage(HANDLE hFile, int main_ver, TCompressMethod cm) { DWORD dwWrite; try{ bool existImage=true; if(main_ver>=1){ WriteFile(hFile, &existImage, sizeof(bool), &dwWrite, NULL); WriteFile(hFile, &(image->Width), sizeof(int), &dwWrite, NULL); WriteFile(hFile, &(image->Height), sizeof(int), &dwWrite, NULL); if(main_ver>=4){ WriteFile(hFile, &cm, sizeof(TCompressMethod), &dwWrite, NULL); image->SaveToTexpiaFile(hFile, cm); } else if(main_ver>=3){ image->SaveToTexpiaFile(hFile, cmNone); } } } catch(...){ bool existImage=false; if(main_ver>=1){ WriteFile(hFile, &existImage, sizeof(bool), &dwWrite, NULL); } return; } } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::LoadImage(HANDLE hFile, int main_ver){ #ifdef LOCK_HASP if(ProtectCard==NULL){ ShowMessage(IDS_MESSAGE_INTERFACE); Application->Terminate(); return; } else { #ifdef HASPSRM ProtectCard->isHacked(true); #else #ifdef NETHASP ProtectCard->Lock_Check(); #else ProtectCard->Read(); #endif if (ProtectCard->isHacking) { ShowMessage(IDS_MESSAGE_INTERFACE); Application->Terminate(); return; } #endif } #endif #ifdef LOCK_IFC if(ProtectCard==NULL){ ShowMessage(IDS_MESSAGE_INTERFACE); Application->Terminate(); return; } else if(!ProtectCard->CheckPassword()) { ShowMessage(IDS_MESSAGE_INTERFACE); Application->Terminate(); return; } #endif DWORD dwRead; bool existImage; int w,h; if(main_ver>=1){ ReadFile(hFile, &existImage, sizeof(bool), &dwRead, NULL); if(existImage){ ReadFile(hFile, &w, sizeof(int), &dwRead, NULL); ReadFile(hFile, &h, sizeof(int), &dwRead, NULL); image->Create(w,h, 24); if(main_ver>=4){ TCompressMethod cm = cmNone; ReadFile(hFile, &cm, sizeof(TCompressMethod), &dwRead, NULL); image->LoadFromTexpiaFile(hFile, cm); } else if(main_ver>=3){ image->LoadFromTexpiaFile(hFile, cmNone); } else { image->LoadFromTexpiaFile(hFile, cmZLib); } } } } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::cbBackMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { if(!SetSimulationData()) return; // by maxleo21c (06.11.04) sd.back = cbBack->Checked; sbSimulationClick(NULL); } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::pmsmViewerClick(TObject *Sender)//ÀåÁø¸¸ : viewâ¿¡¼­ Å©°Ô º¸ÀÌ°Ô { BEGIN_TEX; if(image->Height==0||image->Width==0) { END_TEX; return; } /* if(image->Width>1280*1.5||image->Height>1024*1.5) { ShowMessage(IDS_MESSAGE_TOO_LARGE_BITMAP_ZOOM_REPEAT); return; } Viewer_F->Width = image->Width+6; Viewer_F->Height = image->Height+25; Viewer_F->Image->Width = image->Width; Viewer_F->Image->Height = image->Height; Viewer_F->Image->Picture->Bitmap->Width = image->Width; Viewer_F->Image->Picture->Bitmap->Height = image->Height; */ /* int x_mult = (int)(1280*1.5) / image->Width; int y_mult = (int)(1024*1.5) / image->Height; int wid; if(x_mult != 0) wid = image->Width * x_mult; else wid = 1280 * 1.5; int hei; if(y_mult != 0) hei = image->Height * y_mult; else hei = 1024 * 1.5; Viewer_F->Width = wid+6; Viewer_F->Height = hei+25; Viewer_F->Image->Width = wid; Viewer_F->Image->Height = hei; Viewer_F->Image->Picture->Bitmap->Width = wid; Viewer_F->Image->Picture->Bitmap->Height = hei; HDC hDC = Viewer_F->Image->Canvas->Handle; HDC dcSrc = image->CreateDC(); // BitBlt(hDC,0,0,Viewer_F->Width,Viewer_F->Height,dcSrc,0,0,SRCCOPY); if(x_mult!=0 && y_mult!=0){ for(int i=0;iWidth*i,image->Height*j,image->Width,image->Height,dcSrc,0,0,SRCCOPY); } } } else if(x_mult == 0 && y_mult != 0){ for(int j=0;jHeight*j,1280*1.5,image->Height,dcSrc,0,0,SRCCOPY); } } else if(x_mult != 0 && y_mult == 0){ for(int i=0;iWidth*i,0,image->Width,1024*1.5,dcSrc,0,0,SRCCOPY); } } else if(x_mult == 0 && y_mult == 0){ BitBlt(hDC,0,0,1280*1.5,1024*1.5,dcSrc,0,0,SRCCOPY); } image->DeleteDC(dcSrc); Viewer_F->Show(); Viewer_F->Repaint(); */ // int wid = Screen->Width - 10; // int hei = Screen->Height - 30; int wid = 1800; int hei = 1500; int x_mult = wid / image->Width + 1; int y_mult = hei / image->Height + 1; if(x_mult == 1 || y_mult == 1) ShowMessage(IDS_MESSAGE_TOO_LARGE_FULL_BITMAP); // Viewer_F->Width = wid+6; // Viewer_F->Height = hei+25; Viewer_F->Width = Screen->Width-20; Viewer_F->Height = Screen->Height-20; Viewer_F->Image->Width = wid; Viewer_F->Image->Height = hei; Viewer_F->Image->Picture->Bitmap->Width = wid; Viewer_F->Image->Picture->Bitmap->Height = hei; Viewer_F->scHori->Top = Viewer_F->ClientHeight-16; Viewer_F->scHori->Left = 0; Viewer_F->scHori->Width = Viewer_F->ClientWidth-16; Viewer_F->scHori->Position = 0; Viewer_F->scVert->Top = 0; Viewer_F->scVert->Left = Viewer_F->ClientWidth-16; Viewer_F->scVert->Height = Viewer_F->ClientHeight-16; Viewer_F->scVert->Position = 0; Viewer_F->pnCorner->Top = Viewer_F->ClientHeight-16; Viewer_F->pnCorner->Left = Viewer_F->ClientWidth-16; Viewer_F->Image->Top = 0; Viewer_F->Image->Left = 0; HDC hDC = Viewer_F->Image->Canvas->Handle; HDC dcSrc = image->CreateDC(); for(int i=0;iWidth*i,image->Height*j,image->Width,image->Height,dcSrc,0,0,SRCCOPY); if((i == x_mult-1) && (j != y_mult-1)) BitBlt(hDC,image->Width*i,image->Height*j,wid-image->Width*i,image->Height,dcSrc,0,0,SRCCOPY); if((i != x_mult-1) && (j == y_mult-1)) BitBlt(hDC,image->Width*i,image->Height*j,image->Width,hei-image->Height*j,dcSrc,0,0,SRCCOPY); if((i == x_mult-1) && (j == y_mult-1)) BitBlt(hDC,image->Width*i,image->Height*j,wid-image->Width*i,hei-image->Height*j,dcSrc,0,0,SRCCOPY); } } image->DeleteDC(dcSrc); Viewer_F->Show(); Viewer_F->Repaint(); END_TEX; } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::pmsmToClipBoardClick(TObject *Sender) { BEGIN_TEX; BITMAPHANDLE bh; HDC dcSrc = NULL, dcDst = NULL; memset(&bh, 0, sizeof(BITMAPHANDLE)); L_CreateBitmap(&bh, sizeof(BITMAPHANDLE), TYPE_CONV, image->Width, image->Height, 24, ORDER_BGR, NULL, TOP_LEFT, NULL, NULL); dcDst = L_CreateLeadDC(&bh); dcSrc = image->CreateDC(); BitBlt(dcDst, 0, 0, image->Width, image->Height, dcSrc, 0, 0, SRCCOPY); image->DeleteDC(dcSrc); L_DeleteLeadDC(dcDst); dcDst = NULL; L_CopyToClipboard(Handle, &bh, COPY2CB_EMPTY | COPY2CB_DIB); L_FreeBitmap(&bh); END_TEX; } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::FormResize(TObject *Sender) { OnChangeSize(); } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::OnChangeSize(){ int h=ClientHeight; int w=ClientWidth; if(CaptureVisible){ //Shape3->Left=w-gbSimulation->Width-2; //Shape3->Top=2; sbSimulation->Left=w-gbSimulation->Width; sbSimulation->Top=2; gbSimulation->Top=sbSimulation->Height+4; gbSimulation->Left=w-gbSimulation->Width-2; SimulationScrollBox->Left=2; SimulationScrollBox->Top=2; SimulationScrollBox->Height=h-SimulationScrollBox->Top-6-HorzScrollBar->Height; SimulationScrollBox->Width=w-gbSimulation->Width-8-VertScrollBar->Width; HorzScrollBar->Width=SimulationScrollBox->Width; VertScrollBar->Height=SimulationScrollBox->Height; HorzScrollBar->Top=SimulationScrollBox->Top+SimulationScrollBox->Height+2; VertScrollBar->Left=SimulationScrollBox->Left+SimulationScrollBox->Width+2; VertScrollBar->Top=SimulationScrollBox->Top; HorzScrollBar->Left=SimulationScrollBox->Left; AboutPanel->Visible=false; } else { //Shape3->Left=w-gbSimulation->Width-2; //Shape3->Top=2; sbSimulation->Left=w-gbSimulation->Width; sbSimulation->Top=2; gbSimulation->Top=sbSimulation->Height+4; gbSimulation->Left=w-gbSimulation->Width-2; AboutPanel->Top=2; AboutPanel->Left=2; AboutPanel->Width=w-gbSimulation->Width-6; AboutPanel->Height=gbSimulation->Top+gbSimulation->Height; SimulationScrollBox->Left=2; SimulationScrollBox->Top=sbSimulation->Height+gbSimulation->Height+6; SimulationScrollBox->Height=h-SimulationScrollBox->Top-6-HorzScrollBar->Height; SimulationScrollBox->Width=w-6-VertScrollBar->Width; HorzScrollBar->Width=SimulationScrollBox->Width; VertScrollBar->Height=SimulationScrollBox->Height; HorzScrollBar->Top=SimulationScrollBox->Top+SimulationScrollBox->Height+2; VertScrollBar->Left=SimulationScrollBox->Left+SimulationScrollBox->Width+2; VertScrollBar->Top=SimulationScrollBox->Top; HorzScrollBar->Left=SimulationScrollBox->Left; AboutPanel->Visible=true; if(lbSystem->Width+lbSystem->Left>AboutPanel->Width){ lbSystem->Visible=false; lbType->Visible=false; Copyright->Visible=false; http->Visible=false; ProgramIcon->Visible=false; } else { lbSystem->Visible=true; lbType->Visible=true; Copyright->Visible=true; http->Visible=true; ProgramIcon->Visible=true; } } RzPanel1->Top = AboutPanel->Height/2-RzPanel1->Height/2; RzPanel1->Left = AboutPanel->Width/2-RzPanel1->Width/2; ShowImage(); } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::SimulationPopupMenuPopup(TObject *Sender) { UpdateMenu(); } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::SetFont(){ SetSmallFont(Font); SetSmallFont(sbSimulation->Font); SetSmallFont(gbSimulation->Font); SetSmallFont(lbSimulationZoom->Font); SetSmallFont(lbSimulationW->Font); SetSmallFont(lbCPC->Font); SetSmallFont(lbFuzz->Font); SetSmallFont(lbBack->Font); SetSmallFont(lbBGColor->Font); SetSmallFont(lbSimulation->Font); } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::MakeImage(){ #ifdef NO_SIM_VERSION image->Create(80, 100, 24); image->FillRect(Rect(0, 0, 80, 100), clWhite); #else #ifdef LOCK_HASP if(ProtectCard==NULL){ ShowMessage(IDS_MESSAGE_INTERFACE); Application->Terminate(); return; } else { #ifdef HASPSRM ProtectCard->isHacked(true); #else #ifdef NETHASP ProtectCard->Lock_Check(); #else ProtectCard->Read(); #endif if (ProtectCard->isHacking) { ShowMessage(IDS_MESSAGE_INTERFACE); Application->Terminate(); return; } #endif } #endif #ifdef LOCK_IFC if(ProtectCard==NULL){ ShowMessage(IDS_MESSAGE_INTERFACE); Application->Terminate(); return; } else if(!ProtectCard->CheckPassword()) { ShowMessage(IDS_MESSAGE_INTERFACE); Application->Terminate(); return; } #endif Main->UpdateForms();//½Ã¹Ä·¹ÀÌ¼Ç ÇÏ´Â µ¿¾È À̹ÌÁö ±úÁü º¹¿ø if (!SetSimulationData()) { Application->MessageBox("Please, check the setting menu !", "Warning", MB_OK); return; // by maxleo21c (06.11.04) } UpdateMenu(); TCursor cursor = Screen->Cursor; Screen->Cursor = crHourGlass; int width = Main->texlayer->complete_needle; //ÀåÁø¸¸ : ÃÖ¼Ò°ø¹è¼ö¸¦ À§ÇØ if(Main->texlayer->default_complete_needle == true){ int a[MAX_LAYER_COUNT] = {0,0,0,0,0,0,0}; TList *TexList = Main->texlayer->TexList; for(int j2=0;j2Count;j2++){ Tex *tex = ((Tex *)TexList->Items[j2]); for(int i2=0;i2Wales->Count;i2++) a[j2]+= ((WaleState *)(tex->Wales->Items[i2]))->cnt; } width = GetLCN(a[0],a[1],a[2],a[3],a[4],a[5],a[6]); } int height = Main->maindata.course; int tm_width = (int)(sd.RDistX*(double)width)*sd.rW; int tm_height = (int)(sd.RDistY*(double)height)*sd.rH; try { image->Create(tm_width, tm_height, 24); } catch(...){ ShowMessage(IDS_MESSAGE_TOO_LARGE_BITMAP_ZOOM_REPEAT); return; } TexLayer *texlayer = Main->texlayer; Tricot *tricot = new Tricot(width, height, ((double)(sd.RDistX*(double)width))/(double)width, ((double)(sd.RDistY*(double)height))/(double)height); // ((int)(sd.RDistX*(double)width))/(double)width, // by maxleo21c(06.11.04) ¿Ö int·Î typecastingÀ» Çß´ÂÁö ¸ð¸£°Ú´Ù. // ((int)(sd.RDistY*(double)height))/(double)height);// width/heightº¸´Ù ÀÛÀ¸¸é 0ÀÌ ³ª¿Ã¼ö Àֱ⠶§¹®ÀÌ´Ù. //(½ÇÁ¦ ºñÆ®¸ÊÀÇ Æø) = (int)(sd.RDistX*(double)width) //(ÇÑ Ä­ÀÇ °£°Ý) = (½ÇÁ¦ ºñÆ®¸ÊÀÇ Æø)/(double)width = ((int)(sd.RDistX*(double)width))/(double)width Yarnmap *yarnmap = new Yarnmap(sd.RDistX*(double)width, sd.RDistY*(double)height, (double)sd.zoom+sd.sub_zoom/10.0, sd.back, sd.coc, sd.fuzz, sd.c); ProgressPercentage *percent = new ProgressPercentage(this, ""); //texlayer->MakeYarnImage(); percent->Reset(IDS_INITIALIZING); tricot->InitTricot(texlayer, GuideBar_F->gd.ShowRunin, percent); Treatment_F->PreTreat(tricot);//OptimizeÇϱâÀü¿¡ pileÀ» ÀÏÀ¸Å°´Â ´Ù¸®¸¦ NO_LEG·Î.. percent->Reset(IDS_OPTIMIZING); tricot->Optimize(sd.optimization, sd.span_effect, GuideBar_F->gd.NoTension, percent); yarnmap->MappingTricot(tricot);//MappingOctopus¸¦ ÀÛµ¿½ÃŲ´Ù percent->Reset(IDS_SIMULATING); yarnmap->Draw(image,percent, SimulationAdvSetForm->cbrandomness->Checked);//ºñÆ®¸Ê¿¡ ±×¸°´Ù percent->Reset(IDS_SPANDEX_EFFECT); yarnmap->SpandexEffect(image, sd.span_effect, sd.span_power, sd.span_invert, percent);//½ºÆÇ È¿°ú¸¦ ¸í¾ÏÀ» ÀÌ¿ëÇÏ¿© ³ÖÀ»°Í.. percent->Reset(IDS_TENSION_EFFECT); yarnmap->TensionEffect(image, GuideBar_F->gd.ShowRunin, percent);//tension¿¡ ÀÇÇÑ ±¼°î Ç¥Çö percent->Reset(IDS_TREATING); Treatment_F->FinalTreat(image,sd.RDistX*(double)width,sd.RDistY*(double)height,percent);//¸ðµç󸮰¡ ³¡³ª°í Èİ¡°ø ÆûÀÇ µ¥ÀÌŸ¸¦ °¡Áö°í Èİ¡°øÀ» ½ÃÇà delete percent; delete yarnmap; delete tricot; Screen->Cursor = cursor; #endif } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::ShowImage(){ if(image){ try{ SImage->Top=0; SImage->Left=0; SImage->Picture->Bitmap->Width = min(image->Width,SimulationScrollBox->Width); SImage->Picture->Bitmap->Height = min(image->Height,SimulationScrollBox->Height); if(image->Width>SimulationScrollBox->Width){ HorzScrollBar->Max=image->Width-SimulationScrollBox->Width; } else { HorzScrollBar->Max=0; } if(image->Height>SimulationScrollBox->Height){ VertScrollBar->Max=image->Height-SimulationScrollBox->Height; } else { VertScrollBar->Max=0; } } catch(...){ ShowMessage(IDS_MESSAGE_TOO_LARGE_BITMAP_ZOOM_REPEAT); return; } HDC hDC = image->CreateDC(); BitBlt(SImage->Canvas->Handle,0,0,SImage->Width,SImage->Height, hDC,HorzScrollBar->Position,VertScrollBar->Position, SRCCOPY); image->DeleteDC(hDC); SImage->Repaint(); } else { SImage->Picture->Bitmap->Width=0; SImage->Picture->Bitmap->Height=0; SImage->Width=0; SImage->Height=0; SImage->Repaint(); } } //--------------------------------------------------------------------------- bool __fastcall TSimulationForm::SetSimulationData(){ if(edSZoom->Text=="")edSZoom->Text="4.0"; //ÀåÁø¸¸ if(edSWidth->Text=="")edSWidth->Text="0"; if(edSCPC->Text=="")edSCPC->Text="0"; // by maxleo21c (06.11.02) float f_edSWidth, f_edSCPC, f_edSZoom; int i_edFuzz; if (!::TryStrToFloat(edSWidth->Text, f_edSWidth)) return false; if (!::TryStrToFloat(edSCPC->Text, f_edSCPC)) return false; if (!::TryStrToFloat(edSZoom->Text, f_edSZoom)) return false; if (!::TryStrToInt(edFuzz->Text, i_edFuzz)) return false; if (f_edSWidth<1) edSWidth->Text="1"; if (f_edSCPC<1) edSCPC->Text="1"; if (f_edSCPC>100) edSCPC->Text="100"; int tempi = (int)f_edSZoom; int tempi2 = (int)(f_edSZoom*10); if(tempi < 1){ tempi = 1; tempi2 = 10; edSZoom->Text = "1.0"; } if(tempi > 100){ tempi = 100; tempi2 = 1000; edSZoom->Text = "100"; } sd.zoom = tempi; sd.sub_zoom = tempi2 - tempi*10; //¿©±â±îÁö sd.width = f_edSWidth; sd.gauge=Main->maindata.width*Main->maindata.gauge/sd.width; sd.cpc = f_edSCPC; sd.fuzz = i_edFuzz; sd.back = cbBack->Checked; sd.c = spBGColor->Brush->Color; int width = Main->texlayer->complete_needle; if(Main->texlayer->default_complete_needle == true){ //ÀåÁø¸¸ : ÃÖ¼Ò°ø¹è¼ö¸¦ À§ÇØ int a[MAX_LAYER_COUNT] = {0,0,0,0,0,0,0}; TList *TexList = Main->texlayer->TexList; for(int j2=0;j2Count;j2++){ Tex *tex = ((Tex *)TexList->Items[j2]); for(int i2=0;i2Wales->Count;i2++) a[j2]+= ((WaleState *)(tex->Wales->Items[i2]))->cnt; } width = GetLCN(a[0],a[1],a[2],a[3],a[4],a[5],a[6]); } int height = Main->maindata.course; //sd.zoom sd.RDistX = 2.54*(double)DOT_PER_CM/(double)sd.gauge*(double)(sd.zoom+sd.sub_zoom/10.0);// DOT_PER_CM //¼¾Æ¼¹ÌÅÍ´ç µµÆ® sd.RDistY = (double)DOT_PER_CM/sd.cpc*(double)(sd.zoom+sd.sub_zoom/10.0); sd.rW = SimulationScrollBox->Width/(sd.RDistX*(double)width)+1; sd.rH = SimulationScrollBox->Height/(sd.RDistY*(double)height)+1; return true; } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::ShowSimulationData(){ SimulationForm->edSZoom->Text=IntToStr(sd.zoom) + "." + IntToStr(sd.sub_zoom); //ÀåÁø¸¸ : ÁÜ °ü·Ã SimulationForm->edSWidth->Text=MyFloatToStr(sd.width,2); SimulationForm->edSCPC->Text=MyFloatToStr(sd.cpc,2); SimulationForm->cbBack->Checked=sd.back; SimulationForm->edFuzz->Text=IntToStr(sd.fuzz); SimulationForm->spBGColor->Brush->Color=sd.c; } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::New(){ if(image)image->Destroy(); SImage->Picture->Bitmap->Width=0; SImage->Picture->Bitmap->Height=0; SImage->Width=0; SImage->Height=0; SImage->Repaint(); sd.reset(); ShowSimulationData(); SimulationAdvSetForm->SetData(); } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::FormDestroy(TObject *Sender) { if(image) { delete image; image = NULL; } SimulationForm=NULL; /* TIniFile *IniFile = new TIniFile(BaseDir + "\\Environment.ini"); if (IniFile) { IniFile->WriteInteger("Simulation", "Zoom", sd.zoom); //ÀåÁø¸¸ : ¼³Á¤ ÀúÀå IniFile->WriteInteger("Simulation", "Sub_zoom", sd.sub_zoom); IniFile->WriteFloat("Simulation", "Width", sd.width); IniFile->WriteFloat("Simulation", "Cpc", sd.cpc); IniFile->WriteInteger("Simulation", "Fuzz", sd.fuzz); IniFile->WriteBool("Simulation", "Back", sd.back); delete IniFile; } */ } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::VertScrollBarChange(TObject *Sender) { ShowImage(); } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::HorzScrollBarChange(TObject *Sender) { ShowImage(); } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::pmsmSaveClick(TObject *Sender) { BEGIN_TEX; if(SavePictureDialog->Execute()) { if(SavePictureDialog->FilterIndex==1){ SImage->Picture->Bitmap->SaveToFile(SavePictureDialog->FileName); } else if(SavePictureDialog->FilterIndex==2){ TJPEGImage *jp = new TJPEGImage(); try { jp->Assign(SImage->Picture->Bitmap); jp->SaveToFile(SavePictureDialog->FileName); } __finally { delete jp; } } } END_TEX; } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::sbAdvancedClick(TObject *Sender) { BEGIN_TEX; if(SimulationAdvSetForm->Visible)SimulationAdvSetForm->Visible=false; else SimulationAdvSetForm->Visible=true; END_TEX; } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::FormShow(TObject *Sender) { static bool first=true; if(first){ InitForm(); first=false; } } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::InitForm(){ TIniFile *IniFile = new TIniFile(BaseDir + "\\Main.ini"); if (IniFile) { CaptureVisible=IniFile->ReadBool("Capture", "Visible", true); delete IniFile; } if(CaptureVisible){ Top=(Main->ClientHeight-4)/2; Height=(Main->ClientHeight-4)/2; Left=0; Width=(Main->ClientWidth-209-2)/2; } else { Top=0; Height=Main->ClientHeight-4; Left=0; Width=(Main->ClientWidth-209-2)/2; } OnChangeSize(); } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::httpClick(TObject *Sender) { char win[MAX_PATH]; GetWindowsDirectory(win,MAX_PATH); SHELLEXECUTEINFO screeninfo; memset(&screeninfo,0,sizeof(screeninfo)); screeninfo.cbSize = sizeof(screeninfo); screeninfo.lpVerb = "open"; screeninfo.lpDirectory = win; screeninfo.lpFile = "explorer.exe"; screeninfo.lpParameters = "http://www.texclub.com/"; screeninfo.fMask = SEE_MASK_NOCLOSEPROCESS; screeninfo.nShow = SW_SHOWDEFAULT; if(!ShellExecuteEx(&screeninfo)) { ShowMessage("Unknown Error in "+this->Name); } } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::HotKeyPress(char &Key) { switch(Key) { case '\x03'://ctrl+c { if(image->Width){ pmsmToClipBoardClick(NULL); } break; } } } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::cbBackKeyPress(TObject *Sender, char &Key) { HotKeyPress(Key); } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::FormKeyPress(TObject *Sender, char &Key) { HotKeyPress(Key); } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::VertScrollBarKeyPress(TObject *Sender, char &Key) { HotKeyPress(Key); } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::HorzScrollBarKeyPress(TObject *Sender, char &Key) { HotKeyPress(Key); } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::pmnoTex3D(TObject *Sender) { ShowMessage(IDS_MESSAGE_INSTALL_TEX3D); return; } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::pmsmTex3DClick(TObject *Sender) { BEGIN_TEX; if(image->Width){ pmsmToClipBoardClick(Sender); AnsiString tex3d; TRegistry *Registry; SHELLEXECUTEINFO screeninfo; Registry = new TRegistry; if (!Registry) { END_TEX; return; } Registry->RootKey = HKEY_LOCAL_MACHINE; Registry->OpenKey("SOFTWARE\\Youngwoo\\Tex3D\\" + ((TMenuItem *)Sender)->Hint + "\\Directory",TRUE); tex3d = Registry->ReadString("bin"); delete Registry; memset(&screeninfo,0,sizeof(screeninfo)); screeninfo.cbSize = sizeof(screeninfo); screeninfo.lpVerb = "open"; screeninfo.lpDirectory = tex3d.c_str(); screeninfo.lpFile = "tex3d.exe"; screeninfo.fMask = SEE_MASK_NOCLOSEPROCESS; screeninfo.nShow = SW_SHOWDEFAULT; ShellExecuteEx(&screeninfo); } END_TEX; } //--------------------------------------------------------------------------- float __fastcall TSimulationForm::GetTex3DInstallVersion() { pmsmTex3D->Clear(); TMenuItem *Item; // Tex3D°¡ ¼³Ä¡µÈ µå¶óÀ̺긦 ã¾Æ³½´Ù (°¡Àå ÃֽйöÀüÀ¸·Î..) bool find_tex3d = false; BYTE cIsNumber; bool bNumber; AnsiString strDrv; AnsiString strRegFileName; TRegIniFile *RegIniFile; TStrings *strsRegistry = new TStringList; strRegFileName = "SOFTWARE\\YoungWoo\\Tex3D\\"; RegIniFile = new TRegIniFile(strRegFileName); RegIniFile->RootKey = HKEY_LOCAL_MACHINE; strsRegistry->Clear(); RegIniFile->RootKey = HKEY_LOCAL_MACHINE; RegIniFile->OpenKey(strRegFileName, false); RegIniFile->GetKeyNames(strsRegistry); float dTex3DVersion = 0.0; if (RegIniFile && strsRegistry->Count > 0) { // for·çÇÁ¸¦ µ¹¸é¼­ °¡Àå ÃֽйöÀüÀ» ã´Â´Ù for (int i = strsRegistry->Count-1; i >= 0; i--) { bNumber = true; for (int j = 1; j <= strsRegistry->Strings[i].Length(); j++) { strncpy(&cIsNumber, strsRegistry->Strings[i].SubString(j, 1).c_str(), 1); if ('0' <= cIsNumber && cIsNumber <= '9' || cIsNumber == '.') bNumber &= true; // ½Ç¼öÀÎ °æ¿ì¸¸.. else bNumber &= false; } if (bNumber && strsRegistry->Strings[i].Length()<6) { // Á¦ÀÏ ³ôÀº ¹öÀüÀ» ã´Â´Ù // dTex3DVersion = (dTex3DVersion > StrToFloat(strsRegistry->Strings[i])) ? dTex3DVersion : StrToFloat(strsRegistry->Strings[i]); Item = new TMenuItem(this); Item->Caption = strsRegistry->Strings[i]; Item->Hint = strsRegistry->Strings[i]; Item->Tag = i; Item->OnClick = pmsmTex3DClick; pmsmTex3D->Add(Item); find_tex3d = true; } else { // ½Ç¼ö°¡ ¾Æ´Ï¸é Áö¿î´Ù strsRegistry->Delete(i); continue; } } } if(!find_tex3d){ pmsmTex3D->OnClick = pmnoTex3D; }else{ pmsmTex3D->OnClick = NULL; } if (RegIniFile) { delete RegIniFile; RegIniFile = NULL; } if(strsRegistry){ delete strsRegistry; strsRegistry = NULL; } return dTex3DVersion; } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::cbBackClick(TObject *Sender) { if(!SetSimulationData()) return; // by maxleo21c (06.11.04) sd.back = cbBack->Checked; sbSimulationClick(NULL); } //---------------------------------------------------------------------------