//--------------------------------------------------------------------------- #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" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "TPRuler2D" #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] //--------------------------------------------------------------------------- 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 { ProtectCard->Read(); ProtectCard->Check(); if (ProtectCard->isHacking) { ShowMessage(IDS_MESSAGE_INTERFACE); Application->Terminate(); return; } } #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(); } //--------------------------------------------------------------------------- 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(sbL5->Font); SetSmallFont(sbL4->Font); SetSmallFont(sbL3->Font); SetSmallFont(sbL2->Font); SetSmallFont(sbL1->Font); } //--------------------------------------------------------------------------- void __fastcall TMain::FormCreate(TObject *Sender) { BaseDir = ExtractFileDir(Application->ExeName); TRegIniFile *RegIniFile = NULL; RegIniFile = new TRegIniFile(RegFilename); if (RegIniFile) { BaseDir = RegIniFile->ReadString("Common", "Exe", BaseDir); delete RegIniFile; } Undo = new undodata; if(IsVivien()){ Caption = PROGRAM_NAME + " " + VERSION + " (Vivien)"; } else { Caption = PROGRAM_NAME + " " + VERSION; } //////////////////////////////////////////////////////////////////////////////// SmallFont = new TFont; TIniFile *IniFile = new TIniFile(BaseDir + "\\Environment.ini"); if (IniFile) { Language=IniFile->ReadString("Environment", "Language", "English"); LoadFont(IniFile, SmallFont, "Font"); delete IniFile; } SetFont(); CommonStringTable.Create(BaseDir, Language, "Common"); MessageStringTable.Create(BaseDir, Language, "Message"); StringTable.Create(BaseDir, Language, "Main"); gbBarSelect->Caption=IDS_BAR_SELECT; gbMainMenu->Caption=IDS_MAIN_MENU; gbBasic->Caption=IDS_PRIMARY_SETTING_MENU; 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; //mYarnDB->Caption=IDS_YARN_DB; //mFont->Caption=IDS_FONT; mProduction->Caption=IDS_PRODUCTION; mCost->Caption=IDS_COST; //////////////////////////////////////////////////////////////////////////////// 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); 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; ShowMainData(); OnChangeSize(); int Items; ProtectCard = new TProtectCard; #ifdef LOCK_HASP LoadFromMainRegIniFile(); Items = ProtectCard->Init(Password); if ((((Items>>14)&3)==3)||Items<1 || (Items&PCN_TEXTRICOT)!=PCN_TEXTRICOT) { delete ProtectCard; ProtectCard = NULL; ShowMessage(IDS_MESSAGE_INTERFACE); Application->Terminate(); return; } else { ProtectCard->Read(); ProtectCard->Check(); if (ProtectCard->isHacking) { Application->Terminate(); return; } } switch (Items >> 14) { case 1: Caption = Caption + " - Education"; break; case 2: Caption = Caption + " - Demo"; break; default: break; } #endif #ifdef LOCK_IFC Items = ProtectCard->Init(RegFilename); if (Items==0 || (Items&PCN_TEXTRICOT)!=PCN_TEXTRICOT) { delete ProtectCard; ProtectCard = NULL; ShowMessage(IDS_MESSAGE_INTERFACE); Application->Terminate(); return; } else if(!ProtectCard->CheckPassword()) { ShowMessage(IDS_MESSAGE_INTERFACE); Application->Terminate(); return; } #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) { 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; } //--------------------------------------------------------------------------- void __fastcall TMain::edCourseKeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ if(edCourse->Text=="")return; Undo->reset(); maindata.course=StrToInt(edCourse->Text); texlayer->SetHeight(maindata.course); DesignForm->DrawChart(); 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(); } } //--------------------------------------------------------------------------- void __fastcall TMain::edBarKeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ maindata.bar=StrToInt(edBar->Text); if(maindata.bar>4){ maindata.bar=4; edBar->Text="4"; } 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){ texlayer->AddLayer(); } texlayer->SetHeight(maindata.course); } else { while(maindata.barTexList->Count) { 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(); DesignForm->cbOverLap->Checked=false; } } //--------------------------------------------------------------------------- void __fastcall TMain::sbGuideBarClick(TObject *Sender) { if(GuideBar_F->WindowState==wsMinimized){ GuideBar_F->WindowState=wsNormal; return; } if(GuideBar_F->Visible)GuideBar_F->Visible=false; else GuideBar_F->Visible=true; } //--------------------------------------------------------------------------- void __fastcall TMain::sbLoadSaveClick(TObject *Sender) { 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(); delete Form; } //--------------------------------------------------------------------------- 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; } } //--------------------------------------------------------------------- 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; SimulationForm->MakeImage(); ////////////////////////////////////////////////////////////////////////////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; } 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){ 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 { 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); } 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) { if(Treatment_F->WindowState==wsMinimized){ Treatment_F->WindowState=wsNormal; 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(); } } //--------------------------------------------------------------------------- void __fastcall TMain::mOpenSaveClick(TObject *Sender) { sbLoadSaveClick(NULL); } //--------------------------------------------------------------------------- void __fastcall TMain::mExitClick(TObject *Sender) { Close(); } //--------------------------------------------------------------------------- void __fastcall TMain::mAboutClick(TObject *Sender) { AboutBox->ShowModal(); } //--------------------------------------------------------------------------- void __fastcall TMain::TimerTimer(TObject *Sender) { splash->Close(); Timer->Enabled=false; } //--------------------------------------------------------------------------- void __fastcall TMain::mNewClick(TObject *Sender) { delete texlayer; texlayer=new TexLayer; maindata.reset();// ÃʱâÈ­ LayerNum=maindata.bar-1; for(int i=0;iAddLayer(); } texlayer->SetHeight(maindata.course); UpdateBtn(); DesignForm->UpdateCheckBox(); DesignForm->DrawChart(); 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(); } //--------------------------------------------------------------------------- void __fastcall TMain::mPrintClick(TObject *Sender) { PrintForm = new TPrintForm((TComponent *)NULL); PrintForm->ShowModal(); delete PrintForm; PrintForm=NULL; } //--------------------------------------------------------------------------- void __fastcall TMain::mYarnClick(TObject *Sender) { YarnCompositionData_F->Show(); } //--------------------------------------------------------------------------- void __fastcall TMain::edMGaugeKeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ maindata.gauge=StrToInt(Main->edMGauge->Text); maindata.cpc=StrToFloat(Main->edMCPC->Text); SimulationForm->SetSimulationData(); if(YarnCompositionData_F&&YarnCompositionData_F->Visible)YarnCompositionData_F->Repaint(); edMCPC->SetFocus(); } } //--------------------------------------------------------------------------- void __fastcall TMain::edMCPCKeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ 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); if(mw<1) { edMWidth->Text="1"; mw=1; } maindata.width = mw; SimulationForm->SetSimulationData(); 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) { if(SimulationForm->WindowState==wsMinimized){ SimulationForm->WindowState=wsNormal; return; } if(SimulationForm->Visible)SimulationForm->Visible=false; else SimulationForm->Visible=true; } //--------------------------------------------------------------------------- void __fastcall TMain::mDesignClick(TObject *Sender) { if(DesignForm->WindowState==wsMinimized){ DesignForm->WindowState=wsNormal; return; } if(DesignForm->Visible)DesignForm->Visible=false; else DesignForm->Visible=true; } //--------------------------------------------------------------------------- void __fastcall TMain::sbSimulationClick(TObject *Sender) { if(SimulationForm->WindowState==wsMinimized){ SimulationForm->WindowState=wsNormal; return; } if(SimulationForm->Visible)SimulationForm->Visible=false; else SimulationForm->Visible=true; } //--------------------------------------------------------------------------- void __fastcall TMain::sbCaptureClick(TObject *Sender) { if(CaptureForm->WindowState==wsMinimized){ CaptureForm->WindowState=wsNormal; return; } if(CaptureForm->Visible)CaptureForm->Visible=false; else CaptureForm->Visible=true; } //--------------------------------------------------------------------------- void __fastcall TMain::sbDesignClick(TObject *Sender) { if(DesignForm->WindowState==wsMinimized){ DesignForm->WindowState=wsNormal; return; } if(DesignForm->Visible)DesignForm->Visible=false; else DesignForm->Visible=true; } //--------------------------------------------------------------------------- void __fastcall TMain::mTreatmentClick(TObject *Sender) { sbTreatmentClick(NULL); } //--------------------------------------------------------------------------- void __fastcall TMain::sbL4Click(TObject *Sender) { if(maindata.bar<4)return; LayerNum=3; texlayer->SetVisibleLayer(0, false); texlayer->SetVisibleLayer(1, false); texlayer->SetVisibleLayer(2, false); texlayer->SetVisibleLayer(3, true); sbLXClick(); } //--------------------------------------------------------------------------- void __fastcall TMain::sbL3Click(TObject *Sender) { if(maindata.bar<3)return; LayerNum=2; texlayer->SetVisibleLayer(0, false); texlayer->SetVisibleLayer(1, false); texlayer->SetVisibleLayer(2, true); texlayer->SetVisibleLayer(3, false); sbLXClick(); } //--------------------------------------------------------------------------- void __fastcall TMain::sbL2Click(TObject *Sender) { if(maindata.bar<2)return; LayerNum=1; texlayer->SetVisibleLayer(0, false); texlayer->SetVisibleLayer(1, true); texlayer->SetVisibleLayer(2, false); texlayer->SetVisibleLayer(3, false); sbLXClick(); } //--------------------------------------------------------------------------- void __fastcall TMain::sbL1Click(TObject *Sender) { if(maindata.bar<1)return; LayerNum=0; texlayer->SetVisibleLayer(0, true); texlayer->SetVisibleLayer(1, false); texlayer->SetVisibleLayer(2, false); texlayer->SetVisibleLayer(3, false); sbLXClick(); } //--------------------------------------------------------------------------- void __fastcall TMain::sbLXClick(){ if(GuideBar_F&&GuideBar_F->Visible)GuideBar_F->Repaint(); if(EditorForm&&EditorForm->Visible)EditorForm->Init(); if(CaptureForm->Visible)CaptureForm->update_path(); if(Treatment_F->Visible)Treatment_F->Repaint(); GuideBar_F->UpdateGuideBar(); DesignForm->DrawChart(); DesignForm->UpdateMenu(); DesignForm->UpdateEdit(); DesignForm->cbOverLap->Checked=false; } //--------------------------------------------------------------------------- void __fastcall TMain::UpdateBtn(){ //¹öưÀ» ¾÷µ¥ÀÌÆ®ÇÑ´Ù switch(maindata.bar){ case 1: sbL1->Enabled=true; sbL2->Enabled=false; sbL3->Enabled=false; sbL4->Enabled=false; break; case 2: sbL1->Enabled=true; sbL2->Enabled=true; sbL3->Enabled=false; sbL4->Enabled=false; break; case 3: sbL1->Enabled=true; sbL2->Enabled=true; sbL3->Enabled=true; sbL4->Enabled=false; break; case 4: sbL1->Enabled=true; sbL2->Enabled=true; sbL3->Enabled=true; sbL4->Enabled=true; break; } if(maindata.bar<=LayerNum)LayerNum=maindata.bar-1; 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; } if(DesignForm->cbOverLap->Checked==true){ texlayer->SetVisibleLayer(0, DesignForm->cbLayer1->Checked); texlayer->SetVisibleLayer(1, DesignForm->cbLayer2->Checked); texlayer->SetVisibleLayer(2, DesignForm->cbLayer3->Checked); texlayer->SetVisibleLayer(3, DesignForm->cbLayer4->Checked); } else { texlayer->SetVisibleLayer(0, LayerNum==0); texlayer->SetVisibleLayer(1, LayerNum==1); texlayer->SetVisibleLayer(2, LayerNum==2); texlayer->SetVisibleLayer(3, LayerNum==3); } DesignForm->UpdateMenu(); } //--------------------------------------------------------------------------- void __fastcall TMain::mInOutClick(TObject *Sender) { sbGuideBarClick(NULL); } //--------------------------------------------------------------------------- void __fastcall TMain::mPropertyClick(TObject *Sender) { MetaDataForm->Show(); } //--------------------------------------------------------------------------- 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); 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(); //DesignForm->DrawChart(true); 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) { if(YarnListForm->WindowState==wsMinimized){ YarnListForm->WindowState=wsNormal; return; } if(YarnListForm->Visible)YarnListForm->Visible=false; else YarnListForm->Visible=true; } //--------------------------------------------------------------------------- void __fastcall TMain::mWindowClick(TObject *Sender) { mSimulation->Checked=SimulationForm->Visible; mDesign->Checked=DesignForm->Visible; mInOut->Checked=GuideBar_F->Visible; mYarnList->Checked=YarnListForm->Visible; mTreatment->Checked=Treatment_F->Visible; mCapture->Checked=CaptureForm->Visible; } //--------------------------------------------------------------------------- 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) { Environment->Show(); } //--------------------------------------------------------------------------- void __fastcall TMain::mCostClick(TObject *Sender) { Cost_F->Show(); } //---------------------------------------------------------------------------