next up previous contents
Next: About this document Up: Dialog classes Previous: Kinematics

Geometry

#if !defined(__geometry_h)              // Sentry, use file only if it's not already included.
#define __geometry_h

/*  Project pg
    University of Ljubljana
    Copyright � 1995 LECAD. All Rights Reserved.

    SUBSYSTEM:    pg.apx Application
    FILE:         geometry.h
    AUTHOR:       CAD lab


    OVERVIEW
    ========
    Class definition for Geometry (TDialog).      
*/

#include <owl\owlpch.h>
#pragma hdrstop

#include <owl\combobox.h>
#include <owl\edit.h>

#include "pgapp.rh"            // Definition of all resources.


//{{TDialog = Geometry}}
struct GeometryXfer {
//{{GeometryXFER_DATA}}
    char    BasicRack[ 255 ];
    char    ClearCoeff[ 255 ];
    char    FaceWidth[ 255 ];
    TComboBoxData  GearQuality;
    char    HelixAngle[ 255 ];
    TComboBoxData  NormalAngle;
    TComboBoxData  NormalModul;
//{{GeometryXFER_DATA_END}}
};

struct GeomData {
        double dNorModul ;
        double dHelAng ;
        double dNorAng ;
        double dBasicRack ;
        double dCoeff ;
        double dFaceWidth ;
        double dGearQuality ;
};

class Geometry : public TDialog {
public:
    Geometry (TWindow* parent, TResId resId = IDD_GEOMETRY, TModule* module = 0);
    void GetValues( GeomData *data ) ;
        void SetValues( GeomData data ) ;
    virtual ~Geometry ();

//{{GeometryXFER_DEF}}
protected:
    TEdit *BasicRack;
    TEdit *ClearCoeff;
    TEdit *FaceWidth;
    TComboBox *GearQuality;
    TEdit *HelixAngle;
    TComboBox *NormalAngle;
    TComboBox *NormalModul;

//{{GeometryXFER_DEF_END}}

//{{GeometryVIRTUAL_BEGIN}}
public:
    virtual void SetupWindow ();
//{{GeometryVIRTUAL_END}}
};    //{{Geometry}}


#endif                                      // __geometry_h sentry.



/*  Project pg
    University of Ljubljana
    Copyright � 1995 LECAD. All Rights Reserved.

    SUBSYSTEM:    pg.apx Application
    FILE:         geometry.cpp
    AUTHOR:       CAD lab


    OVERVIEW
    ========
    Source file for implementation of Geometry (TDialog).
*/

#include <owl\owlpch.h>
#include <stdio.h>
#pragma hdrstop

#include "geometry.h"


//{{Geometry Implementation}}


static GeometryXfer GeometryData;
static int iInitDone = 0 ;
static double StandardModules[] =
        { 1, 1.125, 1.25, 1.375, 1.5, 1.75, 2, 2.25, 2.5, 2.75, 3, 3.25,
          3.5, 3.75, 4, 4.25, 4.5, 4.75, 5, 5.25, 5.5, 5.75, 6, 6.5, 7,
          8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 25, 27, 28, 30, 32, 36,
      39, 40, 42, 45, 50};

Geometry::Geometry (TWindow* parent, TResId resId, TModule* module):
    TDialog(parent, resId, module)
{
//{{GeometryXFER_USE}}
    BasicRack = new TEdit(this, IDC_ADD_BASIC, 255);
    ClearCoeff = new TEdit(this, IDC_CLEAR_COEFF, 255);
    FaceWidth = new TEdit(this, IDC_FACE_WIDTH, 255);
    GearQuality = new TComboBox(this, IDC_GEAR_QUALITY, 1);
    HelixAngle = new TEdit(this, IDC_HELIX_ANG, 255);
    NormalAngle = new TComboBox(this, IDC_NORM_ANG, 1);
    NormalModul = new TComboBox(this, IDC_NORM_MODUL, 1);

    SetTransferBuffer(&GeometryData);
//{{GeometryXFER_USE_END}}

    // INSERT>> Your constructor code here.

}


Geometry::~Geometry ()
{
    Destroy();

    // INSERT>> Your destructor code here.

}

void Geometry::GetValues( GeomData *data )
{
        data->dHelAng = atof(GeometryData.HelixAngle) ;
        data->dBasicRack = atof(GeometryData.BasicRack) ;
        data->dCoeff = atof(GeometryData.ClearCoeff) ;
        data->dFaceWidth = atof(GeometryData.FaceWidth) ;

        data->dNorModul = atof( GeometryData.NormalModul.GetSelection().c_str()) ;
        data->dNorAng = atof( GeometryData.NormalAngle.GetSelection().c_str() ) ;
        data->dGearQuality = atof( GeometryData.GearQuality.GetSelection().c_str() ) ;
}


void Geometry::SetValues( GeomData data )
{
        char buf[255] ;
        // set values for input fields
        sprintf( GeometryData.HelixAngle, "%lg", data.dHelAng ) ;
        sprintf( GeometryData.BasicRack, "%lg", data.dBasicRack ) ;
        sprintf( GeometryData.ClearCoeff, "%lg", data.dCoeff ) ;
        sprintf( GeometryData.FaceWidth, "%lg", data.dFaceWidth ) ;

        // set selected string for combo boxes
        sprintf( buf, "%lg", data.dNorModul );
        GeometryData.NormalModul.SelectString( buf ) ;
        sprintf( buf, "%lg", data.dNorAng );
        GeometryData.NormalAngle.SelectString( buf ) ;
        sprintf( buf, "%lg", data.dGearQuality );
        GeometryData.GearQuality.SelectString( buf ) ;
}


void Geometry::SetupWindow ()
{
        TDialog::SetupWindow();

        char buf[20];
        NormalModul->Clear() ;
        NormalModul->ClearList() ;
        for (int i = 0; i < (sizeof(StandardModules)/sizeof(double)); i++)
           {
                        sprintf(buf, "%lg", StandardModules[i]);
                        NormalModul->AddString( buf ) ;
           }


        NormalAngle->Clear() ;
        NormalAngle->ClearList() ;
        NormalAngle->AddString( "20" ) ;

        GearQuality->Clear() ;
        GearQuality->ClearList() ;
        GearQuality->AddString( "5" ) ;
        GearQuality->AddString( "6" ) ;
        GearQuality->AddString( "7" ) ;
        GearQuality->AddString( "8" ) ;
        GearQuality->AddString( "9" ) ;
        GearQuality->AddString( "10" ) ;

        if ( !iInitDone ) {
                // do the initialization
                NormalModul->SetSelIndex( 5 ) ;
                NormalAngle->SetSelIndex( 0 ) ;
                HelixAngle->SetText( "0.0" ) ;
                BasicRack->SetText( "1.0" );
                ClearCoeff->SetText( "0.25" );
                FaceWidth->SetText( "38.0" );
                GearQuality->SetSelIndex( 1 ) ;

                iInitDone = 1 ;                                                         // initialization was done
        } else {
                NormalModul->SetText( GeometryData.NormalModul.GetSelection().c_str() ) ;
                NormalAngle->SetText( GeometryData.NormalAngle.GetSelection().c_str() ) ;
                GearQuality->SetText( GeometryData.GearQuality.GetSelection().c_str() ) ;
    }
}



Leon Kos
Tue Dec 2 10:35:04 CET 1997