//----------------------------------------------------------------------------//
//    module FEditSets.h                                                      //
//                                                                            //
//    Form to edit the parameter sets for the parameter tuning                //
//                                                                            //                                                                            //
//    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 FEditSetsH
#define FEditSetsH

#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ComCtrls.hpp>
#include <Buttons.hpp>
#include <Mask.hpp>
#include <ExtCtrls.hpp>
#include <AppEvnts.hpp>


//----------------------------------------------------------------------------------------------------------------------
#include <values>             // due to:  MAXFLOAT

#include "data.h"             //          TData
#include "projectG.h"         //          TProjectG
#include "paraset.h"          //          TParaSet & TParaSetList


bool CheckParameterString(const bool& f_OnlyOne, AnsiString& szPara, const AnsiString& szName, const float& defVal,
      const float& min, const bool& f_Integer, const float& max=MAXFLOAT);


//----------------------------------------------------------------------------------------------------------------------
// Form to edit parameter sets for optimization
class TFEditSets : public TForm
{
__published:
   TListView *LvTasks;
   TBitBtn *BtEdit;
   TBitBtn *BtDelete;
   TBitBtn *BtAccept;
   TLabel *LaIntervals;
   TLabel *LaWmin;
   TLabel *LaEta;
   TLabel *LaCardinality;
   TLabel *LaSigma;
   TLabel *LaSpecial;
   TGroupBox *GbTask;
   TEdit *EIntervals;
   TEdit *EWmin;
   TEdit *EEta;
   TEdit *ECardinality;
   TEdit *ESigma;
   TEdit *ESpecial;
   TBitBtn *BtDefaults;
   TGroupBox *GbAcceptedTask;
   TLabel *LaWeights;
   TLabel *LaPrune;
   TLabel *LaEuclidean;
   TMaskEdit *EWeights;
   TMaskEdit *EPrune;
   TMaskEdit *EEuclidean;
   TBitBtn *BtClearAll;
   TLabel *LaSetCount2;
   TLabel *LaSetCount1;
   TBitBtn *BtOk;
   TBitBtn *BtWizard;
   TRadioGroup *RadioGroup1;
   TRadioButton *RbNormal;
   TRadioButton *RbFast;
   TRadioButton *RbExhaustive;
   TCheckBox *CbEnableEditing;
   void __fastcall FormShow(TObject *Sender);
   void __fastcall BtWizardClick(TObject *Sender);
   void __fastcall EIntervalsExit(TObject *Sender);
   void __fastcall EWminExit(TObject *Sender);
   void __fastcall EEtaExit(TObject *Sender);
   void __fastcall ECardinalityExit(TObject *Sender);
   void __fastcall ESigmaExit(TObject *Sender);
   void __fastcall ESpecialExit(TObject *Sender);
   void __fastcall BtAcceptClick(TObject *Sender);
   void __fastcall EWeightsExit(TObject *Sender);
   void __fastcall EPruneExit(TObject *Sender);
   void __fastcall EEuclideanExit(TObject *Sender);
   void __fastcall BtDefaultsClick(TObject *Sender);
   void __fastcall LvTasksSelectItem(TObject *Sender, TListItem *Item, bool Selected);
   void __fastcall BtDeleteClick(TObject *Sender);
   void __fastcall BtEditClick(TObject *Sender);
   void __fastcall BtClearAllClick(TObject *Sender);
   void __fastcall LvTasksKeyUp(TObject *Sender, WORD &Key, TShiftState Shift);
   void __fastcall BtOkClick(TObject *Sender);
   void __fastcall CbEnableEditingClick(TObject *Sender);

private:

   void SetDefaults();                              // initialize parameters (edit task group box) with default values
   void DisplaySetCount();                          // display total number of runs


   const TData* data;                               // learn data, used to get # variables etc.
   TProjectG* prj;
   const TParaSet* para;                            // standard (default) parameters

   void AddTaskToListView(const TTask*const& task);
   void DeleteTask(const int& index);               // delete selected task from list
   void DeleteAllTasks();                           // delete all tasks from list

   void EnableTaskEditing(const bool& f_Enable);

   bool f_SomethingChanged;

public:

   // constructor/destructor
   __fastcall TFEditSets(TComponent*) : TForm(Owner) {};
   __fastcall ~TFEditSets(){};

   bool SomethingChanged() const { return f_SomethingChanged; };     // return change flag

   void Associate(const TData*const& _data, TProjectG*const& _prj, const TParaSet*const& _para)
      { data =_data; prj=_prj; para=_para;};                         // set (learn) data, project and parameters
};
extern PACKAGE TFEditSets *FEditSets;
#endif