//--------------------------------------------------------------------------- #include #pragma hdrstop #include "Progress_F.h" //#include "common.h" #include "ImageVectorizer_F.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" //--------------------------------------------------------------------------- #define IDS_ESTIMATEDTIME StringTable[0] #define IDS_ELAPSEDTIME StringTable[1] #define IDS_PROCESSTIME StringTable[2] //--------------------------------------------------------------------------- TProgressForm *ProgressForm; //--------------------------------------------------------------------------- __fastcall TProgressForm::TProgressForm(TComponent* Owner) : TForm(Owner) { //====================================================== /* StringTable.Create(DirectoryBin, Language, "Progress"); SetSmallFont(Font); Caption = IDS_PROCESSTIME; Label1->Caption = IDS_ESTIMATEDTIME; Label5->Caption = IDS_ELAPSEDTIME;*/ //====================================================== Caption = "Process Time"; Label1->Caption = "Estimated Time"; Label5->Caption = "Elapsed Time"; isCancelRequested = false; kind = 0; min_point = 1; } //--------------------------------------------------------------------------- void __fastcall TProgressForm::FormCreate(TObject *Sender) { st = clock()/CLK_TCK; } //--------------------------------------------------------------------------- void __fastcall TProgressForm::SetRatio(double Value) { int t, h, m, s; lbRatio->Caption = Format("%d%%", OPENARRAY(TVarRec, ((int)(Value*100)))); ProgressBar1->Position = Value*100; // express percentage if(Value >0.0) { t = (clock()/CLK_TCK - st)/Value ; // Estimated Time if(t >= 3600) {h = t/3600; t -= h*3600;} else h = 0; if(t >= 60) {m = t/60; t -= m*60;} else m = 0; s = t; lbest_time->Caption = Format("%2d : %2d : %2d", OPENARRAY(TVarRec, (h, m,s))); //the method how to output some varialbes in one Label t = clock()/CLK_TCK - st; //Elapsed Time if(t >= 3600) {h = t/3600; t -= h*3600;} else h = 0; if(t >= 60) {m = t/60; t -= m*60;} else m = 0; s = t; lbela_time->Caption = Format("%2d : %2d : %2d", OPENARRAY(TVarRec, (h, m,s))); Update(); } Application->ProcessMessages(); } //--------------------------------------------------------------------------- void __fastcall TProgressForm::SetTitle(String Value) { lbTitle->Caption = Value; } //--------------------------------------------------------------------------- void __fastcall TProgressForm::FormShow(TObject *Sender) { //FormShow()ÇÔ¼ö°¡ ½ÇÇàµÈ ÈÄ¿¡ VisibleÀÌ µÇ±â ¶§¹®¿¡ message¸¦ queue¿¡ ³Ö¾î¼­ //ÇÔ¼ö ½ÇÇà ÈÄ¿¡ algorithmÀÌ ½ÇÇà µÉ ¼ö ÀÖµµ·Ï ó¸®ÇÔ. PostMessage(this->Handle, TPM_DO_VECTORISING, 0, 0); } //--------------------------------------------------------------------------- void __fastcall TProgressForm::btnCancelClick(TObject *Sender) { isCancelRequested = true; } //--------------------------------------------------------------------------- bool __fastcall TProgressForm::RunThining() { Visible = true; ImageVectorizerForm->image_vectorizer->Thinning(); } //--------------------------------------------------------------------------- bool __fastcall TProgressForm::RunMakeContour(const int min_point) { Visible = true; ImageVectorizerForm->image_vectorizer->MakeContour(min_point); } //--------------------------------------------------------------------------- /** message queue¿¡¼­ TPM_DO_VECTORISING¸¦ È®ÀÎ ÇÑ ÈÄ¿¡ °ü·Ã algorithmÀÌ ½ÇÇàµÈ´Ù. ½ÇÇàÀÌ ³¡³ª¸é Formclose¸¦ ÇÑ´Ù. */ void TProgressForm::TPMDoProcessing(TMessage &msg) { if (kind) { RunMakeContour(min_point); } else { RunThining(); } Close(); } //---------------------------------------------------------------------------