//----------------------------------------------------------------------------//
//    module ThrLearnModel.h                                                  //
//                                                                            //
//    Thread function: Learns a model using TPnc and transforms the learned   //
//    model afterwards to TCluster by calling TPnc::ToTCluster().             //
//                                                                            //                                                                            //
//    copyright (c) 2003 by Lars Haendel                                      //
//    home: www.newty.de                                                      //
//                                                                            //
//    This program is free software; you can redistribute it and/or modify    //
//    it under the terms of the GNU General Public License as published by    //
//    the Free Software Foundation as version 2 of the License.               //
//                                                                            //
//    This program is distributed in the hope that it will be useful,         //
//    but WITHOUT ANY WARRANTY; without even the implied warranty of          //
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           //
//    GNU General Public License for more details.                            //
//                                                                            //
//    You should have received a copy of the GNU General Public License       //
//    along with this program; if not, write to the Free Software             //
//    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.               //
//                                                                            //
//----------------------------------------------------------------------------//



#ifndef ThrLearnModuleH
#define ThrLearnModuleH


//---------------------------------------------------------------------------
#include <Classes.hpp>


//---------------------------------------------------------------------------
#include "FMain.h"         // due to:  TFMain
#include "cluster.h"       //          TCluster


//---------------------------------------------------------------------------------------------------------------------------------------
//    Thread function: Learns a PNC model (TCluster)
class ThrLearnModel : public TThread
{
private:
   TFMain*   main;          // parent main window; used for calback when finished and to access stop flag
   TPnc*     pnc;           // pnc object which will be learned (with succesive calls to TPnc::Iterate())
   bool      f_Prune;       // flag: prune model after learning   note: overrides TParameter/TParaSet::Prune
   int       K;
   TCluster* model;

   void __fastcall MessageBox();      // display error message
   char szText[256];                // error message text


   void __fastcall Execute();
   void __fastcall OnFinish(TObject*); // call when learning is finished
public:
   __fastcall ThrLearnModel(bool CreateSuspended, TFMain*const& _main, TPnc*const& _pnc, const bool& _f_Prune, const int& _K);
};
#endif