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

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


//-------------------------------------------------------------------------------
//  
// ---
#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       _T("stud.l3d")           //  
#define STUDS_INPUT_PATH _T("||_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 :
	IDocument3DPtr   				 doc;            //     3D-
  IPartPtr                 part;           // 
  IEntityCollectionPtr     collect;        //   entity 
  bool                     collectChanged; // true -  
  CString                  fileName;       //  
  int                      flagMode;       //  
  ShpeelBase               bBase;          //   

  //  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( IPartPtr& part );                      //  
  int         Size() { return sizeof(tmp) + sizeof(par); }     //  
  int         MacroElementParam();                             //   
  reference   EditSpcObj( reference spcObj );                  //   
  bool        IsSpcObjCreate() { return SPCOBJ_CREATE; };      //      
  CString&    GetFileName();                                   //                
  void        Draw3D( IDocument3DPtr& doc );                   //  3D 
  int         OpenBase();                                      //  
  void        CloseBase();                                     //  
  int         GetParam();                                      //  
  void        SetCallBackAndFilterFunction( IRequestInfoPtr& info ); //       
  bool        DrawSpcObj();                                    //   
  IPartPtr&   GetPart() { return part; }                       // AddRef -  
  bool        IsCollectionChange( IRequestInfoPtr& info ); //    -  true    Mate'
  //  
  void        SetMates( IDocument3DPtr& doc, IRequestInfoPtr& info, bool delMates = false );
  //       
  IEntityPtr  GetEntityByName( LPCTSTR name, IPart* p = NULL );
  bool        GetDirectionElem() { return true; }           
  bool        IsCollectionEmpty( IRequestInfoPtr& info ); //   -  placement
  bool        AddMate( short constraintType, short direction, short fixed, double val,
                      IEntityPtr& ent, LPCTSTR surfaceName, IPart* p,
                      IMateConstraintCollection* mCol );

};


//{{AFX_INSERT_LOCATION}}
#endif // !defined(__STUDS3D_H)
