////////////////////////////////////////////////////////////////////////////////
//
// gayka.h -    Visual C++ -  
//
////////////////////////////////////////////////////////////////////////////////
#ifndef __GAYKA_H
#define __GAYKA_H

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <libtool.h>

//  
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 KEY_S_ON     0x1   // TRUE -     , FALSE - 
#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     _T("gayka.hlp") //   
//        
#define MODSTEP_REAL 0.5412765877


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


//-------------------------------------------------------------------------------
//    5915
// ---
struct GAYKA5915
{
  float	dr;
  float	s;
	float	D;
  float	da;
  float	h;
  float	d2;
  float	p;
  short	maskAdjustment; //   
  short	classAccuracy;  //  
  float	hatchAngle;
  float	hatchStep;
  short	version;        //  
  float	massa;
  short	indexMassa;     // 0 - , 1 -  , 2 - 
  short	maskAdditional;	//   
};


//-------------------------------------------------------------------------------
//     
// ---
struct SimpleBase 
{
  reference bg;	      //  
  reference rg1, rg2; //  
};


////////////////////////////////////////////////////////////////////////////////
//
//    5915
//
////////////////////////////////////////////////////////////////////////////////
class Gayka5915 
{
protected :
  BaseMacroParam m_paramMacro;   //  
  GAYKA5915			 m_paramGayka;   //    5915
  
  reference			 m_refMacro;     //    
  bool				   m_flagMode;     //     (   )
  
public :
  static Gayka5915 * m_pCallbackCurrentGayka;
  static bool        m_flagSwitch;   //    Placement  Cursor
  static reference   m_refSpcObject; //  


  Gayka5915();
  Gayka5915( Gayka5915& other ); 


  void				Assign( Gayka5915& other );      // 
  operator void* () { return &m_paramMacro; }  //      void* (    )
  int     GetSize() { return sizeof(BaseMacroParam) + sizeof(GAYKA5915); } //  

	GAYKA5915&			GetParamGayka() { return m_paramGayka; } //   
  BaseMacroParam&	GetParamMacro() { return m_paramMacro; } //   
  short&			    GetDrawType()   { return m_paramMacro.drawType; } //   
 
  bool			MacroElementParam();                //  
  void			Draw();                             //  
  void      DrawPosLeader( reference spcObj );  //     
  int			  ChoiceMenuId();                     // 
  void		  SetHatchAngle();                    //   - 
  void		  SetHatchStep();                     //   - 
  void		  SetParamGr();                       //  
  void      SetPlacementGr( double x, double y, double angle ); //  
  bool      DrawSpcObj( reference group ); 	    //   
  reference StaticEditSpcObj( reference geom ); //   
  void			GetGroup( reference &group );       //  
  void			Gayka_Sverhu();                     //    (  )
  void			Gayka_P_K( int j );	                //    ( -/- )
  void			SetFlagMode( bool mode ) { m_flagMode = mode; }
// HOT_POINTS ##################################################################
  //   Hot 
  bool GetHotPoints( HotPointDescription* point, int index ); //   Hot 
  bool SetHotPoint( HotPointDescription* point, int index );  //   Hot 
  bool GetCursorText( int index, char** text );               //   Hot 
  bool ExecuteCommand( int id );                              //  
  bool EditComplete( int index, BOOL success );               //     ,    
  bool ChangeHotPointParam( double d );                       //   Hot 
  int  GetMenu();                                             // 
// HOT_POINTS ##################################################################

protected :  
  //   ,   Cursor
  static int WINAPI CALLBACKPROCCURSOR( int comm, double *x, double *y,
                                        RequestInfoT *info, 
                                        void *phantom, 
                                        int dynamic ); 
  //   ,   Placement
  static int WINAPI CALLBACKPROCPLACEMENT( int comm, double *x, double *y, double *angle,
                                           RequestInfoT *info, 
                                           void *phantom, 
                                           int dynamic );
};


//-------------------------------------------------------------------------------
//  
// ---
//    (   )
void Gayka_K_Side  ( float ls, float s, float D, float d2, float H, int j, int j2 );
//    (  -  )
void Gayka_K_Y     ( float ls, GAYKA5915 *tmp, int j );
//    (  )
void Gayka_K       ( float ls, float l, float d1, float s, float D, float l1, float H, short j, int j1, float d2, int j2 );
//    
LPTSTR LoadStr     ( int id );           
//    
int _ConnectDB( reference bd, LPCTSTR name );   
//                    
bool OpenGaykaBase ( SimpleBase &base );  
//                                  
bool ReadGaykaBase ( float d, SimpleBase &base, GAYKA5915 *pGayka );  
//   
void CloseGaykaBase( SimpleBase &base );                           

//-------------------------------------------------------------------------------
// 
// ---
extern AFX_EXTENSION_MODULE StepDLL;


#endif // !defined(__GAYKA_H)
