//    module: FMain.h                                                         //
//                                                                            //
//    Main form of the GUI for the PNC cluster/learning algorithm             //
//                                                                            //
//    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          //
//    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 FMainH
#define FMainH

#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ComCtrls.hpp>
#include <Menus.hpp>
#include <Dialogs.hpp>
#include <ExtCtrls.hpp>
#include <Buttons.hpp>
#include <ImgList.hpp>
#include <Mask.hpp>
#include <Chart.hpp>
#include <Series.hpp>
#include <TeEngine.hpp>
#include <TeeProcs.hpp>
#include <AppEvnts.hpp>
#include <ToolWin.hpp>

#include <Registry.hpp>       // due to:  TRegistry
#include <time>               //          clock_t

#include "data.h"             //          TData
#include "paraset.h"          //          TParaSet & TParaSetList
#include "para.h"             //          TParameter and default values
#include "projectG.h"         //          TProjectG
#include "cluster.h"          //          TCluster
#include "prediction.h"       //          TPrediction
#include "lossfunc.h"         //          TLossFucntion
#include "tune.h"             //          TTune

// forward declarations
class ThrLoadData;            // thread object, used to load data
class ThrUseModel;            // thread object, used to use model
class ThrLearnModel;          // thread object, used to learn pnc model
class ThrTune;                // thread object, used to tune parameters

#define SZ_DISABLE_WARNINGS   "Disable Warnings"   // registry keys ...
#define SZ_DISABLE_QUESTIONS  "Disable Questions"
#define SZ_COM_CHAR           "Comment Character"
#define DEF_DISABLE_WARNINGS  (bool) false         // ... and default settings
#define DEF_DISABLE_QUESTIONS (bool) false

#define SZ_REGISTRY_KEY "\\Software\\PNC2"
void WriteDefaultsToRegistry(TRegistry* registry, const bool& f_SkipIfExisting); // write defaults to registry

// globals
extern bool f_DisableWarnings;             // flag: disable warning message boxes
extern bool f_DisableQuestions;            // flag: assume YES on silly questions

