////////////////////////////////////////////////////////////////////////////////
//
// studs3d.h -    Visual C++ - 
//     
//
////////////////////////////////////////////////////////////////////////////////
#ifndef __STUDS3D_H
#define __STUDS3D_H

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

#ifndef __IUPTR_H
#include "iuptr.h"
#endif

#ifndef __LIBTOOL_H
#include "libtool.h"
#endif

#ifndef __LTOOL3D_H
#include "ltool3d.h"
#endif

#ifndef __LDEFIN3D_H
#include "ldefin3d.h"
#endif

#ifndef __LIBDB_H
#include "libdb.h"
#endif


//-------------------------------------------------------------------------------
//  
// ---
#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 ALLST        0x4    // FALSE -   b, TRUE -   
#define KONTR        0x8    // FALSE -  , TRUE -    
#define SECOFF       0x10   // FALSE -  , TRUE -  ,  ,  
#define TAKEKONTR    0x20   // FALSE -   , TRUE -  
#define REVERCE_ON   0x20   // FALSE -  , TRUE -  
#define TAKEPODG     0x40   // FALSE -   , TRUE -  
#define LEFT_DRAW    0x40   // TRUE -  
#define FLAGLENGTH   0x200  // FALSE -    , TRUE -  
#define ISPOLN3      0x200  //   FALSE -  2, TRUE -  3
#define REVERCE_DRAW 0x200  // TRUE -  , FALSE -  
#define SBORSHAYBA   0x400  // FALSE -   , TRUE -    
#define PITCHOFF     0x800  // FALSE -     , TRUE -   
#define LENLEN       0x1000 // FALSE -   , TRUE - 
#define LENLENOFF    0x2000 // FALSE -  , TRUE - 
#define ALLST_OF     0x4000 // TRUE -  checkbox    

//-------------------------------------------------------------------------------
//   
// ---
#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 DRAW_ST_OF   0x10  // FALSE -     TRUE -   

//-------------------------------------------------------------------------------
//  
// ---
#define COUNT_MASSA      1000 //       -
#define STANDART_SECTION 25   //     
#define SPC_NAME       	 5    //  

#define EPSILON          0.001  

#define STUDS_FILE       "stud.l3d"           //  
#define STUDS_INPUT_PATH "||_1" //    

#define SPCOBJ_CREATE    TRUE //     


////////////////////////////////////////////////////////////////////////////////
//
//     
//
////////////////////////////////////////////////////////////////////////////////


//------------------------------------------------------------------------------
//   
// ---                      
struct SHPEEL 
{
  float d;          //  
  float p1;         //  
  float p2;         //  
  float b1;         //   
  float c;          //  
  float l;          //  
  float b;          //   
  short f;          //  
  short klass;      //  
  short gost;       //  
  short ver;        //  
  float m1;         //  1 
  float m2;         //  2 
  short indexMassa; // 0 -  1 -   3 -  2 - 
};


////////////////////////////////////////////////////////////////////////////////
//
//      
//
////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------------
//     st22032.loa ... st22043.loa
// ---
struct ShpeelSTmp 
{
  short t;   //     
  float l;   //  
  float d;   //  
  float b;   //  
  float m1;  //   1
  float m2;  //   2
};


//------------------------------------------------------------------------------
//       22032.loa ... 22043.loa
// ---
struct ShpeelTmp 
{
  short t;   //     
  float d;   //  
  float p1;  //  
  float p2;  //  
  float b1;  //  
  float c;   //  
};


//------------------------------------------------------------------------------
//   
// ---
struct ShpeelBase 
{
  reference bg, rg1, rg2;
  reference bs, rs1, rs2;
};


//-------------------------------------------------------------------------------
//  
// ---
struct BaseMakroParam 
{
  float          ang;
  unsigned short flagAttr;
  short          drawType;
  BYTE           typeSwitch;  //      
                              // 0 -     0X ( Placement )
                              // 1 - ,     0X   ( Cursor )
};


////////////////////////////////////////////////////////////////////////////////
//
//  
//
////////////////////////////////////////////////////////////////////////////////
class Shpeel 
{
private :
	LPDOCUMENT3D 						 doc;            //     3D-
  LPPART                   part;           // 
  IUEnv<IEntityCollection> collect;        //   entity 
  bool                     collectChanged; // true -  
  String                   fileName;       //  
  int                      flagMode;       //  
  ShpeelBase               bBase;          //   
  bool                     openBase;       //  

  //  par  tmp   UserParam 
  BaseMakroParam           par;            //  
  SHPEEL                   tmp;            //   

public :
  Shpeel();
  Shpeel( const Shpeel& other );                //  

  void 				Init();                           // 
  void        Assign( const Shpeel& other );    //  
  Shpeel*     Dublicate();                      //  
  ShpeelBase& GetShpeelBase() { return bBase; } //   
  SHPEEL&     GetShpeelParam(){ return tmp; }   //  
  bool&       GetCollectChanged() { return collectChanged; } //     
  unsigned short & GetFlagAttr() { return par.flagAttr; }    //     

  int       ChoiceMenuId();                                  //  
  void      SetParam();                                      //  
  int       Size() { return sizeof(tmp) + sizeof(par); }     //  
  int       MacroElementParam();                             //   
  reference EditSpcObj( reference spcObj );                  //   
  bool      IsSpcObjCreate() { return SPCOBJ_CREATE; };      //      
  String&   SetFileName();                                   //                
  void      Draw3D( LPDOCUMENT3D );                          //  3D 
  int       OpenBase();                                      //     
  void      CloseBase();                                     //  
  int       GetParam();                                      //  
  void      SetCallBackAndFilterFunction( IUEnv<IRequestInfo>& info ); //       
  bool      DrawSpcObj();                                    //   
  LPPART    GetPart() { return part; }                       // AddRef -  
  bool      IsCollectionChange( IUEnv<IRequestInfo>& info ); //    -  true    Mate'
  //  
  void      SetMates( LPDOCUMENT3D doc, IUEnv<IRequestInfo>& info, bool delMates = false );
  //       
  LPENTITY  GetEntityByName( const char * name );
  bool      GetDirectionElem() { return true; }           
  bool      IsCollectionEmpty( IUEnv<IRequestInfo>& info ); //   -  placement
  bool IsBaseOpen() { return openBase; }                    //  
  int Shpeel::ReadShpeelBase( float d );                    //    
  int Shpeel::ReadShpeelStBase();                           //   
};


#endif // !defined(___STUDS3D_H)

