//--------------------------------------------------------------------------- #include #pragma hdrstop #include "Simulation.h" #include "MainImage.h" #include "ModeView_F.h" #include "TextureArrange.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "TPSpin" #pragma resource "*.dfm" TSimulationForm *SimulationForm; //--------------------------------------------------------------------------- __fastcall TSimulationForm::TSimulationForm(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::FormCreate(TObject *Sender) { SetSmallFont(Font); SetSmallFont(lbKind->Font); SetSmallFont(stCut->Font); SetSmallFont(stEffect->Font); SetSmallFont(stEdge->Font); SetSmallFont(stMode->Font); } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::InitForm() { ParentHeight = Parent->Height+20; ClientHeight = 332; Parent->Height = ParentHeight+ClientHeight; //======================================================================== if (MainImageForm->Plan->Dsim.end) //0 stCut->Caption = IDS_COMMON_BUTTONYES; else //1 stCut->Caption = IDS_COMMON_BUTTONNO; if (MainImageForm->Plan->Dsim.edge == 0) //0 stEdge->Caption = IDS_COMMON_BUTTONYES; else //-1 stEdge->Caption = IDS_COMMON_BUTTONNO; if (MainImageForm->Plan->mode) stMode->Caption = IDS_COMMON_BUTTONYES; else stMode->Caption = IDS_COMMON_BUTTONNO; //======================================================================== ViewForm->OnCloseForm = ViewClose; btnExecute->Enabled = MainImageForm->Plan->Finish; View(); } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::stCutClick(TObject *Sender) { if (MainImageForm->Plan->Dsim.end) { MainImageForm->Plan->Dsim.end = 0; stCut->Caption = IDS_COMMON_BUTTONNO; } else { MainImageForm->Plan->Dsim.end = 1; stCut->Caption = IDS_COMMON_BUTTONYES; } } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::btnExecuteClick(TObject *Sender) { TCursor old = Screen->Cursor; Screen->Cursor = crHourGlass; ViewForm->Visible = false; sbView->Down = false; sbView->Flat = false; MainImageForm->Plan->view = false; MainImageForm->bChoiceExchange = false; MainImageForm->Simulation(); if (MainImageForm->Plan->ModeBitmap) sbView->Enabled = true; else sbView->Enabled = false; Screen->Cursor = old; ::RepaintColor(); } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::stEdgeClick(TObject *Sender) { TPileCondition *sd = &MainImageForm->Plan->Dsim; if (sd->edge == 0) { sd->edge = -1; stEdge->Caption = IDS_COMMON_BUTTONNO; } else { sd->edge = 0; stEdge->Caption = IDS_COMMON_BUTTONYES; } } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::spMoveChange(TObject *Sender) { if (CheckLimit(Sender)) { TPileCondition *sd = &MainImageForm->Plan->Dsim; sd->move = (double) spMove->Value / 90.0; } } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::spRepCChange(TObject *Sender) { if (CheckLimit(Sender)) { TPileCondition *sd = &MainImageForm->Plan->Dsim; sd->ec = spRepC->Value; } } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::spRepWChange(TObject *Sender) { if (CheckLimit(Sender)) { TPileCondition *sd = &MainImageForm->Plan->Dsim; sd->ew = spRepW->Value; } } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::spCPIChange(TObject *Sender) { if (CheckLimit(Sender)) { TPileCondition *sd = &MainImageForm->Plan->Dsim; sd->cpi = spCPI->Value; } } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::spWPIChange(TObject *Sender) { if (CheckLimit(Sender)) { TPileCondition *sd = &MainImageForm->Plan->Dsim; sd->wpi = spWPI->Value; } } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::spSpreadChange(TObject *Sender) { if (CheckLimit(Sender)) { TPileCondition *sd = &MainImageForm->Plan->Dsim; sd->spread = spSpread->Value; } } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::spEditClick(TObject *Sender) { ((TPSpinEdit *) Sender)->SetFocus(); ((TPSpinEdit *) Sender)->SelectAll(); } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::stModeClick(TObject *Sender) { if (MainImageForm->Plan->mode) { MainImageForm->Plan->mode = false; stMode->Caption = IDS_COMMON_BUTTONNO; } else { MainImageForm->Plan->mode = true; stMode->Caption = IDS_COMMON_BUTTONYES; } } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::sbViewClick(TObject *Sender) { if (sbView->Flat == false) { ViewForm->Visible = true; sbView->Flat = true; } else { ViewForm->Visible = false; sbView->Flat = false; } MainImageForm->Plan->view = ViewForm->Visible; } //--------------------------------------------------------------------------- //////// Private /////////////////////////////////////////////////////////// //--------------------------------------------------------------------------- void __fastcall TSimulationForm::View() { TPileCondition *sd = &MainImageForm->Plan->Dsim; if (sd->machine == TRICOT) { lbKind->Caption = "Machine is TRICOT"; lbMove->Enabled = true; spMove->Enabled = true; lbCut->Enabled = true; stCut->Enabled = true; if (MainImageForm->Plan->Texture->Count>1) { lbMode->Enabled = true; stMode->Enabled = true; //Corrected by not machine but number of texture } else { lbMode->Enabled = false; stMode->Enabled = false; } } else { lbKind->Caption = "Machine is DNB"; lbMove->Enabled = false; spMove->Enabled = false; lbCut->Enabled = false; stCut->Enabled = false; lbMode->Enabled = true; stMode->Enabled = true; } if (sd->edge == 0) { lbRepC->Enabled = true; lbRepW->Enabled = true; spRepC->Enabled = true; spRepW->Enabled = true; } else { lbRepC->Enabled = false; lbRepW->Enabled = false; spRepC->Enabled = false; spRepW->Enabled = false; } if (MainImageForm->Plan->ModeBitmap) sbView->Enabled = true; else sbView->Enabled = false; spRepC->Value = sd->ec; spRepW->Value = sd->ew; spSpread->Value = sd->spread; spCPI->Value = sd->cpi; spWPI->Value = sd->wpi; spMove->Value = (int) sd->move * 90; } //--------------------------------------------------------------------------- bool __fastcall TSimulationForm::CheckLimit(TObject *Sender) { TPSpinEdit *sp = (TPSpinEdit *) Sender; if (sp->Text.Length() > 0) { if (sp->Value > sp->MaxValue) sp->Value = sp->MaxValue; if (sp->Value < sp->MinValue) sp->Value = sp->MinValue; return true; } return false; } //--------------------------------------------------------------------------- void __fastcall TSimulationForm::ViewClose() { sbView->Down = false; sbView->Flat = false; MainImageForm->Plan->view = false; } //---------------------------------------------------------------------------