// main window
class TFMain : public TForm
   TPageControl *PageControl;
   TTabSheet *TsBasic;
   TTabSheet *TsTuneResults;
   TTabSheet *TsModel;
   TTabSheet *TsUseModel;
   TMainMenu *MainMenu;
   TMenuItem *File1;
   TMenuItem *Help1;
   TMenuItem *MnNew;
   TMenuItem *MnOpenProject;
   TMenuItem *MnLoadModel;
   TMenuItem *MnExit;
   TMenuItem *MnHelp;
   TMenuItem *About;
   TOpenDialog *OpenDialog;
   TSaveDialog *SaveDialog;
   TGroupBox *GbLearnData;
   TGroupBox *GbTune;
   TGroupBox *GbParameters;
   TBitBtn *BtLearnData;
   TProgressBar *PbLearnData;
   TBitBtn *BtLearnDataPause;
   TBitBtn *BtLearnDataAbort;
   TTimer *LoadDataTimer;
   TBitBtn *BtLearnDataContinue;
   TBitBtn *BtEditSets;
   TLabel *LaIntervals;
   TLabel *LaWmin;
   TLabel *LaEta;
   TLabel *LaCardinality;
   TLabel *LaSigma;
   TLabel *LaSpecial;
   TCheckBox *CbWeights;
   TCheckBox *CbPrune;
   TCheckBox *CbEuclidean;
   TEdit *EIntervals;
   TEdit *EWmin;
   TEdit *EEta;
   TEdit *ECardinality;
   TEdit *ESpecial;
   TEdit *ESigma;
   TBitBtn *BtLearn;
   TBitBtn *BtTestData;
   TGroupBox *GbTestData;
   TProgressBar *PbTestData;
   TBitBtn *BtTestDataContinue;
   TBitBtn *BtTestDataAbort;
   TBitBtn *BtTestDataPause;
   TShape *ShTestDataStatus;
   TLabel *LaTestFile;
   TLabel *LaTestDataStatus;
   TGroupBox *GbSimulation;
   TProgressBar *PbTestModel;
   TBitBtn *BtTest;
   TGroupBox *GbTestPara1;
   TGroupBox *GbTestPara2;
   TEdit *ETestCardinality;
   TLabel *LaTestCardinality;
   TLabel *LaTestSigma;
   TEdit *ETestSpecial;
   TLabel *LaTestSpecial;
   TCheckBox *CbTestWeights;
   TCheckBox *CbTestEuclidean;
   TCheckBox *CbTestPrune;
   TShape *Shape1;
   TBitBtn *BtTestOutput;
   TCheckBox *CbWritePredictions;
   TLabel *LaSimulationFile;
   TLabel *LaTestTime;
   TGroupBox *GbModelParameter;
   TLabel *LaModelEta;
   TLabel *LaModelWmin;
   TLabel *LaModelIntervals;
   TLabel *LaModelIntervalsValue;
   TLabel *LaModelWminValue;
   TLabel *LaModelEtaValue;
   TLabel *LaModelWeights;
   TLabel *LaModelEuclidean;
   TBevel *Bevel8;
   TBevel *Bevel9;
   TBevel *Bevel10;
   TLabel *Label4;
   TLabel *Label5;
   TLabel *Label6;
   TLabel *LaModelWeightValue;
   TLabel *LaModelEuclideanValue;
   TGroupBox *GbModelStatus;
   TShape *ShModelStatus;
   TBitBtn *BtModelContinue;
   TBitBtn *BtModelPause;
   TBitBtn *BtModelAbort;
   TProgressBar *PbLearning;
   TGroupBox *GbModel;
   TLabel *LaNCuboids1;
   TLabel *LaNCuboids2;
   TLabel *LaHitrate;
   TLabel *LaNCuboids1Value;
   TLabel *LaNCuboids2Value;
   TLabel *LaHitrateValue;
   TLabel *LaCuboidMass;
   TLabel *LaCuboidMassValue;
   TLabel *LaCuboidSize;
   TLabel *LaCuboidSizeValue;
   TTimer *LearningTimer;
   TTimer *TestTimer;
   TTimer *TuningTimer;
   TListView *LvTuneResults;
   TLabel *LaModelStatus;
   TBitBtn *BtTestContinue;
   TBitBtn *BtTestAbort;
   TBitBtn *BtTestPause;
   TLabel *Label2;
   TBevel *Bevel21;
   TCheckBox *CbModify1;
   TCheckBox *CbModify2;
   TGroupBox *GbTestResults;
   TBevel *Bevel25;
   TBevel *BeLossHorLine1;
   TBevel *BeLossLine1;
   TBevel *BeLossLine2;
   TLabel *LaOverallLoss1;
   TLabel *LaResultHeader1;
   TLabel *LaLossName1;
   TLabel *LaLossName2;
   TBevel *BeLossHorLine3;
   TLabel *LaOverallLoss2;
   TLabel *LaInsideLoss1;
   TLabel *LaInsideLoss2;
   TLabel *LaOutsideLoss2;
   TBevel *BeLossHorLine2;
   TLabel *LaOutsideLoss1;
   TLabel *LaResultHeader3;
   TLabel *LaResultHeader2;
   TLabel *LaInsideRatio;
   TLabel *LaResultHeader4;
   TLabel *LaModelTimeHeader;
   TLabel *LaRuns;
   TLabel *LaLearnFileHeader;
   TLabel *LaLearnDataStatus;
   TShape *ShLearnDataStatus;
   TLabel *LaOutCol;
   TEdit *EOutCol;
   TCheckBox *CbClassification;
   TBitBtn *BtEditTypes;
   TMenuItem *MnSaveProject;
   TMenuItem *MnSaveModel;
   TBitBtn *BtOutColDown;
   TBitBtn *BtOutColUp;
   TBitBtn *BtTune;
   TBitBtn *BtDefault;
   TBevel *Bevel1;
   TBevel *Bevel3;
   TProgressBar *PbModelSize;
   TLabel *LaModelSize;
   TLabel *LaModelTime;
   TCheckBox *CbPruneAnyWay;
   TCheckBox *CbKillCuboids;
   TBitBtn *BtMaxSizeDown;
   TBitBtn *BtMaxSizeUp;
   TEdit *EMaxSize;
   TLabel *LaMaxSize;
   TCheckBox *CbRandomize;
   TCheckBox *CbSkipping;
   TTrackBar *TbDataSplitting;
   TLabel *LaSplitting;
   TEdit *ERepetition;
   TBitBtn *BtRepetitionDown;
   TBitBtn *BtRepetitionUp;
   TLabel *LaRepetition;
   TRadioButton *RbRepetition;
   TRadioButton *RbCrossValidation;
   TRadioButton *RbLoocv;
   TCheckBox *CbSkipTuning;
   TChart *MceChart;
   TPieSeries *Series2;
   TChart *CubHistChart;
   TBarSeries *Series1;
   TLabel *LaModelStatusHeader;
   TLabel *LaLearnFile;
   TLabel *LaLearnDataStatusHeader;
   TLabel *LaTestFileHeader;
   TLabel *LaTestDataStatusHeader;
   TLabel *LaSimulationFileHeader;
   TLabel *LaTestTimeHeader;
   TLabel *LaTestStatusHeader;
   TLabel *LaTestStatus;
   TLabel *LaResultHeader5;
   TBevel *Bevel2;
   TLabel *LaTestCuboids;
   TApplicationEvents *ApplicationEvents;
   TToolBar *ToolBar;
   TToolButton *TbNew;
   TImageList *ToolBarImageList;
   TToolButton *TbOpenProject;
   TToolButton *TbSaveProject;
   TToolButton *TbLoadModel;
   TToolButton *TbSaveModel;
   TToolButton *TbHelp;
   TToolButton *ToolButton2;
   TToolButton *TbAbout;
   TToolButton *ToolButton1;
   TMenuItem *MnSaveProjectAs;
   TMenuItem *MnOptions;
   TLabel *LaMinCmpr;
   TBitBtn *BtMinCmprDown;
   TBitBtn *BtMinCmprUp;
   TEdit *EMinCmpr;
   TGroupBox *GbTuneStatus;
   TProgressBar *PbTune;
   TBitBtn *BtTuneContinue;
   TBitBtn *BtTuneAbort;
   TLabel *LaTuneTime;
   TLabel *LaTuneTimeHeader;
   TLabel *LaTuneStatusHeader;
   TLabel *LaTuneStatus;
   TShape *Shape3;
   TBitBtn *BtTunePause;
   TLabel *LaSelectText;
   TEdit *ETestSigma;
   TBitBtn *BtSelect;
   TMenuItem *MnProjectOptions;
   TMenuItem *MnGuiOptions;
   TBevel *Bevel4;
   TBevel *Bevel5;
   TBevel *Bevel6;
   TBevel *Bevel7;
   TBevel *Bevel11;
   TBevel *Bevel12;
   TBevel *Bevel13;
   TBevel *Bevel14;
   TBevel *Bevel16;
   TBevel *Bevel17;
   void __fastcall AboutClick(TObject *Sender);
   void __fastcall BtLearnDataClick(TObject *Sender);
   void __fastcall BtLearnDataPauseClick(TObject *Sender);
   void __fastcall BtLearnDataContinueClick(TObject *Sender);
   void __fastcall BtLearnDataAbortClick(TObject *Sender);
   void __fastcall MnExitClick(TObject *Sender);
   void __fastcall FormCloseQuery(TObject *Sender, bool &CanClose);
   void __fastcall EOutColExit(TObject *Sender);
   void __fastcall BtEditTypesClick(TObject *Sender);
   void __fastcall RbRepetitionClick(TObject *Sender);
   void __fastcall RbCrossValidationClick(TObject *Sender);
   void __fastcall RbLoocvClick(TObject *Sender);
   void __fastcall TbDataSplittingChange(TObject *Sender);
   void __fastcall ERepetitionExit(TObject *Sender);
   void __fastcall EMaxSizeExit(TObject *Sender);
   void __fastcall BtEditSetsClick(TObject *Sender);
   void __fastcall FormShow(TObject *Sender);
   void __fastcall CbClassificationClick(TObject *Sender);
   void __fastcall TsUseModelShow(TObject *Sender);
   void __fastcall CbModify1Click(TObject *Sender);
   void __fastcall CbModify2Click(TObject *Sender);
   void __fastcall BtTestDataClick(TObject *Sender);
   void __fastcall BtTestDataContinueClick(TObject *Sender);
   void __fastcall BtTestDataAbortClick(TObject *Sender);
   void __fastcall BtTestDataPauseClick(TObject *Sender);
   void __fastcall PageControlChanging(TObject *Sender, bool &AllowChange);
   void __fastcall MnLoadModelClick(TObject *Sender);
   void __fastcall BtTestOutputClick(TObject *Sender);
   void __fastcall BtTestClick(TObject *Sender);
   void __fastcall BtTestPauseClick(TObject *Sender);
   void __fastcall BtTestContinueClick(TObject *Sender);
   void __fastcall BtTestAbortClick(TObject *Sender);
   void __fastcall OnTestTimer(TObject *Sender);
   void __fastcall BtLearnClick(TObject *Sender);
   void __fastcall BtTuneClick(TObject *Sender);
   void __fastcall EWminExit(TObject *Sender);
   void __fastcall EIntervalsExit(TObject *Sender);
   void __fastcall EEtaExit(TObject *Sender);
   void __fastcall ECardinalityExit(TObject *Sender);
   void __fastcall ESpecialExit(TObject *Sender);
   void __fastcall ESigmaExit(TObject *Sender);
   void __fastcall EOutColClick(TObject *Sender);
   void __fastcall EIntervalsClick(TObject *Sender);
   void __fastcall EWminClick(TObject *Sender);
   void __fastcall EEtaClick(TObject *Sender);
   void __fastcall ECardinalityClick(TObject *Sender);
   void __fastcall ESpecialClick(TObject *Sender);
   void __fastcall ESigmaClick(TObject *Sender);
   void __fastcall EOutColKeyDown(TObject *Sender, WORD &Key, TShiftState Shift);
   void __fastcall EIntervalsKeyDown(TObject *Sender, WORD &Key, TShiftState Shift);
   void __fastcall EWminKeyDown(TObject *Sender, WORD &Key, TShiftState Shift);
   void __fastcall EEtaKeyDown(TObject *Sender, WORD &Key, TShiftState Shift);
   void __fastcall ECardinalityKeyDown(TObject *Sender, WORD &Key, TShiftState Shift);
   void __fastcall ESpecialKeyDown(TObject *Sender, WORD &Key, TShiftState Shift);
   void __fastcall ESigmaKeyDown(TObject *Sender, WORD &Key, TShiftState Shift);
   void __fastcall BtOutColUpClick(TObject *Sender);
   void __fastcall BtOutColDownClick(TObject *Sender);
   void __fastcall ERepetitionKeyDown(TObject *Sender, WORD &Key, TShiftState Shift);
   void __fastcall BtRepetitionUpClick(TObject *Sender);
   void __fastcall BtRepetitionDownClick(TObject *Sender);
   void __fastcall BtMaxSizeUpClick(TObject *Sender);
   void __fastcall BtMaxSizeDownClick(TObject *Sender);
   void __fastcall EMaxSizeKeyDown(TObject *Sender, WORD &Key, TShiftState Shift);
   void __fastcall EMaxSizeClick(TObject *Sender);
   void __fastcall ERepetitionClick(TObject *Sender);
   void __fastcall BtDefaultClick(TObject *Sender);
   void __fastcall OnLearningTimer(TObject *Sender);
   void __fastcall BtModelPauseClick(TObject *Sender);
   void __fastcall BtModelAbortClick(TObject *Sender);
   void __fastcall BtModelContinueClick(TObject *Sender);
   void __fastcall MnSaveProjectClick(TObject *Sender);
   void __fastcall CbPruneClick(TObject *Sender);
   void __fastcall CbEuclideanClick(TObject *Sender);
   void __fastcall CbWeightsClick(TObject *Sender);
   void __fastcall ETestCardinalityExit(TObject *Sender);
   void __fastcall ETestCardinalityKeyDown(TObject *Sender, WORD &Key, TShiftState Shift);
   void __fastcall ETestCardinalityClick(TObject *Sender);
   void __fastcall ETestSpecialClick(TObject *Sender);
   void __fastcall ETestSpecialKeyDown(TObject *Sender, WORD &Key, TShiftState Shift);
   void __fastcall ETestSpecialExit(TObject *Sender);
   void __fastcall ETestSigmaKeyDown(TObject *Sender, WORD &Key, TShiftState Shift);
   void __fastcall ETestSigmaExit(TObject *Sender);
   void __fastcall CbTestPruneClick(TObject *Sender);
   void __fastcall CbTestWeightsClick(TObject *Sender);
   void __fastcall CbTestEuclideanClick(TObject *Sender);
   void __fastcall CbSkipTuningClick(TObject *Sender);
   void __fastcall CbKillCuboidsClick(TObject *Sender);
   void __fastcall CbPruneAnyWayClick(TObject *Sender);
   void __fastcall CbRandomizeClick(TObject *Sender);
   void __fastcall CbSkippingClick(TObject *Sender);
   void __fastcall ETestSigmaClick(TObject *Sender);
   void __fastcall MnNewClick(TObject *Sender);
   void __fastcall MnOpenProjectClick(TObject *Sender);
   void __fastcall MnSaveModelClick(TObject *Sender);
   void __fastcall MnHelpGuiClick(TObject *Sender);
   void __fastcall ApplicationEventsShortCut(TWMKey &Msg, bool &Handled);
   void __fastcall ApplicationEventsException(TObject *Sender, Exception *E);
   void __fastcall TsBasicResize(TObject *Sender);
   void __fastcall TsUseModelResize(TObject *Sender);
   void __fastcall TsModelResize(TObject *Sender);
   void __fastcall TsBasicShow(TObject *Sender);
   void __fastcall MnSaveProjectAsClick(TObject *Sender);
   void __fastcall CbWritePredictionsClick(TObject *Sender);
   void __fastcall MnProjectOptionsClick(TObject *Sender);
   void __fastcall EMinCmprExit(TObject *Sender);
   void __fastcall EMinCmprKeyDown(TObject *Sender, WORD &Key, TShiftState Shift);
   void __fastcall EMinCmprClick(TObject *Sender);
   void __fastcall BtMinCmprUpClick(TObject *Sender);
   void __fastcall BtMinCmprDownClick(TObject *Sender);
   void __fastcall BtTuneContinueClick(TObject *Sender);
   void __fastcall BtTunePauseClick(TObject *Sender);
   void __fastcall BtTuneAbortClick(TObject *Sender);
   void __fastcall TuningTimerTimer(TObject *Sender);
   void __fastcall LvTuneResultsColumnClick(TObject *Sender, TListColumn *Column);
   void __fastcall LvTuneResultsCompare(TObject* Sender, TListItem* Item1, TListItem* Item2, int Data, int& Compare);
   void __fastcall BtSelectClick(TObject *Sender);
   void __fastcall LvTuneResultsSelectItem(TObject *Sender, TListItem *Item, bool Selected);
   void __fastcall LvTuneResultsDblClick(TObject *Sender);
   void __fastcall PageControlResize(TObject *Sender);
   void __fastcall LvTuneResultsCustomDrawSubItem(TCustomListView *Sender,
          TListItem *Item, int SubItem, TCustomDrawState State,
          bool &DefaultDraw);
   void __fastcall MnGuiOptionsClick(TObject *Sender);


   TRegistry* registry;
   DWORD HtmlHelpCookie;

   friend void CallLoadLearnDataFinish(const bool&);
   friend void CallLoadTestDataFinish(const bool&);

   char cmplPrgName[256];              // program's name
   AnsiString szExeDir;                // executable's  directory
   AnsiString szHtmlHelpFile;          // help file name   
   AnsiString szProjectFile;           // project filename
   AnsiString szModelFile;             // model filename
   AnsiString szTuningFile;            // tuning results filename
   AnsiString szSimOutputFile;         // simulation output filename       // move to TProjectG (?)

   TProjectG      prj;                 // project
   TData          *data_L, *data_T;    // learn and test data
   TCluster*      model;               // model
   TPnc*          pnc;                 // pnc object (used to learn model)
   TTune*         tuneResults;         // tuning results
   TParameter     para;                // parameter used to learn and test model
   TLossFunction* loss;                // loss object (stores loss function results)
   TParaSet stdPara, learnPara;        // standard (default) parameters and parameters used to learn new model

   ThrLoadData*    LoadDataThread;     // thread objects
   ThrUseModel*    UseModelThread;
   ThrLearnModel*  LearnModelThread;
   ThrTune*        TuneThread;

   bool f_Stop;
   bool f_Loading, f_Tuning;           // flags that indicate, that some work is done by one of the thread objects ...
   bool f_Learning, f_Testing;         // ... This cane be: loading of data files, parameter tuning, learning or testing.
   bool f_LearnParaInitialized;        // flag: learn parameters on tab sheet 'Basic' are initialized
   bool f_Saved;                       // flag: project not saved    note: only model and tuning results are tracked

   bool f_IsWithOutput;                // test data is with output

   // tab sheet independant functions

   // the action list is used to summarize some commonly used actions/tasks
   // note: One could use separate functions instead but i liked this solution
   enum TActionList{LearnDataLoaded, EmptyProject, ModelLoaded, ClearTestData, ClearResults, ProjectToGUI
                  , TuneResultsLoaded, DeleteModel, DeleteTuningResults, DeleteTuningTasks};
   void ActionList(const TActionList& action);

   void SaveProject(AnsiString szFileName);              // save project to file
   void UpdatePara();                                    // initialize (learn and) test parameters

   void DoIt();                           // write through output column and set data and project in TVarTypes object
   void DoItExt();                        // call DoIt() to calculate feature weights and ini. standard parameters
   void EnableMenus(const bool& enable);  // enable/disable menus while busy (loading, learning, tuning, testing)

   void OpenHelp();                       // open help

   // tab sheet 'Basic'
   void ChangeOutCol(int outcol);

   void __fastcall OnLoadLearnDataTimer(TObject*);
   void OnLoadLearnDataFinish(const bool& error);     // learn data has been loaded
   void EnableLearnDataCtrls(const bool& enable);     // group box 'Learn Data' (and 'Tuning'/'Parameter') controls
   void EnableTuneCtrls     (const bool& enable);     // group box 'Tune parameters' controls
   void EnableParameterCtrls(const bool& enable);     // group box 'Parameter' controls
   void SetTsLearnFocus();                            // set focus to appropriate control

   void EvOutputType();                               // evaluate output variable type
   void EvTuneType();                                 // evaluate tuning type, hide inappropriate controls
   void Set_N_R_Tune(const int N_R_Tune);             // set repetition count
   void SetMaxSize(const int maxSize);
   void SetMinCmpr(const int minCmpr);

   void SetNParameterSets();                    // display actual number of parameter sets or hint how to define tasks
   void SetParameters(const TParaSet& para);    // initialize strings in group box 'Parameters' with given values
   void ActLearnDataStatus(const bool& f_ActFilename=false);

   // tab sheet 'Tuning Results'
   clock_t tuneTime, tuneStartTime;
   void AddTuningResult(const int& id);   // add one new tuning result
   void AddTuningResults();               // add new tuning results as necessary
   int ColumnToSort;                      // kind of global, used in LvTuningResultsColumnClick()
   void ActTuningResultsStatus();

   // tab sheet 'Model'
   clock_t learnTime, learnStartTime, testTime, testStartTime;
   void ActModelParameters();                                     // set values of group box 'Model Parameters'

   // tab sheet 'Use Model'
   void __fastcall OnLoadTestDataTimer(TObject*);
   void OnLoadTestDataFinish(const bool& error);                  // test data has been loaded

   void EnableTestDataCtrls(const bool& enable);
   void EnableTestTestParameterCtrls(const bool& enable);         // group box 'Learn Parameters'
   void EnableTestLearnAndTestParameterCtrls(const bool& enable); // group box 'Learn and Test Parameters'

   void SetTestParameter1();                                      // set values in group box 'Learn Parameters'
   void SetTestParameter2();                                      // set values in group box 'Learn and Test Parameters'
   void ActTestDataStatus(const bool& f_ActFilename=true);
   void ActTestStatus();
   void ActLossFunctionResults();                                 // display actual loss fucntion results

   void ActModelStatus();


   // constructor/destructor
   __fastcall TFMain(TComponent* Owner);
   __fastcall ~TFMain();

   bool AllowChangeOfInputType();                        // ask user if a model is present cause this will be deleted
   void SetSavedFlag(const bool& f_Set);                 // access 'project is saved' flag

   void OnDeployFinish();                                // simulation is finished, results can be displayed
   void OnLearnModelFinished(TCluster* _model);          // called if learning of model is finished
   void OnTuningFinished();                              // called if tuning is finished

   const bool& GetStopFlag() const { return f_Stop; };   // return reference to stop flag, used by thread objects to
                                                         // terminate upon request
extern PACKAGE TFMain *FMain;