home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2002 March / PCWMAR02.iso / software / turbocad / v8trial / TurboCADv8ProfessionalNoReg.exe / Data.Cab / F37603_TDialog1.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-16  |  4.7 KB  |  212 lines

  1. /******************************************************************/
  2. /*                                                                */
  3. /*                      TurboCAD for Windows                      */
  4. /*                   Copyright (c) 1993 - 2001                    */
  5. /*             International Microcomputer Software, Inc.         */
  6. /*                            (IMSI)                              */
  7. /*                      All rights reserved.                      */
  8. /*                                                                */
  9. /******************************************************************/
  10.  
  11. // TDialog1.cpp : implementation file
  12. //
  13.  
  14. #include "stdafx.h"
  15. #include "instool.h"
  16. #include "InsSymb.h"
  17. #include "TDialog1.h"
  18. #include "ViewWnd.h"
  19.  
  20. #ifdef _DEBUG
  21. #define new DEBUG_NEW
  22. #undef THIS_FILE
  23. static char THIS_FILE[] = __FILE__;
  24. #endif
  25.  
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CModifyDlg dialog
  28.  
  29.  
  30. CModifyDlg::CModifyDlg(CInsSymb* pTool, CWnd* pParent /*=NULL*/)
  31.     : CDialog(CModifyDlg::IDD, pParent)
  32. {
  33.     m_pTool = pTool;
  34.     //{{AFX_DATA_INIT(CModifyDlg)
  35.         // NOTE: the ClassWizard will add member initialization here
  36.     //}}AFX_DATA_INIT
  37. }
  38.  
  39.  
  40. void CModifyDlg::DoDataExchange(CDataExchange* pDX)
  41. {
  42.     CDialog::DoDataExchange(pDX);
  43.     //{{AFX_DATA_MAP(CModifyDlg)
  44.         // NOTE: the ClassWizard will add DDX and DDV calls here
  45.     //}}AFX_DATA_MAP
  46. }
  47.  
  48.  
  49. BEGIN_MESSAGE_MAP(CModifyDlg, CDialog)
  50.     //{{AFX_MSG_MAP(CModifyDlg)
  51.     ON_EN_CHANGE(IDC_EDITSCALEX, OnChangeEditscalex)
  52.     ON_EN_KILLFOCUS(IDC_EDITSCALEX, OnKillfocusEditscalex)
  53.     //}}AFX_MSG_MAP
  54. END_MESSAGE_MAP()
  55.  
  56. /////////////////////////////////////////////////////////////////////////////
  57. // CModifyDlg message handlers
  58.  
  59. void CModifyDlg::OnOK() 
  60. {
  61.     // TODO: Add extra validation here
  62.     COleVariant varOptional(varMissing);
  63.     COleVariant varItem(0L);
  64.  
  65.     char textx[6];
  66.     char texty[6];
  67.     char tz[6];
  68.     double x, y, z;
  69.     double angleZ;
  70.     angleZ = 0;
  71.  
  72.     IDrawing* pIDr = NULL;
  73.     IGraphic *pIGr = NULL;
  74.     Graphics* pGrs = NULL;
  75.     IMatrix *pIMat = NULL;
  76.     
  77.     try
  78.     {
  79.         CPreviewWnd *pView = (CPreviewWnd *)(GetParent()->GetDlgItem(IDC_PREVIEW));
  80.  
  81.         HRESULT hRes = pView->m_pPreviewView->get_Drawing(&pIDr);
  82.         CHECK_HRESULT(hRes)
  83.             
  84.         hRes = pIDr->get_Graphics(&pGrs);
  85.         CHECK_HRESULT(hRes)
  86.         
  87.         hRes = pGrs->get_Item(&varItem, &pIGr);
  88.         CHECK_HRESULT(hRes)
  89.  
  90.         x = y = z = 1;
  91.  
  92.         AFX_MANAGE_STATE(m_pTool->m_pTCState);
  93.  
  94.         COleVariant varVal(1L);
  95.         m_AngleZ->GetLine(0, tz);
  96.         angleZ = atof(tz); // convert text from Axis - Z edit box to double
  97.  
  98.         angleZ = (angleZ*3.14159265359)/180; //calculate angle in radians
  99.     
  100.         hRes = pIGr->RotateAxis(angleZ, varOptional, varOptional, varVal, varOptional, varOptional, varOptional, &pIMat);
  101.         CHECK_HRESULT(hRes)
  102.  
  103.         if (pIMat != NULL)
  104.         {
  105.             pIMat->Release();
  106.             pIMat = NULL;
  107.         }
  108.             
  109.             
  110.         hRes = pView->m_pPreviewView->ZoomToExtents();
  111.         CHECK_HRESULT(hRes)
  112.  
  113.         m_ScaleX->GetLine(0, textx);
  114.         x = atof(textx);
  115.         if (x == 0)
  116.             x = 1;
  117.  
  118.         m_ScaleY->GetLine(0, texty);
  119.         y = atof(texty);
  120.         if (y ==0)
  121.             y = 1;
  122.  
  123.         hRes = pIGr->Scale(x, y, z, varOptional, varOptional, varOptional, &pIMat);
  124.         CHECK_HRESULT(hRes)
  125.             
  126.         pView->Invalidate();
  127.     }
  128.     catch (...)
  129.     {
  130.         TRACE_EXCEPTION("CModifyDlg::OnOK")
  131.         _clearfp();
  132.     }
  133.  
  134.     if (pIMat != NULL)
  135.     {
  136.         pIMat->Release();
  137.         pIMat = NULL;
  138.     }
  139.     
  140.     if (pIGr != NULL)
  141.     {
  142.         pIGr->Release();
  143.         pIGr = NULL;
  144.     }
  145.     
  146.     if (pGrs != NULL)
  147.     {
  148.         pGrs->Release();
  149.         pGrs = NULL;
  150.     }
  151.  
  152.     if(pIDr != NULL)
  153.     {
  154.         pIDr->Release();
  155.         pIDr = NULL;
  156.     }
  157.  
  158.     CDialog::OnOK();
  159. }
  160.  
  161. void CModifyDlg::OnCancel() 
  162. {
  163.     // TODO: Add extra cleanup here
  164.     
  165.     CDialog::OnCancel();
  166. }
  167.  
  168. void CModifyDlg::OnChangeEditscalex() 
  169. {
  170. }
  171.  
  172. BOOL CModifyDlg::OnInitDialog() 
  173. {
  174.     CDialog::OnInitDialog();
  175.     
  176.     // TODO: Add extra initialization here
  177.     m_ScaleX = (CEdit *) GetDlgItem(IDC_EDITSCALEX);
  178.     m_ScaleX->SetLimitText(6);
  179.     m_ScaleX->SetWindowText("1");
  180.     
  181.  
  182.     m_ScaleY = (CEdit *) GetDlgItem(IDC_EDITSCALEY);
  183.     m_ScaleY->SetLimitText(6);
  184.     m_ScaleY->SetWindowText("1");
  185.     
  186.     m_ScaleZ = (CEdit *) GetDlgItem(IDC_EDITSCALEZ);
  187.     m_ScaleZ->SetLimitText(6);
  188.     m_ScaleZ->SetWindowText("1");
  189.  
  190.     
  191.     m_AngleX = (CEdit *) GetDlgItem(IDC_EDITANGLEX);
  192.     m_AngleX->SetLimitText(6);
  193.     m_AngleX->SetWindowText("0");
  194.     
  195.     m_AngleY = (CEdit *) GetDlgItem(IDC_EDITANGLEY);
  196.     m_AngleY->SetLimitText(6);
  197.     m_AngleY->SetWindowText("0");
  198.     
  199.     m_AngleZ = (CEdit *) GetDlgItem(IDC_EDITANGLEZ);
  200.     m_AngleZ->SetLimitText(6);
  201.     m_AngleZ->SetWindowText("0");
  202.  
  203.  
  204.     return TRUE;  // return TRUE unless you set the focus to a control
  205.                   // EXCEPTION: OCX Property Pages should return FALSE
  206. }
  207.  
  208. void CModifyDlg::OnKillfocusEditscalex() 
  209. {
  210. }
  211.  
  212.