home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************/
- /* */
- /* TurboCAD for Windows */
- /* Copyright (c) 1993 - 2001 */
- /* International Microcomputer Software, Inc. */
- /* (IMSI) */
- /* All rights reserved. */
- /* */
- /******************************************************************/
-
- // TDialog1.cpp : implementation file
- //
-
- #include "stdafx.h"
- #include "instool.h"
- #include "InsSymb.h"
- #include "TDialog1.h"
- #include "ViewWnd.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CModifyDlg dialog
-
-
- CModifyDlg::CModifyDlg(CInsSymb* pTool, CWnd* pParent /*=NULL*/)
- : CDialog(CModifyDlg::IDD, pParent)
- {
- m_pTool = pTool;
- //{{AFX_DATA_INIT(CModifyDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- }
-
-
- void CModifyDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CModifyDlg)
- // NOTE: the ClassWizard will add DDX and DDV calls here
- //}}AFX_DATA_MAP
- }
-
-
- BEGIN_MESSAGE_MAP(CModifyDlg, CDialog)
- //{{AFX_MSG_MAP(CModifyDlg)
- ON_EN_CHANGE(IDC_EDITSCALEX, OnChangeEditscalex)
- ON_EN_KILLFOCUS(IDC_EDITSCALEX, OnKillfocusEditscalex)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CModifyDlg message handlers
-
- void CModifyDlg::OnOK()
- {
- // TODO: Add extra validation here
- COleVariant varOptional(varMissing);
- COleVariant varItem(0L);
-
- char textx[6];
- char texty[6];
- char tz[6];
- double x, y, z;
- double angleZ;
- angleZ = 0;
-
- IDrawing* pIDr = NULL;
- IGraphic *pIGr = NULL;
- Graphics* pGrs = NULL;
- IMatrix *pIMat = NULL;
-
- try
- {
- CPreviewWnd *pView = (CPreviewWnd *)(GetParent()->GetDlgItem(IDC_PREVIEW));
-
- HRESULT hRes = pView->m_pPreviewView->get_Drawing(&pIDr);
- CHECK_HRESULT(hRes)
-
- hRes = pIDr->get_Graphics(&pGrs);
- CHECK_HRESULT(hRes)
-
- hRes = pGrs->get_Item(&varItem, &pIGr);
- CHECK_HRESULT(hRes)
-
- x = y = z = 1;
-
- AFX_MANAGE_STATE(m_pTool->m_pTCState);
-
- COleVariant varVal(1L);
- m_AngleZ->GetLine(0, tz);
- angleZ = atof(tz); // convert text from Axis - Z edit box to double
-
- angleZ = (angleZ*3.14159265359)/180; //calculate angle in radians
-
- hRes = pIGr->RotateAxis(angleZ, varOptional, varOptional, varVal, varOptional, varOptional, varOptional, &pIMat);
- CHECK_HRESULT(hRes)
-
- if (pIMat != NULL)
- {
- pIMat->Release();
- pIMat = NULL;
- }
-
-
- hRes = pView->m_pPreviewView->ZoomToExtents();
- CHECK_HRESULT(hRes)
-
- m_ScaleX->GetLine(0, textx);
- x = atof(textx);
- if (x == 0)
- x = 1;
-
- m_ScaleY->GetLine(0, texty);
- y = atof(texty);
- if (y ==0)
- y = 1;
-
- hRes = pIGr->Scale(x, y, z, varOptional, varOptional, varOptional, &pIMat);
- CHECK_HRESULT(hRes)
-
- pView->Invalidate();
- }
- catch (...)
- {
- TRACE_EXCEPTION("CModifyDlg::OnOK")
- _clearfp();
- }
-
- if (pIMat != NULL)
- {
- pIMat->Release();
- pIMat = NULL;
- }
-
- if (pIGr != NULL)
- {
- pIGr->Release();
- pIGr = NULL;
- }
-
- if (pGrs != NULL)
- {
- pGrs->Release();
- pGrs = NULL;
- }
-
- if(pIDr != NULL)
- {
- pIDr->Release();
- pIDr = NULL;
- }
-
- CDialog::OnOK();
- }
-
- void CModifyDlg::OnCancel()
- {
- // TODO: Add extra cleanup here
-
- CDialog::OnCancel();
- }
-
- void CModifyDlg::OnChangeEditscalex()
- {
- }
-
- BOOL CModifyDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // TODO: Add extra initialization here
- m_ScaleX = (CEdit *) GetDlgItem(IDC_EDITSCALEX);
- m_ScaleX->SetLimitText(6);
- m_ScaleX->SetWindowText("1");
-
-
- m_ScaleY = (CEdit *) GetDlgItem(IDC_EDITSCALEY);
- m_ScaleY->SetLimitText(6);
- m_ScaleY->SetWindowText("1");
-
- m_ScaleZ = (CEdit *) GetDlgItem(IDC_EDITSCALEZ);
- m_ScaleZ->SetLimitText(6);
- m_ScaleZ->SetWindowText("1");
-
-
- m_AngleX = (CEdit *) GetDlgItem(IDC_EDITANGLEX);
- m_AngleX->SetLimitText(6);
- m_AngleX->SetWindowText("0");
-
- m_AngleY = (CEdit *) GetDlgItem(IDC_EDITANGLEY);
- m_AngleY->SetLimitText(6);
- m_AngleY->SetWindowText("0");
-
- m_AngleZ = (CEdit *) GetDlgItem(IDC_EDITANGLEZ);
- m_AngleZ->SetLimitText(6);
- m_AngleZ->SetWindowText("0");
-
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
-
- void CModifyDlg::OnKillfocusEditscalex()
- {
- }
-
-