//--------------------------------------------------------------------------- #include #include #pragma hdrstop #include "Main_F.h" #include "DesignViewForm.h" #include "FileManager_F.h" #include "Environment_F.h" #include "yarnmap.h" #include "GuideBar.h" #include "YarnCompositionData.h" #include "treatment.h" #include "ProgressPercentage.h" #include "About.h" #include "SplashForm.h" #include "PrintingForm.h" #include "Viewer.h" #include #include #include "ProtectCard.h" #include "capture.h" #include "Simulation_F.h" #include "Design.h" #include "MetaData_F.h" #include "YarnList_F.h" #include "Editor.h" #include "SimulationAdvSet_F.h" #include "Cost.h" #include "HiddenPrintData_F.h" #include "YarnTable_F.h" //gabriel #include "YarnDesign_F.h" //gabriel #include "Palette.h" //gabriel #include "DTPColorLibrary_F.h" //Altang //2016.10.27 - Upload xml Test #include #include #include #include #include #include #include #include #include #ifdef LOCK_TEX #include "Seedx.h" #endif //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "TPRuler2D" #pragma link "RzPanel" #pragma link "RzButton" #pragma link "RzEdit" #pragma resource "*.dfm" //--------------------------------------------------------------------------- #define IDS_BAR_SELECT StringTable[0] #define IDS_MAIN_MENU StringTable[1] #define IDS_PRIMARY_SETTING_MENU StringTable[2] #define IDS_SIMULATION StringTable[3] #define IDS_SAVELOAD StringTable[4] #define IDS_GUIDE_BAR_SETTING StringTable[5] #define IDS_TREATMENT_SETTING StringTable[6] #define IDS_CAPTURE_IMAGE StringTable[7] #define IDS_ANALYZE_IMAGE StringTable[8] #define IDS_DESIGN StringTable[9] #define IDS_BAR StringTable[10] #define IDS_COURSE StringTable[11] #define IDS_WPI StringTable[12] #define IDS_CPC StringTable[13] #define IDS_WIDTH StringTable[14] #define IDS_FILE StringTable[15] #define IDS_NEW StringTable[16] #define IDS_OPENSAVE StringTable[17] #define IDS_PRINT StringTable[18] #define IDS_EXIT StringTable[19] #define IDS_COMPOSITION StringTable[20] #define IDS_ABOUT StringTable[21] #define IDS_ENVIRONMENT StringTable[22] #define IDS_REOPEN StringTable[23] #define IDS_WINDOW StringTable[24] #define IDS_M_DESIGN StringTable[25] #define IDS_M_TREATMENT StringTable[26] #define IDS_M_SIMULATION StringTable[27] #define IDS_M_CAPTURE StringTable[28] #define IDS_M_INOUT StringTable[29] #define IDS_ADDITIONAL_PROPERTY StringTable[30] #define IDS_YARN_LIST StringTable[31] #define IDS_YARN_DB StringTable[32] #define IDS_FONT StringTable[33] #define IDS_SAVE_AND_EXIT StringTable[34] #define IDS_PRODUCTION StringTable[35] #define IDS_COST StringTable[36] #define IDS_YARNMAKER StringTable[37] //--------------------------------------------------------------------------- TMain *Main; //--------------------------------------------------------------------------- __fastcall TMain::TMain(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TMain::FormResize(TObject *Sender) { #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 OnChangeSize(); if(CaptureForm) CaptureForm->InitForm(); #ifndef NO_SIM_VERSION if(SimulationForm) SimulationForm->InitForm(); #endif if(DesignForm)DesignForm->InitForm(); } //--------------------------------------------------------------------------- void __fastcall TMain::SetFont(){ SetSmallFont(Font); SetSmallFont(gbBarSelect->Font); SetSmallFont(gbMainMenu->Font); SetSmallFont(gbBasic->Font); SetSmallFont(sbLoadSave->Font); SetSmallFont(sbGuideBar->Font); SetSmallFont(sbTreatment->Font); SetSmallFont(sbPrint->Font); SetSmallFont(lbBar->Font); SetSmallFont(lbCourse->Font); SetSmallFont(lbmWPI->Font); SetSmallFont(lbmCPC->Font); SetSmallFont(lbWidth->Font); SetSmallFont(sbL7->Font); SetSmallFont(sbL6->Font); SetSmallFont(sbL5->Font); SetSmallFont(sbL4->Font); SetSmallFont(sbL3->Font); SetSmallFont(sbL2->Font); SetSmallFont(sbL1->Font); SetSmallFont(Label1->Font); SetSmallFont(Label2->Font); SetSmallFont(Label3->Font); } //--------------------------------------------------------------------------- void __fastcall TMain::FormCreate(TObject *Sender) { OSVERSIONINFO osinfo; osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&osinfo); // Vista¿¡´Â "MS Sans Serif"°¡ "Microsoft Sans Serif"·Î ¹Ù²î¾ú´Ù - by monkman (2007.05.10) if ((osinfo.dwMajorVersion == 6) && (osinfo.dwMinorVersion >= 0)) { DefaultFontName = "Microsoft Sans Serif"; // Vista } else { DefaultFontName = "MS Sans Serif"; // Etc (!Vista) } BaseDir = ExtractFileDir(Application->ExeName); TRegIniFile *RegIniFile = NULL; RegIniFile = new TRegIniFile(RegFilename); RegIniFile->RootKey = HKEY_LOCAL_MACHINE; RegIniFile->OpenKey(RegFilename + "\\",true); // yw if (RegIniFile) { BaseDir = RegIniFile->ReadString("Common", "Defaultdir", BaseDir); delete RegIniFile; } Undo = new undodata; if(IsVivien()){ #ifdef NO_SIM_VERSION Caption = PROGRAM_NAME + " " + VERSION + " (Vivien) - Restricted Version"; #else Caption = PROGRAM_NAME + " " + VERSION + " (Vivien)"; #endif } else { #ifdef NO_SIM_VERSION Caption = PROGRAM_NAME + " " + VERSION + " - Restricted Version"; #else Caption = PROGRAM_NAME + " " + VERSION + ""; #endif } #ifdef NO_SIM_VERSION mSimulation->Enabled = false; //sbSimulation->Enabled = false; #endif //////////////////////////////////////////////////////////////////////////////// SmallFont = new TFont; TIniFile *IniFile = new TIniFile(BaseDir + "\\Environment.ini"); if (IniFile) { Language=IniFile->ReadString("Environment", "Language", "English"); LoadFont(IniFile, SmallFont, "Font"); if (Language == "Korean" && (SmallFont->Name == "Microsoft Sans Serif" || SmallFont->Name == "MS Sans Serif")) { SmallFont->Name = "Gulim"; } maindata.bar = IniFile->ReadInteger("Main", "Bar", 2); //ÀåÁø¸¸ : ¼³Á¤ ·Îµå maindata.course = IniFile->ReadInteger("Main", "Course", 16); maindata.gauge = IniFile->ReadInteger("Main", "Gauge", 28); maindata.cpc = IniFile->ReadInteger("Main", "Cpc", 20); maindata.width = IniFile->ReadInteger("Main", "Width", 105); maindata.tex_max_width2 = IniFile->ReadInteger("Environment", "TexMaxWidth", 150); LayerMode = IniFile->ReadInteger("Environment", "LayerMode", 0); delete IniFile; } SetFont(); CommonStringTable.Create(BaseDir, Language, "Common"); MessageStringTable.Create(BaseDir, Language, "Message"); StringTable.Create(BaseDir, Language, "Main"); SetSmallFont(this->Font); //Áß±¹¾î ±úÁü °ü·ÃÇØ¼­ Àӽ÷ΠÀû¿ë. NDJ //gbBarSelect->Caption=IDS_BAR_SELECT; //gbBarSelect2->Caption=IDS_BAR_SELECT; //gbMainMenu->Caption=IDS_MAIN_MENU; //gbBasic->Caption=IDS_PRIMARY_SETTING_MENU; Label1->Caption=IDS_MAIN_MENU; Label2->Caption=IDS_PRIMARY_SETTING_MENU; Label3->Caption=IDS_BAR_SELECT; sbSimulation->Hint=IDS_SIMULATION; sbLoadSave->Hint=IDS_SAVELOAD; sbDesign->Hint=IDS_DESIGN; sbGuideBar->Hint=IDS_GUIDE_BAR_SETTING; sbTreatment->Hint=IDS_TREATMENT_SETTING; sbCapture->Hint=IDS_CAPTURE_IMAGE; sbPrint->Hint=IDS_COMMON_PRINT; lbBar->Caption=IDS_BAR; lbCourse->Caption=IDS_COURSE; lbmWPI->Caption=IDS_WPI; lbmCPC->Caption=IDS_CPC; lbWidth->Caption=IDS_WIDTH; mFile->Caption=IDS_FILE; mNew->Caption=IDS_NEW; mOpenSave->Caption=IDS_OPENSAVE; mPrint->Caption=IDS_PRINT; mExit->Caption=IDS_EXIT; mYarn->Caption=IDS_COMPOSITION; mAbout->Caption=IDS_ABOUT; mReopen->Caption=IDS_REOPEN; mEnvironment->Caption=IDS_ENVIRONMENT; mWindow->Caption=IDS_WINDOW; mDesign->Caption=IDS_M_DESIGN; mTreatment->Caption=IDS_M_TREATMENT; mSimulation->Caption=IDS_M_SIMULATION; mCapture->Caption=IDS_M_CAPTURE; mInOut->Caption=IDS_M_INOUT; mProperty->Caption=IDS_ADDITIONAL_PROPERTY; mYarnList->Caption=IDS_YARN_LIST; mYarnMaker->Caption=IDS_YARNMAKER; //mYarnDB->Caption=IDS_YARN_DB; //mFont->Caption=IDS_FONT; mProduction->Caption=IDS_PRODUCTION; mCost->Caption=IDS_COST; #ifdef UPLOAD_IDS Upload1->Visible = true; #else Upload1->Visible = false; #endif //////////////////////////////////////////////////////////////////////////////// PrinterColor = new TPrinterColor; StandardColor = new TStandardColor(BaseDir +"\\color"+"\\Standard.tpc"); TextileColor = new TTextileColor(BaseDir +"\\color"+"\\Textile.tpc"); Pantone1000 = new TPantone1000(BaseDir +"\\color"+"\\Thousand.ptc"); //ã±â À§Çؼ­ PantoneTextile = new TPantoneTextile(BaseDir +"\\color"+"\\Textile.ptc"); RegIniFile = NULL; AnsiString s; RegIniFile = new TRegIniFile(RegFilename); RegIniFile->RootKey = HKEY_LOCAL_MACHINE; RegIniFile->OpenKey(RegFilename + "\\",true); // yw if (RegIniFile) { bool r=false; for(int i=0;i<10;i++){ s = RegIniFile->ReadString("Recent Files", IntToStr(i), ""); if(s!=""){ r=true; TMenuItem *item = new TMenuItem(NULL); item->Caption=s; item->OnClick = mReopenSubItemsClick; mReopen->Add(item); } } mReopen->Enabled=r; delete RegIniFile; } srand(clock()); texlayer = new TexLayer; LayerNum=0; for(int i=0;iAddLayer(); } texlayer->SetHeight(maindata.course); texTemp = NULL; //////////////////////////////////////////////////////////////////////////////// //create forms //autocreate¸¦ ¾ø¾Ö°í ¿©±â¿¡ ³ÖÀ» ¼ö ÀÖÀ½ HiddenPrintDataForm = NULL; //////////////////////////////////////////////////////////////////////////////// ShowMainData(); OnChangeSize(); int Items; ProtectCard = new TProtectCard; #ifdef LOCK_HASP LoadFromMainRegIniFile(); #ifndef HASPSRM Items = ProtectCard->Init(Password); #ifdef NO_SIM_VERSION if ((((Items>>14)&3)==3)||Items<1 || (Items&PCN_TEXTRICOT_R)!=PCN_TEXTRICOT_R) { #else if ((((Items>>14)&3)==3)||Items<1 || (Items&PCN_TEXTRICOT )!=PCN_TEXTRICOT ) { #endif delete ProtectCard; ProtectCard = NULL; ShowMessage(IDS_MESSAGE_INTERFACE); Application->Terminate(); return; } else { #ifdef NETHASP ProtectCard->Lock_Check(); #else ProtectCard->Read(); ProtectCard->Check(); #endif if (ProtectCard->isHacking) { Application->Terminate(); return; } } #else //HASPSRM if (!ProtectCard->Init(hsTexTricot, VERSION)) { ShowMessage(IDS_MESSAGE_INTERFACE); Application->Terminate(); return; } if (ProtectCard->isHacked()) { ShowMessage(IDS_MESSAGE_INTERFACE); Application->Terminate(); return; } #endif #ifdef NETHASP switch (Items >> 14) { case 1: Caption = "Net" + Caption + " - Education"; break; case 2: Caption = "Net" + Caption + " - Demo"; break; default: break; } #else switch (Items >> 14) { case 1: Caption = Caption + " - Education"; break; case 2: Caption = Caption + " - Demo"; break; default: break; } #endif #endif #ifdef LOCK_IFC Items = ProtectCard->Init(RegFilename); #ifdef NO_SIM_VERSION if (Items==0 || (Items&PCN_TEXTRICOT_R)!=PCN_TEXTRICOT_R) { #else if (Items==0 || (Items&PCN_TEXTRICOT )!=PCN_TEXTRICOT ) { #endif delete ProtectCard; ProtectCard = NULL; ShowMessage(IDS_MESSAGE_INTERFACE); Application->Terminate(); return; } else if(!ProtectCard->CheckPassword()) { ShowMessage(IDS_MESSAGE_INTERFACE); Application->Terminate(); return; } #endif if (LayerMode) { //new gbBarSelect->Visible = false; gbBarSelect2->Left = gbBarSelect->Left; gbBarSelect2->Top = gbBarSelect->Top; gbBarSelect2->Width = gbBarSelect->Width; gbBarSelect2->Height = gbBarSelect->Height; gbBarSelect2->BringToFront(); gbBarSelect2->Visible = true; } else { //±âÁ¸ ¹æ½Ä gbBarSelect2->Visible = false; gbBarSelect->BringToFront(); gbBarSelect->Visible = true; } #ifdef LOCK_TEX CheckTimer->Enabled = true; #endif #ifdef HASPSRM TimerHASPSRM->Enabled = true; #endif } //--------------------------------------------------------------------------- void __fastcall TMain::OnChangeSize(){ int h=ClientHeight; int w=ClientWidth; MainMenuPanel->Top=0; MainMenuPanel->Left=w-MainMenuPanel->Width; } //--------------------------------------------------------------------------- void __fastcall TMain::FormPaint(TObject *Sender) { static bool first=true; if(first){ bool CaptureVisible=true; TIniFile *IniFile = new TIniFile(BaseDir + "\\Main.ini"); if (IniFile) { CaptureVisible=IniFile->ReadBool("Capture", "Visible", true); delete IniFile; } if (CaptureForm) CaptureForm->WindowState = CaptureVisible ? wsNormal : wsMinimized; first=false; } if(GuideBar_F&&GuideBar_F->Visible)GuideBar_F->Repaint(); } //--------------------------------------------------------------------------- void __fastcall TMain::FormDestroy(TObject *Sender) { delete Undo; delete SmallFont; SmallFont=NULL; delete PantoneTextile; PantoneTextile = NULL; delete Pantone1000; Pantone1000 = NULL; delete TextileColor; TextileColor = NULL; delete StandardColor; StandardColor = NULL; delete PrinterColor; PrinterColor = NULL; if(texlayer){ delete texlayer; texlayer = NULL; } if(ProtectCard) { delete ProtectCard; ProtectCard = NULL; } if(texTemp) delete texTemp; if(HiddenPrintDataForm) delete HiddenPrintDataForm; TIniFile *IniFile = new TIniFile(BaseDir + "\\Environment.ini"); if (IniFile) { IniFile->WriteInteger("Main", "Bar", maindata.bar); IniFile->WriteInteger("Main", "Course", maindata.course); IniFile->WriteInteger("Main", "Gauge", maindata.gauge); IniFile->WriteInteger("Main", "Cpc", maindata.cpc); IniFile->WriteInteger("Main", "Width", maindata.width); IniFile->WriteInteger("Main", "TexMaxWidth2", maindata.tex_max_width2); delete IniFile; } //DestroyYarnForms(); } //--------------------------------------------------------------------------- void __fastcall TMain::edCourseKeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ if(edCourse->Text=="")return; Undo->reset(); int i_edCourse; // by maxleo21c (06.11.04) if (!::TryStrToInt(edCourse->Text, i_edCourse)) return; maindata.course=i_edCourse; if (maindata.course>5000) {//gabriel maindata.course = 5000; edCourse->Text="5000"; } texlayer->SetHeight(maindata.course); DesignForm->DrawChart(false); if(GuideBar_F&&GuideBar_F->Visible)GuideBar_F->Repaint(); if(YarnCompositionData_F&&YarnCompositionData_F->Visible)YarnCompositionData_F->Repaint(); if(Treatment_F->Visible)Treatment_F->Repaint(); edMGauge->SetFocus(); //EditorForm->tsELShow(Sender);//gabriel EditorForm->lb3TT1->Caption=edCourse->Text; EditorForm->lb3TT2->Caption=edCourse->Text; EditorForm->lb3TT3->Caption=edCourse->Text; EditorForm->lb3TT4->Caption=edCourse->Text; EditorForm->lb3TT5->Caption=edCourse->Text; EditorForm->lb3TT6->Caption=edCourse->Text; EditorForm->lb3TT7->Caption=edCourse->Text; } } //--------------------------------------------------------------------------- void __fastcall TMain::edBarKeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ int i_edBar; // by maxleo21c (06.11.04) if (!::TryStrToInt(edBar->Text, i_edBar)) return; maindata.bar=i_edBar; if(maindata.bar>MAX_LAYER_COUNT){ //gabriel maindata.bar=MAX_LAYER_COUNT; edBar->Text= IntToStr(MAX_LAYER_COUNT);//"7"; } if(maindata.bar<1){ maindata.bar=1; edBar->Text="1"; } edCourse->SetFocus(); if(maindata.bar==texlayer->TexList->Count)return; Undo->reset(); if(maindata.bar>texlayer->TexList->Count){ while(maindata.bar>texlayer->TexList->Count){ if(Main->LayerMode) texlayer->InsertLayer(0);//GuideBarÀÇ °æ¿ì ¾Õ¿¡¼­ ºÎÅÍ Ãß°¡ÇØ¾ßµÊ Layer ¿ª¼ø - kisub else texlayer->AddLayer(); } texlayer->SetHeight(maindata.course); } else { while(maindata.barTexList->Count) { if(Main->LayerMode) { texlayer->DeleteLayer(0);//GuideBarÀÇ °æ¿ì ¾Õ¿¡¼­ ºÎÅÍ Á¦°ÅÇØ¾ßµÊ Layer ¿ª¼ø - kisub } else { texlayer->DeleteLayer(texlayer->TexList->Count-1); } } } LayerNum=maindata.bar-1; UpdateBtn(); if(GuideBar_F&&GuideBar_F->Visible)GuideBar_F->Repaint(); if(YarnCompositionData_F&&YarnCompositionData_F->Visible)YarnCompositionData_F->Repaint(); DesignForm->DrawChart(false); //# sjpark - Editor Layer Visible Initialize EditorForm->tsL1->TabVisible = false; EditorForm->tsL2->TabVisible = false; EditorForm->tsL3->TabVisible = false; EditorForm->tsL4->TabVisible = false; EditorForm->tsL5->TabVisible = false; EditorForm->tsL6->TabVisible = false; EditorForm->tsL7->TabVisible = false; EditorForm->lbL1->Color = clGray; EditorForm->lbL2->Color = clGray; EditorForm->lbL3->Color = clGray; EditorForm->lbL4->Color = clGray; EditorForm->lbL5->Color = clGray; EditorForm->lbL6->Color = clGray; EditorForm->lbL7->Color = clGray; EditorForm->memoHorzData1->Enabled = false; EditorForm->memoHorzData2->Enabled = false; EditorForm->memoHorzData3->Enabled = false; EditorForm->memoHorzData4->Enabled = false; EditorForm->memoHorzData5->Enabled = false; EditorForm->memoHorzData6->Enabled = false; EditorForm->memoHorzData7->Enabled = false; if(maindata.bar>=1){ EditorForm->tsL1->TabVisible = true; EditorForm->lbL1->Font->Color = clWhite; EditorForm->lbL1->Color = RGB2TColor(62,67,88); EditorForm->memoHorzData1->Enabled = true; } if(maindata.bar>=2){ EditorForm->tsL2->TabVisible = true; EditorForm->lbL2->Font->Color = clWhite; EditorForm->lbL2->Color = RGB2TColor(62,67,88); EditorForm->memoHorzData2->Enabled = true; } if(maindata.bar>=3){ EditorForm->tsL3->TabVisible = true; EditorForm->lbL3->Font->Color = clWhite; EditorForm->lbL3->Color = RGB2TColor(62,67,88); EditorForm->memoHorzData3->Enabled = true; } if(maindata.bar>=4){ EditorForm->tsL4->TabVisible = true; EditorForm->lbL4->Font->Color = clWhite; EditorForm->lbL4->Color = RGB2TColor(62,67,88); EditorForm->memoHorzData4->Enabled = true; } if(maindata.bar>=5){ EditorForm->tsL5->TabVisible = true; EditorForm->lbL5->Font->Color = clWhite; EditorForm->lbL5->Color = RGB2TColor(62,67,88); EditorForm->memoHorzData5->Enabled = true; } if(maindata.bar>=6){ EditorForm->tsL6->TabVisible = true; EditorForm->lbL6->Font->Color = clWhite; EditorForm->lbL6->Color = RGB2TColor(62,67,88); EditorForm->memoHorzData6->Enabled = true; } if(maindata.bar>=7){ EditorForm->tsL7->TabVisible = true; EditorForm->lbL7->Font->Color = clWhite; EditorForm->lbL7->Color = RGB2TColor(62,67,88); EditorForm->memoHorzData7->Enabled = true; } //# sjpark - Editor Layer Visible Initialize EditorForm->EditorTextChange(); GuideBar_F->FormActivate(NULL);//GuideBar¿¡µµ »õ·Î¿î Bar °³¼ö °»½Å - kisub EditorForm->Init(); //EditorForm->tsELShow(NULL);//EL data checkbox ¶§¹® } } //--------------------------------------------------------------------------- void __fastcall TMain::sbGuideBarClick(TObject *Sender) { BEGIN_TEX; if(GuideBar_F->WindowState==wsMinimized){ GuideBar_F->WindowState=wsNormal; END_TEX; return; } if(GuideBar_F->Visible)GuideBar_F->Visible=false; else GuideBar_F->Visible=true; END_TEX; } //--------------------------------------------------------------------------- void __fastcall TMain::sbLoadSaveClick(TObject *Sender) { BEGIN_TEX; if (DesignView_F->Visible) DesignView_F->Visible = false; if (EditorForm->Visible) EditorForm->Visible = false; TFileManagerForm *Form = new TFileManagerForm(this); Form->Extension = 0; Form->FilterComboBox->Filter = "Tricot Files(*.trc)|*.trc"; Form->OnRead = TRCRead; Form->OnFileName = FMOnFileName; Form->OnSave = TRCSave; Form->ShowModal(); EditorForm->EditorTextChange();//ÅØ½ºÆ® º¸±â Layer °»½Å - kisub delete Form; END_TEX; } //--------------------------------------------------------------------------- AnsiString __fastcall TMain::FMOnFileName(AnsiString FileName, TGraphicFileFormat ExtIndex) { char *s; AnsiString fn; s = AnsiStrScan(FileName.c_str(), '.'); if (s==NULL) { switch (ExtIndex) { case gffTEX: fn = FileName+".tex"; break; case gffTFC: fn = FileName+".tfc"; break; case gffT3D: fn = FileName+".t3d"; break; case gffTRC: fn = FileName+".trc"; break; } return fn; } else { return FileName; } } //--------------------------------------------------------------------- ///todo: ÀúÀå ÇÔ¼ö. 2006.12.08. diekun void __fastcall TMain::TRCSave(AnsiString FileName, TCompressMethod cm){ maindata.FileName=FileName; SetAll(); HANDLE hFile; DWORD dwWrite; int ver = FILE_VERSION; try{ hFile = CreateFile(FileName.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); WriteFile(hFile, &ver, sizeof(int), &dwWrite, NULL); TTexpiaBitmap *tag = new TTexpiaBitmap; int btn = MessageDlg(IDS_MESSAGE_SIMULATIONBEFORESAVE, mtWarning, TMsgDlgButtons() << mbOK << mbCancel, 0); if (btn == mrOk) SimulationForm->MakeImage();//gabriel ////////////////////////////////////////////////////////////////////////////save tag tag->Create(80,100,24); HDC dst=tag->CreateDC(); HDC src=SimulationForm->image->CreateDC(); SetStretchBltMode(dst,COLORONCOLOR); StretchBlt(dst,0,0,80,100,src,0,0,SimulationForm->image->Width,SimulationForm->image->Height,SRCCOPY); tag->DeleteDC(dst); SimulationForm->image->DeleteDC(src); tag->SaveToTexpiaFile(hFile, cmNone); //////////////////////////////////////////////////////////////////////////// SetFilePointer (hFile, 25000, NULL, FILE_BEGIN);//length of tag //24000+1000 maindata.SaveToFile(hFile); MetaDataForm->md.SaveToFile(hFile); texlayer->SaveToFile(hFile); Treatment_F->SaveToFile(hFile); GuideBar_F->gd.SaveToFile(hFile); SimulationForm->sd.SaveToFile(hFile); SimulationForm->SaveImage(hFile, ver, cm); DesignForm->SaveToFile(hFile); Cost_F->SaveToFile(hFile); CloseHandle(hFile); SimulationForm->ShowImage(); if(tag) delete tag; } catch(...){ ShowMessage(IDS_MESSAGE_SAVE_FAIL); } ShowMainData(); Undo->reset(); } //--------------------------------------------------------------------------- void __fastcall TMain::TRCRead(AnsiString FileName){ HANDLE hFile = INVALID_HANDLE_VALUE; DWORD dwRead; int ver; hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL); ReadFile(hFile, &ver, sizeof(int), &dwRead, NULL); if(ver>FILE_VERSION){ ShowMessage("version error"); CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE; return; } sbL1Click(NULL);//LayerNum=0;//¹ÙÀÇ °¹¼ö°¡ ÁÙ¾îµé¼ö ÀÖÀ¸¹Ç·Î ¹Ì¸® ¼±Åà ¹Ù¸¦ 0À¸·Î ÇÔ Cost_F->reset(); Undo->reset(); if(ver<100){ maindata.FileName=FileName; ReadFromOldFile(hFile, ver, true); } else { SetFilePointer (hFile, 25000, NULL, FILE_BEGIN);//length of tag //24000+1000 maindata.ReadFromFile(hFile); MetaDataForm->md.ReadFromFile(hFile); if(texlayer) delete texlayer; texlayer = new TexLayer;//°ø°£À» ÇÒ´çÇÑ´Ù texlayer->ReadFromFile(hFile, ver); texlayer->SetHeight(maindata.course); Treatment_F->ReadFromFile(hFile, ver); GuideBar_F->gd.ReadFromFile(hFile); SimulationForm->sd.ReadFromFile(hFile); SimulationForm->LoadImage(hFile, ver); if(ver>=101){ DesignForm->ReadFromFile(hFile); if(ver>=102){ Cost_F->ReadFromFile(hFile); } } } ShowAll(); SimulationForm->ShowImage(); CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE; } //--------------------------------------------------------------------------- void __fastcall TMain::ReadHeaderFromFile(AnsiString FileName, TTexpiaBitmap *tag, MainData *maindata){ HANDLE hFile = INVALID_HANDLE_VALUE; DWORD dwRead; int ver; hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL); ReadFile(hFile, &ver, sizeof(int), &dwRead, NULL); if(ver<100){ if(tag!=NULL){ tag->Create(80,100,24); ReadFromOldFile(hFile, ver, false); HDC dcSrc = SimulationForm->image->CreateDC(); HDC dcDst = tag->CreateDC(); SetStretchBltMode(dcDst, COLORONCOLOR); StretchBlt(dcDst, 0, 0, 80, 100, dcSrc, 0, 0, SimulationForm->image->Width, SimulationForm->image->Height, SRCCOPY); tag->DeleteDC(dcDst); SimulationForm->image->DeleteDC(dcSrc); } } else { if(tag!=NULL){ tag->Create(80,100,24); tag->LoadFromTexpiaFile(hFile, cmNone); } SetFilePointer (hFile, 25000, NULL, FILE_BEGIN);//length of tag //24000+1000 maindata->ReadFromFile(hFile); } CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE; } //--------------------------------------------------------------------------- void __fastcall TMain::ReadFromOldFile(HANDLE hFile, int ver, bool UpdateMainData){ DWORD dwRead; int bar; int course; int mlpi;//guage double mcpc;//cpc double mwidth;//width int slpi;//sd.gauge //¿©±â¼­ sd.width´Â slpi,mlpi,mwidth¿¡ ÀÇÇØ °áÁ¤µÊ //ÃÖ±Ù ÆÄÀÏ¿¡¼­´Â sd.gauge°¡ sd.width,maindata.gauge,maindata.width¿¡ ÀÇÇØ °áÁ¤µÊ double scpc;//sd.cpc TColor c;//sd.c int zoom;//sd.zoom; int rH;//sd.rH int rW;//sd.rW bool back;//sd.back int fuzz;//sd.fuzz try{ if(ver>=1){ ReadFile(hFile, &bar, sizeof(int), &dwRead, NULL); ReadFile(hFile, &course, sizeof(int), &dwRead, NULL); ReadFile(hFile, &slpi, sizeof(int), &dwRead, NULL); ReadFile(hFile, &scpc, sizeof(double), &dwRead, NULL); ReadFile(hFile, &rH, sizeof(int), &dwRead, NULL); ReadFile(hFile, &rW, sizeof(int), &dwRead, NULL); ReadFile(hFile, &back, sizeof(bool), &dwRead, NULL); ReadFile(hFile, &fuzz, sizeof(int), &dwRead, NULL); ReadFile(hFile, &mlpi, sizeof(int), &dwRead, NULL); ReadFile(hFile, &mcpc, sizeof(double), &dwRead, NULL); ReadFile(hFile, &mwidth, sizeof(double), &dwRead, NULL); ReadFile(hFile, &c, sizeof(TColor), &dwRead, NULL); ReadFile(hFile, &zoom, sizeof(int), &dwRead, NULL); } if(ver>=5){ MetaDataForm->md.ReadFromFile(hFile); } if(ver>=1){ if(UpdateMainData){ if(texlayer) delete texlayer; texlayer = new TexLayer;//°ø°£À» ÇÒ´çÇÑ´Ù texlayer->ReadFromFile(hFile, ver); texlayer->SetHeight(course); Treatment_F->ReadFromFile(hFile, ver); } else { TexLayer *temptexlayer = new TexLayer;//°ø°£À» ÇÒ´çÇÑ´Ù temptexlayer->ReadFromFile(hFile, ver); //temptexlayer->SetHeight(course); delete temptexlayer; SetFilePointer (hFile, sizeof(int)+4*sizeof(bool), NULL, FILE_CURRENT);//instead of treatment loading } SimulationForm->LoadImage(hFile, ver); } } catch(...){ ShowMessage(IDS_MESSAGE_LOAD_FAIL); } if(UpdateMainData){ // È­ÀÏÀÚ·á·ÎºÎÅÍ ¸ÞÀÎÆûÀÇ editµîÀ» ¾÷µ¥ÀÌÆ®ÇÑ´Ù maindata.bar=bar; maindata.course=course; maindata.gauge=mlpi; maindata.cpc=mcpc; maindata.width=mwidth; //maindata.FileName=""; maindata.ProductName=""; maindata.ProductCode=""; maindata.ProductDetail=""; SimulationForm->sd.reset(); SimulationForm->sd.gauge=slpi; SimulationForm->sd.width=mwidth*mlpi/slpi; SimulationForm->sd.cpc=scpc; SimulationForm->sd.c=c; SimulationForm->sd.zoom=zoom; SimulationForm->sd.sub_zoom=0; SimulationForm->sd.rH=rH; SimulationForm->sd.rW=rW; SimulationForm->sd.back=back; SimulationForm->sd.fuzz=fuzz; } } //--------------------------------------------------------------------------- void __fastcall TMain::sbTreatmentClick(TObject *Sender) { BEGIN_TEX; if(Treatment_F->WindowState==wsMinimized){ Treatment_F->WindowState=wsNormal; END_TEX; return; } if(Treatment_F->Visible) { Treatment_F->Visible=false; } else { //POINT p=gbMainMenu->ClientToScreen(TPoint(0,gbMainMenu->Top+gbMainMenu->Height)); //MoveWindow(Treatment_F->Handle,p.x,p.y,Treatment_F->Width,Treatment_F->Height,false); Treatment_F->Visible=true; Treatment_F->Show(); } END_TEX; } //--------------------------------------------------------------------------- void __fastcall TMain::mOpenSaveClick(TObject *Sender) { sbLoadSaveClick(NULL); } //--------------------------------------------------------------------------- void __fastcall TMain::mExitClick(TObject *Sender) { Close(); } //--------------------------------------------------------------------------- void __fastcall TMain::mAboutClick(TObject *Sender) { BEGIN_TEX; AboutBox->ShowModal(); END_TEX; } //--------------------------------------------------------------------------- void __fastcall TMain::TimerTimer(TObject *Sender) { splash->Close(); Timer->Enabled=false; } //--------------------------------------------------------------------------- void __fastcall TMain::mNewClick(TObject *Sender) { BEGIN_TEX; int rt = MessageDlg(IDS_SAVE_AND_EXIT, mtConfirmation, TMsgDlgButtons() << mbYes << mbNo << mbCancel,0);//ÀåÁø¸¸ : »õâ ¸Þ¼¼Áö if (rt==mrCancel){ END_TEX; return; } else if(rt==mrYes){ sbLoadSaveClick(NULL); } delete texlayer; texlayer=new TexLayer; maindata.reset();// ÃʱâÈ­ main_reset = true; LayerNum=maindata.bar-1; for(int i=0;iAddLayer(); } texlayer->SetHeight(maindata.course); UpdateBtn(); DesignForm->UpdateCheckBox(); DesignForm->DrawChart(false); SimulationForm->New(); GuideBar_F->gd.reset(); GuideBar_F->ShowData(); Treatment_F->Reset(); if(GuideBar_F&&GuideBar_F->Visible)GuideBar_F->Repaint(); if(YarnListForm&&YarnListForm->Visible)YarnListForm->Repaint(); if(YarnCompositionData_F&&YarnCompositionData_F->Visible)YarnCompositionData_F->Repaint(); if(Treatment_F&&Treatment_F->Visible)Treatment_F->Repaint(); MetaDataForm->md.reset(); MetaDataForm->ShowMetaData(); Cost_F->reset(); Cost_F->ShowData(); ShowMainData(); Undo->reset(); sbL1Click(NULL);//±×³É ù¹øÂ° ·¹ÀÌ¾î ¼±ÅÃµÈ »óÅ·Π½ÃÀÛÇÏ°Ô END_TEX; } //--------------------------------------------------------------------------- void __fastcall TMain::mPrintClick(TObject *Sender) { BEGIN_TEX; TPrinter *printer = Printer(); if (printer->Printers->Count == 0) { END_TEX; return; } if(HiddenPrintDataForm==NULL){ HiddenPrintDataForm = new THiddenPrintDataForm(this); } if(!PrintForm){ PrintForm = new TPrintForm((TComponent *)NULL); } //PrintForm->ShowModal(); PrintForm->Visible = true; END_TEX; } //--------------------------------------------------------------------------- void __fastcall TMain::mYarnClick(TObject *Sender) { BEGIN_TEX; YarnCompositionData_F->Show(); END_TEX; } //--------------------------------------------------------------------------- void __fastcall TMain::edMGaugeKeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ int i_edMGauge; // by maxleo21c(06.11.04) float f_edMCPC; if (!::TryStrToInt(Main->edMGauge->Text, i_edMGauge)) return; if (!::TryStrToFloat(Main->edMCPC->Text, f_edMCPC)) return; maindata.gauge=i_edMGauge; maindata.cpc=f_edMCPC; if (!SimulationForm->SetSimulationData()) return; // by maxleo21c (06.11.04) if(YarnCompositionData_F&&YarnCompositionData_F->Visible)YarnCompositionData_F->Repaint(); edMCPC->SetFocus(); } } //--------------------------------------------------------------------------- void __fastcall TMain::edMCPCKeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ int i_edMGauge; // by maxleo21c(06.11.04) float f_edMCPC; if (!::TryStrToInt(Main->edMGauge->Text, i_edMGauge)) return; if (!::TryStrToFloat(Main->edMCPC->Text, f_edMCPC)) return; maindata.gauge=i_edMGauge; maindata.cpc=f_edMCPC; //maindata.gauge=StrToInt(Main->edMGauge->Text); //maindata.cpc=StrToFloat(Main->edMCPC->Text); if(YarnCompositionData_F&&YarnCompositionData_F->Visible)YarnCompositionData_F->Repaint(); edMWidth->SetFocus(); } } //--------------------------------------------------------------------------- void __fastcall TMain::edMWidthKeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ if(edMWidth->Text=="") return; // double mw = StrToFloat(edMWidth->Text); float mw; if (!::TryStrToFloat(edMWidth->Text, mw)) return; // by maxleo21c (06.11.04) if(mw<1) { edMWidth->Text="1"; mw=1; } maindata.width = mw; if (!SimulationForm->SetSimulationData()) return; // by maxleo21c (06.11.04) if(YarnCompositionData_F&&YarnCompositionData_F->Visible)YarnCompositionData_F->Repaint(); } } //--------------------------------------------------------------------------- void __fastcall TMain::sbPrintClick(TObject *Sender) { mPrintClick(Sender); } //--------------------------------------------------------------------------- void __fastcall TMain::mReopenSubItemsClick(TObject *Sender) { if(((TMenuItem *)Sender)->Caption!="")TRCRead(((TMenuItem *)Sender)->Caption); } //--------------------------------------------------------------------------- void __fastcall TMain::mCaptureClick(TObject *Sender) { sbCaptureClick(NULL); } //--------------------------------------------------------------------------- void __fastcall TMain::mSimulationClick(TObject *Sender) { BEGIN_TEX; #ifndef NO_SIM_VERSION if(SimulationForm->WindowState==wsMinimized){ SimulationForm->WindowState=wsNormal; } else { SimulationForm->WindowState=wsMinimized; } #endif END_TEX; } //--------------------------------------------------------------------------- void __fastcall TMain::mDesignClick(TObject *Sender) { BEGIN_TEX; if(DesignForm->WindowState==wsMinimized){ DesignForm->WindowState=wsNormal; } else { DesignForm->WindowState=wsMinimized; } END_TEX; } //--------------------------------------------------------------------------- void __fastcall TMain::sbSimulationClick(TObject *Sender) { BEGIN_TEX; #ifndef NO_SIM_VERSION if(SimulationForm->WindowState==wsMinimized){ SimulationForm->WindowState=wsNormal; } else { SimulationForm->WindowState=wsMinimized; } #endif END_TEX; } //--------------------------------------------------------------------------- void __fastcall TMain::sbCaptureClick(TObject *Sender) { BEGIN_TEX; if(CaptureForm->WindowState==wsMinimized){ CaptureForm->WindowState=wsNormal; } else { CaptureForm->WindowState=wsMinimized; } TIniFile *IniFile = new TIniFile(BaseDir + "\\Main.ini"); if (IniFile) { IniFile->WriteBool("Capture", "Visible", CaptureForm->WindowState==wsNormal); delete IniFile; } CaptureForm->InitForm(); #ifndef NO_SIM_VERSION SimulationForm->InitForm(); #endif END_TEX; } //--------------------------------------------------------------------------- void __fastcall TMain::sbDesignClick(TObject *Sender) { BEGIN_TEX; if(DesignForm->WindowState==wsMinimized){ DesignForm->WindowState=wsNormal; } else { DesignForm->WindowState=wsMinimized; } END_TEX; } //--------------------------------------------------------------------------- void __fastcall TMain::mTreatmentClick(TObject *Sender) { sbTreatmentClick(NULL); } //--------------------------------------------------------------------------- void __fastcall TMain::sbL7Click(TObject *Sender) { if(maindata.barstop_draw=true; DesignForm->cbLayer1->Checked=false; DesignForm->cbLayer2->Checked=false; DesignForm->cbLayer3->Checked=false; DesignForm->cbLayer4->Checked=false; DesignForm->cbLayer5->Checked=false; DesignForm->cbLayer6->Checked=false; DesignForm->cbLayer7->Checked=true; DesignForm->stop_draw=false; sbLXClick(); EditorForm->pcLayer->ActivePage = EditorForm->tsL7; } //--------------------------------------------------------------------------- void __fastcall TMain::sbL6Click(TObject *Sender) { if(maindata.bar<6)return; LayerNum=5; DesignForm->stop_draw=true; DesignForm->cbLayer1->Checked=false; DesignForm->cbLayer2->Checked=false; DesignForm->cbLayer3->Checked=false; DesignForm->cbLayer4->Checked=false; DesignForm->cbLayer5->Checked=false; DesignForm->cbLayer6->Checked=true; DesignForm->cbLayer7->Checked=false; DesignForm->stop_draw=false; sbLXClick(); EditorForm->pcLayer->ActivePage = EditorForm->tsL6; } //--------------------------------------------------------------------------- void __fastcall TMain::sbL5Click(TObject *Sender) { if(maindata.bar<5)return; LayerNum=4; DesignForm->stop_draw=true; DesignForm->cbLayer1->Checked=false; DesignForm->cbLayer2->Checked=false; DesignForm->cbLayer3->Checked=false; DesignForm->cbLayer4->Checked=false; DesignForm->cbLayer5->Checked=true; DesignForm->cbLayer6->Checked=false; DesignForm->cbLayer7->Checked=false; DesignForm->stop_draw=false; sbLXClick(); EditorForm->pcLayer->ActivePage = EditorForm->tsL5; } //--------------------------------------------------------------------------- void __fastcall TMain::sbL4Click(TObject *Sender) { if(maindata.bar<4)return; LayerNum=3; DesignForm->stop_draw=true; DesignForm->cbLayer1->Checked=false; DesignForm->cbLayer2->Checked=false; DesignForm->cbLayer3->Checked=false; DesignForm->cbLayer4->Checked=true; DesignForm->cbLayer5->Checked=false; DesignForm->cbLayer6->Checked=false; DesignForm->cbLayer7->Checked=false; DesignForm->stop_draw=false; sbLXClick(); EditorForm->pcLayer->ActivePage = EditorForm->tsL4; } //--------------------------------------------------------------------------- void __fastcall TMain::sbL3Click(TObject *Sender) { if(maindata.bar<3)return; LayerNum=2; DesignForm->stop_draw=true; DesignForm->cbLayer1->Checked=false; DesignForm->cbLayer2->Checked=false; DesignForm->cbLayer3->Checked=true; DesignForm->cbLayer4->Checked=false; DesignForm->cbLayer5->Checked=false; DesignForm->cbLayer6->Checked=false; DesignForm->cbLayer7->Checked=false; DesignForm->stop_draw=false; sbLXClick(); EditorForm->pcLayer->ActivePage = EditorForm->tsL3; } //--------------------------------------------------------------------------- void __fastcall TMain::sbL2Click(TObject *Sender) { if(maindata.bar<2)return; LayerNum=1; DesignForm->stop_draw=true; DesignForm->cbLayer1->Checked=false; DesignForm->cbLayer2->Checked=true; DesignForm->cbLayer3->Checked=false; DesignForm->cbLayer4->Checked=false; DesignForm->cbLayer5->Checked=false; DesignForm->cbLayer6->Checked=false; DesignForm->cbLayer7->Checked=false; DesignForm->stop_draw=false; sbLXClick(); EditorForm->pcLayer->ActivePage = EditorForm->tsL2; } //--------------------------------------------------------------------------- void __fastcall TMain::sbL1Click(TObject *Sender) { if(maindata.bar<1)return; LayerNum=0; DesignForm->stop_draw=true; DesignForm->cbLayer1->Checked=true; DesignForm->cbLayer2->Checked=false; DesignForm->cbLayer3->Checked=false; DesignForm->cbLayer4->Checked=false; DesignForm->cbLayer5->Checked=false; DesignForm->cbLayer6->Checked=false; DesignForm->cbLayer7->Checked=false; DesignForm->stop_draw=false; sbLXClick(); EditorForm->pcLayer->ActivePage = EditorForm->tsL1; } //--------------------------------------------------------------------------- void __fastcall TMain::sbLXClick() { BEGIN_TEX; DesignForm->UpdateCheckBox(); DesignForm->UpdateMenu(); DesignForm->UpdateEdit(); DesignForm->DrawChart(false); if(GuideBar_F&&GuideBar_F->Visible)GuideBar_F->Repaint(); if(EditorForm&&EditorForm->Visible)EditorForm->Init(); if(main_reset) { EditorForm->initMode3(); main_reset = false; } //if(CaptureForm->Visible) CaptureForm->UpdatePath(); if(Treatment_F->Visible)Treatment_F->Repaint(); GuideBar_F->UpdateGuideBar(); END_TEX; } //--------------------------------------------------------------------------- void __fastcall TMain::UpdateBtn(){ //¹öưÀ» ¾÷µ¥ÀÌÆ®ÇÑ´Ù if (Main->LayerMode) { switch(maindata.bar){ case 1: cbB1->Enabled=true; cbB2->Enabled=false; cbB3->Enabled=false; cbB4->Enabled=false; cbB5->Enabled=false; cbB6->Enabled=false; cbB7->Enabled=false; break; case 2: cbB1->Enabled=true; cbB2->Enabled=true; cbB3->Enabled=false; cbB4->Enabled=false; cbB5->Enabled=false; cbB6->Enabled=false; cbB7->Enabled=false; break; case 3: cbB1->Enabled=true; cbB2->Enabled=true; cbB3->Enabled=true; cbB4->Enabled=false; cbB5->Enabled=false; cbB6->Enabled=false; cbB7->Enabled=false; break; case 4: cbB1->Enabled=true; cbB2->Enabled=true; cbB3->Enabled=true; cbB4->Enabled=true; cbB5->Enabled=false; cbB6->Enabled=false; cbB7->Enabled=false; break; case 5: cbB1->Enabled=true; cbB2->Enabled=true; cbB3->Enabled=true; cbB4->Enabled=true; cbB5->Enabled=true; cbB6->Enabled=false; cbB7->Enabled=false; break; case 6: cbB1->Enabled=true; cbB2->Enabled=true; cbB3->Enabled=true; cbB4->Enabled=true; cbB5->Enabled=true; cbB6->Enabled=true; cbB7->Enabled=false; break; case MAX_LAYER_COUNT: cbB1->Enabled=true; cbB2->Enabled=true; cbB3->Enabled=true; cbB4->Enabled=true; cbB5->Enabled=true; cbB6->Enabled=true; cbB7->Enabled=true; break; } bool layer_changed = false;//gabriel 2006.04.24 if(maindata.bar<=LayerNum) { LayerNum=maindata.bar-1; layer_changed = true; } switch(LayerNum){ case 0: cbB1->Down=true; break; case 1: cbB2->Down=true; break; case 2: cbB3->Down=true; break; case 3: cbB4->Down=true; break; case 4: cbB5->Down=true; break; case 5: cbB6->Down=true; break; case MAX_LAYER_COUNT-1: cbB7->Down=true; break; } } else { switch(maindata.bar){ case 1: sbL1->Enabled=true; sbL2->Enabled=false; sbL3->Enabled=false; sbL4->Enabled=false; sbL5->Enabled=false; sbL6->Enabled=false; sbL7->Enabled=false; break; case 2: sbL1->Enabled=true; sbL2->Enabled=true; sbL3->Enabled=false; sbL4->Enabled=false; sbL5->Enabled=false; sbL6->Enabled=false; sbL7->Enabled=false; break; case 3: sbL1->Enabled=true; sbL2->Enabled=true; sbL3->Enabled=true; sbL4->Enabled=false; sbL5->Enabled=false; sbL6->Enabled=false; sbL7->Enabled=false; break; case 4: sbL1->Enabled=true; sbL2->Enabled=true; sbL3->Enabled=true; sbL4->Enabled=true; sbL5->Enabled=false; sbL6->Enabled=false; sbL7->Enabled=false; break; case 5: sbL1->Enabled=true; sbL2->Enabled=true; sbL3->Enabled=true; sbL4->Enabled=true; sbL5->Enabled=true; sbL6->Enabled=false; sbL7->Enabled=false; break; case 6: sbL1->Enabled=true; sbL2->Enabled=true; sbL3->Enabled=true; sbL4->Enabled=true; sbL5->Enabled=true; sbL6->Enabled=true; sbL7->Enabled=false; break; case MAX_LAYER_COUNT: sbL1->Enabled=true; sbL2->Enabled=true; sbL3->Enabled=true; sbL4->Enabled=true; sbL5->Enabled=true; sbL6->Enabled=true; sbL7->Enabled=true; break; } bool layer_changed = false;//gabriel 2006.04.24 if(maindata.bar<=LayerNum) { LayerNum=maindata.bar-1; layer_changed = true; } switch(LayerNum){ case 0: sbL1->Down=true; break; case 1: sbL2->Down=true; break; case 2: sbL3->Down=true; break; case 3: sbL4->Down=true; break; case 4: sbL5->Down=true; break; case 5: sbL6->Down=true; break; case MAX_LAYER_COUNT-1: sbL7->Down=true; break; } } DesignForm->UpdateCheckBox(); DesignForm->UpdateMenu(); } //--------------------------------------------------------------------------- void __fastcall TMain::mInOutClick(TObject *Sender) { sbGuideBarClick(NULL); } //--------------------------------------------------------------------------- void __fastcall TMain::mPropertyClick(TObject *Sender) { BEGIN_TEX; MetaDataForm->Show(); END_TEX; } //--------------------------------------------------------------------------- void __fastcall TMain::ShowMainData(){ edBar->Text=IntToStr(maindata.bar); edCourse->Text=IntToStr(maindata.course); edMGauge->Text=IntToStr(maindata.gauge); edMCPC->Text=MyFloatToStr(maindata.cpc,2); edMWidth->Text=MyFloatToStr(maindata.width,2); MenuStatusBar->Panels->Items[0]->Text=ExtractFileName(maindata.FileName); ////////////////////////////////////////////////////reopen data mReopen->Enabled=true; if(maindata.FileName!=""){ TMenuItem *item = new TMenuItem(NULL); item->Caption=maindata.FileName; item->OnClick=mReopenSubItemsClick; mReopen->Insert(0,item); } for(int i=1;iCount;i++){ if(mReopen->Items[i]->Caption==maindata.FileName){ delete (TMenuItem *)mReopen->Items[i]; //mReopen->Delete(i); break;// °°Àº À̸§Àº Çϳª ÀÌÇÏÀÌ´Ù } } while(mReopen->Count>10){ delete mReopen->Items[mReopen->Count-1]; //mReopen->Delete(mReopen->Count-1); } TRegIniFile *RegIniFile = NULL; AnsiString s; RegIniFile = new TRegIniFile(RegFilename); RegIniFile->RootKey = HKEY_LOCAL_MACHINE; RegIniFile->OpenKey(RegFilename + "\\",true); // yw if (RegIniFile) { for(int i=0;i<10;i++){ if(mReopen->Count>i){ RegIniFile->WriteString("Recent Files", IntToStr(i), mReopen->Items[i]->Caption); } else { RegIniFile->WriteString("Recent Files", IntToStr(i), ""); } } delete RegIniFile; } ////////////////////////////////////////////////////reopen data } //--------------------------------------------------------------------------- void __fastcall TMain::SetAll(){//Æû¿¡ ÀÖ´Â ¸ðµç ÇÊ¿äÇÑ µ¥ÀÌÅ͸¦ ±¸ÇÏ¿© ÇØ´çÇÏ´Â º¯¼ö¿¡ ÀԷ½ÃŲ´Ù //SimulationForm->SetSimulationData();//Edit¿¡¼­ ¿£Å͸¦ Ä¡Áö ¾ÊÀ¸¸é ¼¼ÀÌºê µÇÁö ¾Êµµ·Ï ¸·À½ MetaDataForm->SetMetaData(); YarnCompositionData_F->SetYarnUseList();// º¯°æµÈ meta data¿¡ µû¶ó mm/Rack¸¦ °è»ê } //--------------------------------------------------------------------------- void __fastcall TMain::ShowAll(){ ShowMainData(); SimulationForm->ShowSimulationData(); MetaDataForm->ShowMetaData(); DesignForm->DrawChart(true); DesignForm->UpdateCheckBox(); DesignForm->UpdateMenu(); DesignForm->UpdateEdit(); GuideBar_F->ShowData(); GuideBar_F->UpdateGuideBar(); if(GuideBar_F->Visible)GuideBar_F->Repaint(); if(YarnCompositionData_F&&YarnCompositionData_F->Visible)YarnCompositionData_F->Repaint(); if(Treatment_F->Visible)Treatment_F->Repaint(); Cost_F->ShowData(); UpdateBtn(); } //--------------------------------------------------------------------------- void __fastcall TMain::ShowAllExceptChart(){ ShowMainData(); SimulationForm->ShowSimulationData(); MetaDataForm->ShowMetaData(); DesignForm->UpdateCheckBox(); if(GuideBar_F->Visible)GuideBar_F->Repaint(); if(YarnCompositionData_F&&YarnCompositionData_F->Visible)YarnCompositionData_F->Repaint(); if(Treatment_F->Visible)Treatment_F->Repaint(); UpdateBtn(); } //--------------------------------------------------------------------------- void __fastcall TMain::sbViewYarnListClick(TObject *Sender) { YarnListForm->Show(); } //--------------------------------------------------------------------------- void __fastcall TMain::mYarnListClick(TObject *Sender) { BEGIN_TEX; if(YarnListForm->WindowState==wsMinimized){ YarnListForm->WindowState=wsNormal; END_TEX; return; } // if(YarnListForm->Visible)YarnListForm->Visible=false; // else YarnListForm->Visible=true; if(YarnListForm->Visible) { YarnListForm->Visible=false; //if (YarnTableForm && YarnTableForm->Visible==true) YarnListForm->sbYarnTableClick(NULL); } else { YarnListForm->Visible=true; //if (!YarnTableForm || YarnTableForm->Visible==false) YarnListForm->sbYarnTableClick(NULL); } //gabriel: YarnList, YarnMaker´Â µ¿½Ã¿¡ º¸ÀÌÁö ¾ÊÀ½ //if (mYarnList->Checked) DestroyYarnForms(); END_TEX; } //--------------------------------------------------------------------------- void __fastcall TMain::mWindowClick(TObject *Sender) { mSimulation->Checked=(SimulationForm->WindowState==wsNormal); mDesign->Checked=(DesignForm->WindowState==wsNormal); mInOut->Checked=GuideBar_F->Visible; mYarnList->Checked=YarnListForm->Visible; mTreatment->Checked=Treatment_F->Visible; mCapture->Checked=(CaptureForm->WindowState==wsNormal); //gabriel //if (mYarnList->Checked) DestroyYarnForms(); // tricot ¹æ½Ä °ÑÀ¸·Î µû¶óÇϱâ À§ÇØ (½ÇÁ¦·Î µ¿Àû»ý¼º) if (YarnDesignForm && (YarnDesignForm->Visible == false)) { //alt + F4 case DestroyYarnForms(); } mYarnMaker->Checked=(YarnDesignForm)? true:false;// if form initialized } //--------------------------------------------------------------------------- void __fastcall TMain::FormCloseQuery(TObject *Sender, bool &CanClose) { int rt = MessageDlg(IDS_SAVE_AND_EXIT, mtConfirmation, TMsgDlgButtons() << mbYes << mbNo << mbCancel,0); if (rt==mrCancel){ CanClose = false; } else if(rt==mrYes){ sbLoadSaveClick(NULL); } else if(rt==mrNo){ } } //--------------------------------------------------------------------------- void __fastcall TMain::UpdateForms(){ Update(); CaptureForm->Update(); SimulationForm->Update(); DesignForm->Update(); GuideBar_F->Update(); YarnListForm->Update(); Treatment_F->Update(); YarnCompositionData_F->Update(); } //--------------------------------------------------------------------------- void __fastcall TMain::mEnvironmentClick(TObject *Sender) { BEGIN_TEX; Environment->Show(); END_TEX; } //--------------------------------------------------------------------------- void __fastcall TMain::mCostClick(TObject *Sender) { BEGIN_TEX; Cost_F->Show(); END_TEX; } //--------------------------------------------------------------------------- void __fastcall MainData::reset(){ FileName=""; ProductName=""; ProductCode=""; ProductDetail=""; TIniFile *IniFile = new TIniFile(BaseDir + "\\Environment.ini"); if (IniFile) { bar = IniFile->ReadInteger("Main", "Bar", 2); //ÀåÁø¸¸ : ¼³Á¤ ·Îµå course = IniFile->ReadInteger("Main", "Course", 16); gauge = IniFile->ReadInteger("Main", "Gauge", 28); cpc = IniFile->ReadInteger("Main", "Cpc", 20); width = IniFile->ReadInteger("Main", "Width", 105); delete IniFile; } } //--------------------------------------------------------------------------- void __fastcall TMain::mYarnMakerClick(TObject *Sender) { //gabriel BEGIN_TEX; /* À̹æ½ÄÀº tricot¹æ½Ä if(DesignForm->WindowState==wsMinimized){ DesignForm->WindowState=wsNormal; } else { DesignForm->WindowState=wsMinimized; } */ //YarnListForm->Hide();//YarnList, YarnMaker´Â µ¿½Ã¿¡ º¸ÀÌÁö ¾ÊÀ½ DestroyYarnForms(); if (mYarnMaker->Checked == false) { // YarnTableForm = new TYarnTableForm(this); // YarnTableForm->Parent = this; YarnTableForm->Visible = false; // YarnTableForm->InitForm(false); YarnDesignForm = new TYarnDesignForm(this); YarnDesignForm->Parent = this; YarnDesignForm->Visible = true; YarnDesignForm->MakeButton->SetFocus(); //lhskys ¿£ÅÍ·Î ½ÇÇàÇϱâÀ§ÇØ! } PaletteForm->Visible=true; PaletteForm->InitForm(PaletteForm->Palette);//visible »óÅ¿¡¼­ ÃʱâÈ­ÇØ¾ß ½ºÅ©·Ñ¹Ù°¡ ¿òÁ÷¿©Áø´Ù PaletteForm->Visible=false; END_TEX; } //--------------------------------------------------------------------------- void __fastcall TMain::DestroyYarnForms() //gabriel { // if (YarnTableForm) //::doDestroy(YarnTableForm); //À̰÷¿¡¼­ YarnTableFormÀ» Áö¿ö ¹ö·Á¼­ ÁÖ¼®À¸·Î ó¸® by maxleo21c(06.11.22) ::doDestroy(YarnDesignForm); } //--------------------------------------------------------------------------- void __fastcall TMain::cbB1Click(TObject *Sender) { if(maindata.bar<1)return; LayerNum = maindata.bar-1; DesignForm->stop_draw=true; DesignForm->cbBar1->Checked=true; DesignForm->cbBar2->Checked=false; DesignForm->cbBar3->Checked=false; DesignForm->cbBar4->Checked=false; DesignForm->cbBar5->Checked=false; DesignForm->cbBar6->Checked=false; DesignForm->cbBar7->Checked=false; DesignForm->stop_draw=false; sbLXClick(); //SelectEditorPage(LayerNum); SelectEditorPage(cbB1->TabOrder); } //--------------------------------------------------------------------------- void __fastcall TMain::cbB2Click(TObject *Sender) { if(maindata.bar<2)return; LayerNum = maindata.bar-2; DesignForm->stop_draw=true; DesignForm->cbBar1->Checked=false; DesignForm->cbBar2->Checked=true; DesignForm->cbBar3->Checked=false; DesignForm->cbBar4->Checked=false; DesignForm->cbBar5->Checked=false; DesignForm->cbBar6->Checked=false; DesignForm->cbBar7->Checked=false; DesignForm->stop_draw=false; sbLXClick(); //SelectEditorPage(LayerNum); SelectEditorPage(cbB2->TabOrder); } //--------------------------------------------------------------------------- void __fastcall TMain::cbB3Click(TObject *Sender) { if(maindata.bar<3)return; LayerNum = maindata.bar-3; DesignForm->stop_draw=true; DesignForm->cbBar1->Checked=false; DesignForm->cbBar2->Checked=false; DesignForm->cbBar3->Checked=true; DesignForm->cbBar4->Checked=false; DesignForm->cbBar5->Checked=false; DesignForm->cbBar6->Checked=false; DesignForm->cbBar7->Checked=false; DesignForm->stop_draw=false; sbLXClick(); //SelectEditorPage(LayerNum); SelectEditorPage(cbB3->TabOrder); } //--------------------------------------------------------------------------- void __fastcall TMain::cbB4Click(TObject *Sender) { if(maindata.bar<4)return; LayerNum = maindata.bar-4; DesignForm->stop_draw=true; DesignForm->cbBar1->Checked=false; DesignForm->cbBar2->Checked=false; DesignForm->cbBar3->Checked=false; DesignForm->cbBar4->Checked=true; DesignForm->cbBar5->Checked=false; DesignForm->cbBar6->Checked=false; DesignForm->cbBar7->Checked=false; DesignForm->stop_draw=false; sbLXClick(); //SelectEditorPage(LayerNum); SelectEditorPage(cbB4->TabOrder); } //--------------------------------------------------------------------------- void __fastcall TMain::cbB5Click(TObject *Sender) { if(maindata.bar<5)return; LayerNum = maindata.bar-5; DesignForm->stop_draw=true; DesignForm->cbBar1->Checked=false; DesignForm->cbBar2->Checked=false; DesignForm->cbBar3->Checked=false; DesignForm->cbBar4->Checked=false; DesignForm->cbBar5->Checked=true; DesignForm->cbBar6->Checked=false; DesignForm->cbBar7->Checked=false; DesignForm->stop_draw=false; sbLXClick(); //SelectEditorPage(LayerNum); SelectEditorPage(cbB5->TabOrder); } //--------------------------------------------------------------------------- void __fastcall TMain::cbB6Click(TObject *Sender) { if(maindata.bar<6)return; LayerNum=maindata.bar-6; DesignForm->stop_draw=true; DesignForm->cbBar1->Checked=false; DesignForm->cbBar2->Checked=false; DesignForm->cbBar3->Checked=false; DesignForm->cbBar4->Checked=false; DesignForm->cbBar5->Checked=false; DesignForm->cbBar6->Checked=true; DesignForm->cbBar7->Checked=false; DesignForm->stop_draw=false; sbLXClick(); //SelectEditorPage(LayerNum); SelectEditorPage(cbB6->TabOrder); } //--------------------------------------------------------------------------- void __fastcall TMain::cbB7Click(TObject *Sender) { if(maindata.barstop_draw=true; DesignForm->cbBar1->Checked=false; DesignForm->cbBar2->Checked=false; DesignForm->cbBar3->Checked=false; DesignForm->cbBar4->Checked=false; DesignForm->cbBar5->Checked=false; DesignForm->cbBar6->Checked=false; DesignForm->cbBar7->Checked=true; DesignForm->stop_draw=false; sbLXClick(); //SelectEditorPage(LayerNum); SelectEditorPage(cbB7->TabOrder); } //--------------------------------------------------------------------------- void __fastcall TMain::SelectEditorPage(int index) { switch(index) { case 0: EditorForm->pcLayer->ActivePage = EditorForm->tsL1; break; case 1: EditorForm->pcLayer->ActivePage = EditorForm->tsL2; break; case 2: EditorForm->pcLayer->ActivePage = EditorForm->tsL3; break; case 3: EditorForm->pcLayer->ActivePage = EditorForm->tsL4; break; case 4: EditorForm->pcLayer->ActivePage = EditorForm->tsL5; break; case 5: EditorForm->pcLayer->ActivePage = EditorForm->tsL6; break; case 6: EditorForm->pcLayer->ActivePage = EditorForm->tsL7; break; } } //--------------------------------------------------------------------------- void __fastcall TMain::CheckTimerTimer(TObject *Sender) { #ifdef LOCK_TEX CheckReverseEngineeringTools(); #endif } //--------------------------------------------------------------------------- void __fastcall TMain::TimerHASPSRMTimer(TObject *Sender) { #ifdef HASPSRM if (ProtectCard->IsHacking) { TimerHASPSRM->Enabled = false; ShowMessage(IDS_MESSAGE_INTERFACE); Application->Terminate(); } #endif } //--------------------------------------------------------------------------- void __fastcall TMain::SaveTRC(AnsiString name, AnsiString SavePath) { TFMSaveEvent OnSave; AnsiString strTrcCheckErrorMessage; strTrcCheckErrorMessage = "The" + name + ".trc file does not exist in the upload folder."; if(::GetFileAttributes(SavePath.c_str())) { MessageBox(NULL,strTrcCheckErrorMessage.c_str(),"Warning", MB_OK); return; } } void __fastcall TMain::SaveXML(AnsiString name, AnsiString SavePath) { TXMLDocument *xmlDocument = new TXMLDocument(""); xmlDocument->Active = true; xmlDocument->Encoding = "UTF-8"; xmlDocument->Version = "1.0"; xmlDocument->FileName = name + ".xml"; _di_IXMLNode project = xmlDocument->AddChild("project"); project->SetAttribute(WideString("name"),name); project->SetAttribute(WideString("code"),maindata.ProductCode); ////////////////////////////////////////////////////// // ¾î¶² Data °¡ ¾îµð·Î µé¾î°¡´ÂÁö º¸±â ½±°Ô ÇÏ·Á°í // º¯¼ö ¸¹ÀÌ ¸¸µé¾î ³õ¾Ò´Âµ¥ º¯¼öÀÇ È¿À²¼ºÀº ¶³¾îÁü str Çϳª¸¸ Àâ¾Æµµ µÇ´Ï // Ȥ½Ã¶óµµ º¯°æ ÇÏ½Ç »ý°¢ÀÌ ÀÖ´Ù¸é º¯°æÇصµ ¹«¹æ ////////////////////////////////////////////////////// AnsiString str = ""; AnsiString strLayer = ""; AnsiString strYarnIdx = ""; AnsiString strYarnMaker = ""; AnsiString strYarnSpec = ""; AnsiString strYarnCode = ""; AnsiString strYarnColor = ""; AnsiString strPantoneColor = ""; AnsiString strLabColor = ""; AnsiString strPercent = ""; AnsiString strmmRACK = ""; AnsiString strUse = ""; AnsiString strBeam = ""; AnsiString strTotal = ""; AnsiString strChain = ""; AnsiString strRowWpi = ""; AnsiString strRowCpi = ""; AnsiString strRowWidth = ""; AnsiString strRowWeight = ""; AnsiString strSimWpi = ""; AnsiString strSimCpi = ""; AnsiString strSimWidth = ""; AnsiString strSimWeight = ""; AnsiString strQuota = ""; AnsiString strMachine = ""; AnsiString strArray = ""; AnsiString strMagnificationRatio = ""; YarnUse *yu; Yarn *yarn; /* InOut data ¸¸µé±â */ AnsiString InOut[MAX_LAYER_COUNT]={"FULL","FULL","FULL","FULL","FULL","FULL","FULL"}; for(int l=0;lmaindata.bar;l++){ if(GuideBar_F->gd.iodescription[l]!=""){ InOut[l]=GuideBar_F->gd.iodescription[l]; continue; } AnsiString str; Tex *tex = ((Tex *)Main->texlayer->TexList->Items[l]); for(int i=0;iWales->Count;i++){ WaleState *ws = (WaleState *)tex->Wales->Items[i]; if(ws->in){ str+=IntToStr(ws->cnt)+AnsiString((char)('A'+ws->yarnIndex))+" "; } else { str+=IntToStr(ws->cnt)+"X "; } } if(tex->Wales->Count==1)str="FULL"; if(str!="")InOut[l]=str; InOut[l] = InOut[l] + " START=" + IntToStr(tex->leftShift); } // project -> layers _di_IXMLNode layerList = project->AddChild("layers"); for(int i=0; i < maindata.bar ;i++) { str = ""; yu = (YarnUse *)Main->texlayer->YarnUseList->Items[i]; yarn = (Yarn *)Main->texlayer->YarnList->Items[yu->yarnIndex]; ////////////////////////////////////////////////////////////// // Get Value ////////////////////////////////////////////////////////////// // Layer // //# sjpark - Layer name ¸ÂÁö ¾Ê´Â Çö»ó //strLayer = "L"+IntToStr(yu->layer_num+1); strLayer = "L"+IntToStr(i+1); strYarnIdx = AnsiString((char)('A'+yu->yarnIndex)); strYarnMaker = yarn->lot; if(yarn->name[0] == NULL) { YarnCompositionData_F->AddYMToStr(strYarnSpec,yarn->ym,yarn->ymDirect); strYarnSpec+=IntToStr((int)yarn->denier); strYarnSpec+="/"; strYarnSpec+=IntToStr(yarn->filament); strYarnSpec+=" "; YarnCompositionData_F->AddYPToStr(strYarnSpec,yarn->yp,yarn->ypDirect); } else{ strYarnSpec = yarn->name; } strYarnCode= yarn->code; //strYarnColor= TColorToRGB(yarn->color); /* rgb_color ¸¸µé±â */ RGBQUAD rgb = TColorToRGB(yarn->color); strYarnColor=IntToStr(rgb.rgbRed)+","+IntToStr(rgb.rgbGreen)+","+IntToStr(rgb.rgbBlue); /* pantone_color ¸¸µé±â */ TColor temp_color; //±×³É ÇÔ¼ö ¾²·Á°í ¸¸µë if (DTPColorLibraryForm) DTPColorLibraryForm->FindNearestColor(rgb, temp_color, strPantoneColor); /* lab_color ¸¸µé±â */ strLabColor = RGBtoLAB(rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue); /* ¹èÀ² ¸¸µé±â */ strMagnificationRatio = IntToStr(SimulationForm->sd.zoom) + "." + IntToStr(SimulationForm->sd.sub_zoom); strPercent = MyFloatToStr(yu->percent,2); strmmRACK = IntToStr(yu->mmPerRACK); strUse = IntToStr(yu->use); strBeam = IntToStr(yu->beam); strTotal = IntToStr(yu->total_use); // Chain Link Data Tex *tex = ((Tex *)Main->texlayer->TexList->Items[i]); if(tex->Curve->Count%2||tex->Curve->Count<3){ //Ȧ¼öÀ̸é ÀüºÎ Ç¥Çö for(int j=0;jCurve->Count;j++){ KO *ko = (KO *)tex->Curve->Items[j]; if( 1 /*PrintForm->rgChain->ItemIndex==0*/){ // print form ÀÌ null °ªÀÌ ¶ó¼­ ÀÏ´Ü printform->rgchain ÀÇ index °¡ 0 ÀÎ °æ¿ì¸¸À¸·Î ÀÏ´Ü ÇÑÁ¤Çß´Ù. str+=IntToStr(ko->in)+","+IntToStr(ko->via)+" / "; } else { str+=IntToStr(ko->in)+","+IntToStr(ko->via)+","+IntToStr(ko->out)+" / "; } } } else { // ¦¼öÀ̸é Áߺ¹ üũ // bool repeat=true; KO *ko01 = (KO *)tex->Curve->Items[0]; KO *ko02 = (KO *)tex->Curve->Items[1]; for(int j=0;jCurve->Count/2;j++){ KO *ko1 = (KO *)tex->Curve->Items[2*j]; KO *ko2 = (KO *)tex->Curve->Items[2*j+1]; if(ko01->in!=ko1->in||ko01->via!=ko1->via|| ko02->in!=ko2->in||ko02->via!=ko2->via) { repeat=false; break; } } if(repeat){ KO *ko1 = (KO *)tex->Curve->Items[0]; KO *ko2 = (KO *)tex->Curve->Items[1]; /* if(PrintForm->rgChain->ItemIndex==0){ str+=IntToStr(ko1->in)+IntToStr(ko1->via)+" "+IntToStr(ko2->in)+IntToStr(ko2->via)+" "; } else { str+=IntToStr(ko1->in)+IntToStr(ko1->via)+IntToStr(ko1->out)+" "+ IntToStr(ko2->in)+IntToStr(ko2->via)+IntToStr(ko2->out)+" "; } */ str+=IntToStr(ko1->in)+","+IntToStr(ko1->via)+" / "+IntToStr(ko2->in)+","+IntToStr(ko2->via)+" / "; } else { for(int j=0;jCurve->Count;j++){ KO *ko = (KO *)tex->Curve->Items[j]; /* if(PrintForm->rgChain->ItemIndex==0){ str+=IntToStr(ko->in)+IntToStr(ko->via)+" "; } else { str+=IntToStr(ko->in)+IntToStr(ko->via)+IntToStr(ko->out)+" "; } */ str+=IntToStr(ko->in)+","+IntToStr(ko->via)+" / "; } } } strChain = str +" = "+IntToStr(Main->maindata.course)+" COS"; strArray = IntToStr(tex->leftShift); strRowWpi = IntToStr(Main->maindata.gauge); strSimWpi = MyFloatToStr(SimulationForm->sd.gauge,2); strRowCpi = MyFloatToStr(Main->maindata.cpc,2); strSimCpi = MyFloatToStr(SimulationForm->sd.cpc,2); strRowWidth = MyFloatToStr(Main->maindata.width,2); strSimWidth = MyFloatToStr(SimulationForm->sd.width,2); char buf[256]; Extended value; double gpy=0; for(int i=0;itexlayer->YarnUseList->Count;i++){ gpy+=yu->GPY; } memset(buf,0,256); value=gpy; value/=MetaDataForm->md.count_of_w; FloatToText(buf, &value, fvExtended, ffNumber, 8, 1); strRowWeight = AnsiString(buf); memset(buf,0,256); value=gpy/Main->maindata.cpc*SimulationForm->sd.cpc; value/=MetaDataForm->md.count_of_w; FloatToText(buf, &value, fvExtended, ffNumber, 8, 1); strSimWeight = AnsiString(buf); strQuota = IntToStr(MetaDataForm->md.rpm)+" X "+ MyFloatToStr(MetaDataForm->md.hours,2)+"h X 60 X " +MyFloatToStr(MetaDataForm->md.efficiency/100.0,2)+" / "+ MyFloatToStr(Main->maindata.cpc,2)+" / 91.44 X "+IntToStr(MetaDataForm->md.count_of_w)+" = "+ MyFloatToStr(MetaDataForm->md.rpm*MetaDataForm->md.hours*60.0*(MetaDataForm->md.efficiency/100.0)/ maindata.cpc/91.44*MetaDataForm->md.count_of_w,2); strMachine = MetaDataForm->md.machineName; ////////////////////////////////////////////////////////////// // Set Value ////////////////////////////////////////////////////////////// // Layer _di_IXMLNode layer = layerList->AddChild("layer"); layer->SetAttribute(WideString("name"),strLayer); _di_IXMLNode yarn = layer->AddChild("yarn"); _di_IXMLNode idx = yarn->AddChild("idx"); idx->SetAttribute(WideString("value"),strYarnIdx); _di_IXMLNode maker = yarn->AddChild("maker"); maker->SetAttribute(WideString("value"),strYarnMaker); _di_IXMLNode spec = yarn->AddChild("spec"); spec->SetAttribute(WideString("value"),strYarnSpec); _di_IXMLNode code = yarn->AddChild("code"); code->SetAttribute(WideString("value"),strYarnCode); _di_IXMLNode rgb_color = yarn->AddChild("rgb_color"); rgb_color->SetAttribute(WideString("value"),strYarnColor); _di_IXMLNode lab_color = yarn->AddChild("lab_color"); lab_color->SetAttribute(WideString("value"),strLabColor); _di_IXMLNode pantone_color = yarn->AddChild("pantone_color"); pantone_color->SetAttribute(WideString("value"),strPantoneColor); _di_IXMLNode ratio = layer->AddChild("ratio"); ratio->SetAttribute(WideString("value"),strPercent); _di_IXMLNode mmrack = layer->AddChild("mmrack"); mmrack->SetAttribute(WideString("value"),strmmRACK); _di_IXMLNode use = layer->AddChild("use"); use->SetAttribute(WideString("value"),strUse); _di_IXMLNode beam = layer->AddChild("beam"); beam->SetAttribute(WideString("value"),strBeam); _di_IXMLNode total = layer->AddChild("total"); total->SetAttribute(WideString("value"),strTotal); _di_IXMLNode chainlink = layer->AddChild("chainlink"); _di_IXMLNode course = chainlink->AddChild("course"); course->SetAttribute(WideString("value"),strChain); _di_IXMLNode array = layer->AddChild("array"); array->SetAttribute(WideString("value"),strArray); _di_IXMLNode InOut_Data = layer->AddChild("inout"); InOut_Data->SetAttribute(WideString("value"),InOut[i]); } // project -> production _di_IXMLNode production = project->AddChild("production"); _di_IXMLNode row = production->AddChild("row"); _di_IXMLNode wpi_r = row->AddChild("wpi"); wpi_r->SetAttribute(WideString("value"),strRowWpi); _di_IXMLNode cpi_r = row->AddChild("cpi"); cpi_r->SetAttribute(WideString("value"),strRowCpi); _di_IXMLNode width_r = row->AddChild("width"); width_r->SetAttribute(WideString("value"),strRowWidth); _di_IXMLNode weight_per_width_r = row->AddChild("weight_per_width"); weight_per_width_r->SetAttribute(WideString("value"),strRowWeight); _di_IXMLNode simulated = production->AddChild("simulated"); _di_IXMLNode wpi_s = simulated->AddChild("wpi"); wpi_s->SetAttribute(WideString("value"),strSimWpi); _di_IXMLNode cpi_s = simulated->AddChild("cpi"); cpi_s->SetAttribute(WideString("value"),strSimCpi); _di_IXMLNode width_s = simulated->AddChild("width"); width_s->SetAttribute(WideString("value"),strSimWidth); _di_IXMLNode weight_per_width_s = simulated->AddChild("weight_per_width"); weight_per_width_s->SetAttribute(WideString("value"),strSimWeight); _di_IXMLNode quota_per_day = production->AddChild("quota_per_day"); quota_per_day->SetAttribute(WideString("value"),strQuota); _di_IXMLNode machine_name = production->AddChild("machine_name"); machine_name->SetAttribute(WideString("value"),strMachine); _di_IXMLNode note = production->AddChild("note"); note->SetAttribute(WideString("value"),"test"); _di_IXMLNode magnification_ratio = production->AddChild("magnification_ratio"); magnification_ratio->SetAttribute(WideString("value"),strMagnificationRatio); xmlDocument->SaveToFile(SavePath); xmlDocument->CleanupInstance(); } //--------------------------------------------------------------------------- void __fastcall TMain::SaveJPG(AnsiString name, AnsiString DesignImgPath, AnsiString SimulationImgPath) { HDC dc=NULL; int dx=0,dy=0,sx=0,sy=0; int Width = 320; int height = 240; Graphics::TBitmap *designImg = new Graphics::TBitmap; Graphics::TBitmap *simulationImg = new Graphics::TBitmap; TJPEGImage*imgJpg=new TJPEGImage(); /////////////////////////////////////////////////////////////// designImg->Width = Width; designImg->Height = height; dc=DesignForm->smallchart->CreateDC(); dx=0,dy=0,sx=0,sy=0; if(DesignForm->smallchart->Width>designImg->Width) { sx = DesignForm->smallchart->Width-designImg->Width; dx = 0; } else { sx = 0; dx = 0; } if(DesignForm->smallchart->Height>designImg->Height) { sy = DesignForm->smallchart->Height-designImg->Height; dy = 0; } else { sy = 0; dy = 0; } BitBlt(designImg->Canvas->Handle, dx, dy, designImg->Width, designImg->Height, dc, sx, sy, SRCCOPY); DesignForm->smallchart->DeleteDC(dc); imgJpg->Assign(designImg); imgJpg->SaveToFile(DesignImgPath); /////////////////////////////////////////////////////////////// simulationImg->Width = Width; simulationImg->Height = height; dc=SimulationForm->image->CreateDC(); dx=0,dy=0,sx=0,sy=0; if(SimulationForm->image->Width>simulationImg->Width) { sx = SimulationForm->image->Width-simulationImg->Width; dx = 0; } else { sx = 0; dx = 0; } if(SimulationForm->image->Height>simulationImg->Height) { sy = SimulationForm->image->Height-simulationImg->Height; dy = 0; } else { sy = 0; dy = 0; } BitBlt(simulationImg->Canvas->Handle, dx, dy, simulationImg->Width, simulationImg->Height, dc, sx, sy, SRCCOPY); SimulationForm->image->DeleteDC(dc); imgJpg->Assign(simulationImg); imgJpg->SaveToFile(SimulationImgPath); delete imgJpg; } //--------------------------------------------------------------------------- void __fastcall TMain::Upload1Click(TObject *Sender) { // File Path Setting // AnsiString strFileName = ExtractFileName(maindata.FileName); if(strFileName.IsEmpty()) return; strFileName= strFileName.SubString(1, strFileName.Length() - 4); strFileName= strFileName.UpperCase(); // Upload ¿©ºÎ È®ÀÎ Message AnsiString strUpLoadMessage; strUpLoadMessage="Upload " + strFileName + "?"; if(!(MessageBox(NULL, strUpLoadMessage.c_str() , "Upload Message", MB_YESNOCANCEL) == IDYES)) return; AnsiString strServerUrl = InputBox("UPLOAD", "Set new upload url","http://211.238.177.146:9999/design_data/upload"); ShowMessage("Upload to " + strServerUrl); // Æú´õ À¯¹« È®ÀÎ AnsiString strSaveMain = BaseDir + "\\Upload\\"; if(!DirectoryExists(strSaveMain)){ ::CreateDirectory(strSaveMain.c_str(), NULL); } AnsiString strSaveDirPath = strSaveMain + strFileName + "\\"; if(::GetFileAttributes(strSaveDirPath.c_str())) { ::CreateDirectory(strSaveDirPath.c_str(), NULL); } AnsiString strTrcPath = strSaveDirPath + strFileName + ".trc"; AnsiString strXmlPath = strSaveDirPath + strFileName + ".xml"; AnsiString strDesignImgPath = strSaveDirPath + strFileName +"_design.jpg"; AnsiString strSimulationImgPath = strSaveDirPath + strFileName +"_simulation.jpg"; // Trc Upload Æú´õ¿¡ ÀúÀå // //SaveTRC(strFileName,strTrcPath); // XML »ý¼º // SaveXML(strFileName,strXmlPath); // JPG »ý¼º // SaveJPG(strFileName, strDesignImgPath, strSimulationImgPath); // Upload // TIdMultiPartFormDataStream *streamRequest = new TIdMultiPartFormDataStream(); TStringStream *streamResponse = new TStringStream(""); TStringList *AllFileList = new TStringList; AnsiString strServerAddress = strServerUrl; //streamRequest->AddFile("trc", strTrcPath, "trc"); streamRequest->AddFile("project", strXmlPath, "text/xml"); streamRequest->AddFile("design", strDesignImgPath, "jpg"); streamRequest->AddFile("simulation", strSimulationImgPath, "jpg"); TIdHTTP *IdHTTP = new TIdHTTP(this); try{ IdHTTP->HandleRedirects = true; IdHTTP->Request->ContentType = streamRequest->RequestContentType; IdHTTP->Post(strServerAddress, streamRequest, streamResponse); if (IdHTTP) delete IdHTTP; if (streamResponse) delete streamResponse; if (streamRequest) delete streamRequest; IdHTTP = NULL; streamResponse = NULL; streamRequest = NULL; ShowMessage("Success!!"); } catch(Exception &e){ ShowMessage(e.Message); if (IdHTTP) delete IdHTTP; if (streamResponse) delete streamResponse; if (streamRequest) delete streamRequest; IdHTTP = NULL; streamResponse = NULL; streamRequest = NULL; } } //--------------------------------------------------------------------------- ///(R,G,B)¸¦ (L,a,b)·Î ¹Ù²ãÁÜ AnsiString __fastcall RGBtoLAB(BYTE R, BYTE G, BYTE B) //2006.11.23 by smallpotato { AnsiString L_str; AnsiString A_str; AnsiString B_str; float var_R, var_G, var_B, var_X_D65, var_Y_D65, var_Z_D65, var_X_D50, var_Y_D50, var_Z_D50, var_X, var_Y, var_Z; var_R = ((float)R) / 255; //Where R = 0 ¡À 255 var_G = ((float)G) / 255; //Where G = 0 ¡À 255 var_B = ((float)B) / 255; //Where B = 0 ¡À 255 if ( var_R > 0.03928 ) var_R = pow(( var_R + 0.055 ) / 1.055 , 2.4); else var_R = var_R / 12.92; if ( var_G > 0.03928 ) var_G = pow(( var_G + 0.055 ) / 1.055 , 2.4); else var_G = var_G / 12.92; if ( var_B > 0.03928 ) var_B = pow(( var_B + 0.055 ) / 1.055 , 2.4); else var_B = var_B / 12.92; //0.04045 var_R = var_R * 100; var_G = var_G * 100; var_B = var_B * 100; var_X_D65 = var_R * 0.4124 + var_G * 0.3576 + var_B * 0.1805; var_Y_D65 = var_R * 0.2126 + var_G * 0.7152 + var_B * 0.0722; var_Z_D65 = var_R * 0.0193 + var_G * 0.1192 + var_B * 0.9505; //bradford transform D65 to D50 if(1/*GetRGBtoLABmap()->illuminant == LUMINANT_D50*/){ var_X_D65 = var_X_D65 * 1.0479 + var_Y_D65 * 0.0229 + var_Z_D65 * -0.0502; var_Y_D65 = var_X_D65 * 0.0296 + var_Y_D65 * 0.9904 + var_Z_D65 * -0.0171; var_Z_D65 = var_X_D65 *-0.0092 + var_Y_D65 * 0.0151 + var_Z_D65 * 0.7519; } if(1/*GetRGBtoLABmap()->illuminant == LUMINANT_D50*/){ var_X = var_X_D65 / 96.43; //ref_X = 95.047 96.43 Observer= 2¡Æ, Illuminant= D65 & 50 var_Y = var_Y_D65 / 100.00; //ref_Y = 100.000 100 var_Z = var_Z_D65 / 82.51; //ref_Z = 108.883 82.51*/ } else if(0/*GetRGBtoLABmap()->illuminant == LUMINANT_D65*/){ var_X = var_X_D65 / 95.047; var_Y = var_Y_D65 / 100.000; var_Z = var_Z_D65 / 108.883; } if ( var_X > 0.008856 ) var_X = pow(var_X, 1.0f/3); else var_X = ( 7.787 * var_X ) + ( 16.0f / 116 ); if ( var_Y > 0.008856 ) var_Y = pow(var_Y, 1.0f/3); else var_Y = ( 7.787 * var_Y ) + ( 16.0f / 116 ); if ( var_Z > 0.008856 ) var_Z = pow(var_Z, 1.0f/3); else var_Z = ( 7.787 * var_Z ) + ( 16.0f / 116 ); L_str = IntToStr(Round(( 116 * var_Y ) - 16)); A_str = IntToStr(Round(500 * ( var_X - var_Y ))); B_str = IntToStr(Round(200 * ( var_Y - var_Z ))); return L_str+"/"+A_str+"/"+B_str; } //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- ///¹Ý¿Ã¸²ÇÔ¼ö. ¼Ò¼ö ù°ÀÚ¸®¿¡¼­ ¹Ý¿Ã¸² int __fastcall Round(double num){ return num>=0?(int)(num+0.5):(int)(num-0.5); } //-----------------------------------------------------------------------------