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

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

#ifndef __PROPMEN_H
#include "PropMen.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 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 //     
#define PARAM_COUNT      5    //      

#define MAX_LENGTH 1000       //   
#define MIN_LENGTH 0          //   

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


//------------------------------------------------------------------------------
//   
// ---                      
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 : public PropertyManagerObject 
{
private :
	IDocument3DPtr					 doc;            //     3D-
  IPartPtr                 part;           // 
  IEntityCollectionPtr     collect;        //   entity 
  bool                     collectChanged; // true -  
  CString                  fileName;       //  
  int                      flagMode;       //  
  ShpeelBase               bBase;          //   
  bool                     changed;        //   
  bool                     openBase;       //   

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

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

  // 
  void 				      Init();                                          
  //  
  void              Assign( const Shpeel& other ); 
  // 
  Shpeel *          Dublicate();
  //     
  bool &            GetCollectChanged() { return collectChanged; }   
  //     
  unsigned short &  GetFlagAttr() { return par.flagAttr; }           
  //                
  CString &         GetFileName();                                   
  //  
  void              SetParam( IPartPtr& pPart );                                      
  //  
  int               Size() { return sizeof(tmp) + sizeof(par); }     
  //   
  reference         EditSpcObj( reference spcObj );                  
  //      
  bool              IsSpcObjCreate() { return SPCOBJ_CREATE; };      
  //  3D 
  void              Draw3D( IDocument3DPtr& );                          
  //  
  int               OpenBase();                                      
  //  
  void              CloseBase();                                     
  //  
  int               GetParam();                                      
  //       
  void              SetCallBackAndFilterFunction( IRequestInfoPtr& info ); 
  //   
  bool              DrawSpcObj( reference & spcObj );                                    
  // AddRef -  
  IPartPtr&         GetPart() { return part; }
  // AddRef -  
  IDocument3DPtr&   GetDoc()	{ return doc;  }
  //    -  true    Mate'
  bool              IsCollectionChange( IRequestInfoPtr& info ); 
  bool AddMate( short constraintType, 
                short direction, 
                short fixed, 
                double val,
                IEntity* ent, 
                LPCTSTR surfaceName, 
                IPart* p,
                IMateConstraintCollection* mCol );
  //  
  void              SetMates( IRequestInfoPtr& info, 
                              bool delMates = false );
  //       
  IEntityPtr        GetEntityByName( LPCTSTR name, IPartPtr& p );
  bool              GetDirectionElem() { return true; }           
  //   -  placement
  bool              IsCollectionEmpty( IRequestInfoPtr& info );  
  
//   ##################################################################
  //  prButtonClick -  .
  virtual void      OnButtonClick( long buttonID );     
  //  prChangeControlValue -   
  virtual void      OnChangeControlValue( long ctrlID, const VARIANT& newVal );
  
  //  
  virtual void      RedrawPhantom();    
  //     
  virtual void      ShowControls();
  //  
  virtual void      ShowParam();  
  //      
  virtual int       ParamCount(){ return PARAM_COUNT; }
  //  
  virtual long      GetSlideID();

  //   
  void              FillDiametr( IPropertyListPtr & diamList );
  //   
  void              FillLenght( IPropertyListPtr & lenghtList );
  //     
  void              FillScrewEnding( IPropertyListPtr & screwEndingList );
  //    
  void              FillClass( IPropertyListPtr & classList ); //     
  //   
  void              FillGost( IPropertyListPtr & gostList ); 
  //     
  void              FillMaterial( IPropertyListPtr & materialList ); 

  //   
  bool              Changed()                            { return changed; }  
  void              SetChanged( bool newChanged = true ) { changed = newChanged; } 
//   ##################################################################

//   
public : 
  static Shpeel*  callbackCurrentShpeel;
  static IPartPtr callbackCurrentPhantom;
protected :   
  static bool WINAPI SELECTFILTERPROC( IEntity* entity );
  static int WINAPI  SELECTCALLBACKPROC( IEntity* entity, IRequestInfo* info );
};


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