////////////////////////////////////////////////////////////////////////////////
//
// base.h -  , ,   
//
////////////////////////////////////////////////////////////////////////////////
#ifndef __BASE_H
#define __BASE_H

#if !defined( __SYSTYPES_H )
#include <systypes.h>
#endif

#include <Forms.hpp>

#ifndef __LIBTOOL_H
#include <libtool.h>
#endif

#ifndef __KONSTR_RH
#include "gayka.rh"
#endif

typedef UINT uint;

//  
struct HotPointDescription;

//-------------------------------------------------------------------------------
//    
// ---
#define SPC_FORMAT   1 // 
#define SPC_ZONA     2 // 
#define SPC_POSITION 3 // 
#define SPC_MARKER   4 // 
#define SPC_NAME     5 // 
#define SPC_COUNT    6 // 
#define SPC_NOTE     7 // 

//-------------------------------------------------------------------------------
//  
// ---
#define AXIS_OFF   0x1   // FALSE - , TRUE -  
#define PITCH      0x2   // FALSE -  , TRUE -  
#define SIMPLE     0x10  // FALSE -  , TRUE -  
#define ISPOLN     0x80  // FALSE -  1, TRUE -  2
#define TAKEISPOLN 0x100 // FALSE -   , TRUE -  

//-------------------------------------------------------------------------------
//   
// ---
#define KEY_S_ON     0x1   // TRUE -     , FALSE - 
#define KOEFF_MAT_ON 0x4   // FALSE -  , TRUE  
#define KEY_S        0x2   // TRUE -    , FALSE -     
#define KEY_S_GRAY   0x8   // TRUE -  "   "
#define PITCHOFF     0x800 // TRUE -    , FALSE -     

//-------------------------------------------------------------------------------
//  
// ---
#define SPC_CLEAR_GEOM   FALSE       //      
#define STANDART_SECTION 25          //     
#define COUNT_MASSA      1000        //       -
#define LIB_HELPFILE     "gayka.hlp" //   
#define SPCOBJ_CREATE    TRUE        //     
#define MIN_H_ANG        -90
#define MAX_H_ANG        90
#define MIN_H_SHAG       0.1
#define MAX_H_SHAG       1000
#define KONSTR_TXT       "konstr.txt"
#define SPC_LIB          "graphic.lyt"
#define MAX_COUNT_SPCOBJ 4           //       4
//        
#define MODSTEP_REAL 0.5412765877

//-------------------------------------------------------------------------------
//  
// ---
struct BaseMacroParam 
{
  float angle;      //  
  bool  flagAttr;   //   
  short drawType;   //   
  bool  typeSwitch; //       0 - Placement, 1 - Cursor
                    // Placement -     0X,
                    // Cursor -  (     0X   )
};

////////////////////////////////////////////////////////////////////////////////
//
//    
//
////////////////////////////////////////////////////////////////////////////////
class  CPar 
{
protected :
  reference    * refMacr;
  static reference spcObj[MAX_COUNT_SPCOBJ];
  uint           countObj;
  int            flagMode;
public:
  BaseMacroParam par;

public:
  CPar();
  virtual  ~CPar();

  virtual  void              GetGroup( reference &gr ) = 0; //  
  virtual  int               ChoiceMenuId()            = 0; //  
  virtual  void              SetParam()                = 0; //  

  //   Hot 
  virtual  BOOL              GetHotPoints( HotPointDescription* point, int index ) = 0;
  virtual  int               SetHotPoint ( HotPointDescription* point, int index ) = 0;

  virtual  int               Size()                       { return sizeof(par); }  //  
  virtual  void              SetHatchAngl()               {}                       //   
  virtual  void              SetHatchShag()               {}                       //   
  virtual  void              SetSimple()                  {}                       // 
  virtual  void              SetDimension()               {}                       // 
  virtual  int               MacroElementParam()          { return IDCANCEL; }     //   
  virtual  void              FuncAfteDrawType()           {}                       //      
  virtual  int               ServiceObj()                 { return 1; }            //  
  virtual  void              ServiceObj1( float , float ) {}                       //   1

  virtual  reference         EditSpcObj( reference*, reference ) { return 0; }     //   
  virtual  bool              IsSpcObjCreate()             { return false;}         //      
  virtual  void              CalkPaket()                  {} ;                     //   
  virtual  void              SetPlacement( double x, double y, double angl );      //    
           void              Assign ( const CPar &other );                         //  
           void              Draw1();                                              //  
           void              Draw();                                               //   1
           uint              GetObjCount()                { return countObj; }     //   
           short &           GetDrawType()                { return par.drawType; } //  
           //   
           bool &            GetFlagAttr()                { return par.flagAttr; }
           void              SetAttr()                    { par.flagAttr = par.flagAttr ? false : true; }

           operator void* ()                              { return &par.angle; }   //       void*

public:
  //   ,   Cursor  Placement
  static int  pascal CallBackP ( int com, double *x, double *y, double *angl, RequestInfo *info, void *phantom, int dynamic );
  static int  pascal CallBackC ( int com, double *x, double *y, RequestInfo *info, void *phantom, int dynamic );
  static bool        DrawSpcObj( reference group ); //   
  static void        _MessageBoxResult();           //     
  static void DrawPosLeader( reference _spcObj );   //    
};


////////////////////////////////////////////////////////////////////////////////
//
//  
// commandHelp - false -  ,     
//               true  -      (    )
//
////////////////////////////////////////////////////////////////////////////////
class  ConstrHelp  
{
  public :
    static  char helpName[250];
    static  uint command;
    static  bool commandHelp;
    static  bool helpErr;
    static  int  GetHelpFileName(); //   
    static  void SetCommandHelp( bool f = true ) { ConstrHelp::commandHelp = f; };
    static  void SetCommand( uint c ) { ConstrHelp::commandHelp = false; ConstrHelp::command = c; };
    static  bool IsCommandHelp( ) { return ConstrHelp::commandHelp; }
};


//-------------------------------------------------------------------------------
//  
// ---
float     SetHatchAngl( float ang );                        //   
float     SetHatchShag( float shag);                        //   
void      CheckDecimelPart(char *s,unsigned int pointToComma = 0 ); //        "." 
int       pr_str(char *vh, char *rez, int t);               //    
void      ErrorKonstr();                                    //   konstr.txt
reference _OpenTextFile( char *name );                      //   
int       _ConnectDB(reference bd, char *name );            //   
int       _GetMacroParam( void *value, unsigned int size ); //    
double    GetViewScale();                                   //  
char*     LoadStr( int id, char *str, int size );           //    
void      ConvertLangForm( TForm* form );                   //   
int       GetFullName( char *name, char *fName );           //      

#endif