void CDlgPgInfoAttachingPlacement::DoDataExchange(CDataExchange* pDX) { CPropertyPage::DoDataExchange(pDX); CModelerView *pModelerView = CModelerView::GetActiveView(); if(pModelerView == NULL) return; CModelerDoc* pDoc = pModelerView->GetDocument(); CModelData *pMD = &pDoc->m_emEditModel.edm_md; INDEX ctPositions = pDoc->m_emEditModel.edm_aamAttachedModels.Count(); if( (m_iActivePlacement == -1) && ( ctPositions != 0) ) m_iActivePlacement = 0; if( m_iActivePlacement >= ctPositions) { if( ctPositions != 0) m_iActivePlacement = 0; else m_iActivePlacement = -1; } // if transfering data from document to dialog if( !pDX->m_bSaveAndValidate) { BOOL bAttachmentExists = ( m_iActivePlacement != -1); GetDlgItem( IDC_ATTACHING_PLACEMENT_INDEX_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_PREVIOUS_ATTACHING_PLACEMENT )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_NAME )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_NEXT_ATTACHING_PLACEMENT )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_REMOVE_ATTACHING_PLACEMENT )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_X_OFFSET_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_X_OFFSET )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_Y_OFFSET_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_Y_OFFSET )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_Z_OFFSET_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_Z_OFFSET )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_HEADING_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_HEADING )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_PITCH_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_PITCH )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_BANKING_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_BANKING )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_IS_VISIBLE )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_BROWSE_MODEL )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_MODEL_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_MODEL_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_MODEL_ANIMATION_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHMENT_MODEL_ANIMATION_COMBO)->EnableWindow( bAttachmentExists); GetDlgItem( IDC_VERTICES_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_VERTICES )->EnableWindow( bAttachmentExists); if( bAttachmentExists) { pMD->md_aampAttachedPosition.Lock(); pDoc->m_emEditModel.edm_aamAttachedModels.Lock(); CPlacement3D plCurrent = pMD->md_aampAttachedPosition[ m_iActivePlacement].amp_plRelativePlacement; m_fHeading = DegAngle( plCurrent.pl_OrientationAngle(1)); m_fPitch = DegAngle( plCurrent.pl_OrientationAngle(2)); m_fBanking = DegAngle( plCurrent.pl_OrientationAngle(3)); m_fXOffset = plCurrent.pl_PositionVector(1); m_fYOffset = plCurrent.pl_PositionVector(2); m_fZOffset = plCurrent.pl_PositionVector(3); CAttachedModel *pam = &pDoc->m_emEditModel.edm_aamAttachedModels[ m_iActivePlacement]; m_strName = pam->am_strName; m_strAttachingModel = pam->am_moAttachedModel.GetName(); char achrLine[ 256]; sprintf( achrLine, "center:%d, front:%d, up:%d", pMD->md_aampAttachedPosition[ m_iActivePlacement].amp_iCenterVertex, pMD->md_aampAttachedPosition[ m_iActivePlacement].amp_iFrontVertex, pMD->md_aampAttachedPosition[ m_iActivePlacement].amp_iUpVertex); m_strAttachingVertices = achrLine; sprintf( achrLine, "%d.", m_iActivePlacement); m_strPlacementIndex = achrLine; m_bIsVisible = pDoc->m_emEditModel.edm_aamAttachedModels[ m_iActivePlacement].am_bVisible != 0; pDoc->m_emEditModel.edm_aamAttachedModels.Unlock(); pMD->md_aampAttachedPosition.Unlock(); if( IsWindow( m_comboAttachmentModelAnimation.m_hWnd)) { m_comboAttachmentModelAnimation.EnableWindow( m_bIsVisible); FillAttachmentModelAnimationCombo(); } // mark that the values have been updated to reflect the state of the view m_udAllValues.MarkUpdated(); } } //{{AFX_DATA_MAP(CDlgPgInfoAttachingPlacement) DDX_Control(pDX, IDC_ATTACHMENT_MODEL_ANIMATION_COMBO, m_comboAttachmentModelAnimation); DDX_Text(pDX, IDC_ATTACHING_PLACEMENT_BANKING, m_fBanking); DDX_Text(pDX, IDC_ATTACHING_PLACEMENT_HEADING, m_fHeading); DDX_Text(pDX, IDC_ATTACHING_PLACEMENT_PITCH, m_fPitch); DDX_Text(pDX, IDC_ATTACHING_PLACEMENT_X_OFFSET, m_fXOffset); DDX_Text(pDX, IDC_ATTACHING_PLACEMENT_Y_OFFSET, m_fYOffset); DDX_Text(pDX, IDC_ATTACHING_PLACEMENT_Z_OFFSET, m_fZOffset); DDX_Text(pDX, IDC_ATTACHING_PLACEMENT_NAME, m_strName); DDX_Text(pDX, IDC_ATTACHING_MODEL_T, m_strAttachingModel); DDX_Text(pDX, IDC_ATTACHING_VERTICES, m_strAttachingVertices); DDX_Text(pDX, IDC_ATTACHING_PLACEMENT_INDEX_T, m_strPlacementIndex); DDX_Check(pDX, IDC_IS_VISIBLE, m_bIsVisible); //}}AFX_DATA_MAP // if transfering data from dialog to document if( pDX->m_bSaveAndValidate) { if( m_iActivePlacement == -1) return; pMD->md_aampAttachedPosition.Lock(); pDoc->m_emEditModel.edm_aamAttachedModels.Lock(); CPlacement3D plCurrent; plCurrent.pl_OrientationAngle(1) = AngleDeg( m_fHeading); plCurrent.pl_OrientationAngle(2) = AngleDeg( m_fPitch); plCurrent.pl_OrientationAngle(3) = AngleDeg( m_fBanking); plCurrent.pl_PositionVector(1) = m_fXOffset; plCurrent.pl_PositionVector(2) = m_fYOffset; plCurrent.pl_PositionVector(3) = m_fZOffset; pMD->md_aampAttachedPosition[ m_iActivePlacement].amp_plRelativePlacement = plCurrent; pDoc->m_emEditModel.edm_aamAttachedModels[ m_iActivePlacement].am_strName = CStringA(m_strName); pDoc->m_emEditModel.edm_aamAttachedModels[ m_iActivePlacement].am_bVisible = m_bIsVisible; pDoc->m_emEditModel.edm_aamAttachedModels.Unlock(); pMD->md_aampAttachedPosition.Unlock(); pDoc->ClearAttachments(); pDoc->SetupAttachments(); pDoc->SetModifiedFlag(); pDoc->UpdateAllViews( NULL); } }
void CDlgPgPosition::DoDataExchange(CDataExchange* pDX) { if( theApp.m_bDisableDataExchange) return; CPropertyPage::DoDataExchange(pDX); SetModified( TRUE); // obtain document CWorldEditorDoc* pDoc = theApp.GetDocument(); // if document doesn't exist, return if( pDoc == NULL) return; // get active view CWorldEditorView *pWorldEditorView = theApp.GetActiveView(); // if dialog is recieving data if( pDX->m_bSaveAndValidate == FALSE) { // is CSG on? if( pDoc->m_pwoSecondLayer != NULL) { // yes, pick up coordinates for editting from second layer m_fHeading = DegAngle( pDoc->m_plSecondLayer.pl_OrientationAngle(1)); m_fPitch = DegAngle( pDoc->m_plSecondLayer.pl_OrientationAngle(2)); m_fBanking = DegAngle( pDoc->m_plSecondLayer.pl_OrientationAngle(3)); m_fX = pDoc->m_plSecondLayer.pl_PositionVector(1); m_fY = pDoc->m_plSecondLayer.pl_PositionVector(2); m_fZ = pDoc->m_plSecondLayer.pl_PositionVector(3); } // otherwise if we are in entity mode and there is only one entity selected else if( (pDoc->m_iMode == ENTITY_MODE) && ( pDoc->m_selEntitySelection.Count() == 1) ) { // lock selection's dynamic container pDoc->m_selEntitySelection.Lock(); // get first entity CEntity *penEntityOne = pDoc->m_selEntitySelection.Pointer(0); // unlock selection's dynamic container pDoc->m_selEntitySelection.Unlock(); // get placement of first entity CPlacement3D plEntityOnePlacement = penEntityOne->GetPlacement(); m_fHeading = DegAngle( plEntityOnePlacement.pl_OrientationAngle(1)); m_fPitch = DegAngle( plEntityOnePlacement.pl_OrientationAngle(2)); m_fBanking = DegAngle( plEntityOnePlacement.pl_OrientationAngle(3)); m_fX = plEntityOnePlacement.pl_PositionVector(1); m_fY = plEntityOnePlacement.pl_PositionVector(2); m_fZ = plEntityOnePlacement.pl_PositionVector(3); } m_udSelection.MarkUpdated(); } //{{AFX_DATA_MAP(CDlgPgPosition) DDX_Text(pDX, IDC_EDIT_BANKING, m_fBanking); DDX_Text(pDX, IDC_EDIT_HEADING, m_fHeading); DDX_Text(pDX, IDC_EDIT_PITCH, m_fPitch); DDX_Text(pDX, IDC_EDIT_X, m_fX); DDX_Text(pDX, IDC_EDIT_Y, m_fY); DDX_Text(pDX, IDC_EDIT_Z, m_fZ); //}}AFX_DATA_MAP // if dialog is giving data if( pDX->m_bSaveAndValidate != FALSE) { // is CSG on? if( pDoc->m_pwoSecondLayer != NULL) { // yes, copy coordinates from editting controls into second layer pDoc->m_plSecondLayer.pl_OrientationAngle(1) = AngleDeg( m_fHeading); pDoc->m_plSecondLayer.pl_OrientationAngle(2) = AngleDeg( m_fPitch); pDoc->m_plSecondLayer.pl_OrientationAngle(3) = AngleDeg( m_fBanking); pDoc->m_plSecondLayer.pl_PositionVector(1) = m_fX; pDoc->m_plSecondLayer.pl_PositionVector(2) = m_fY; pDoc->m_plSecondLayer.pl_PositionVector(3) = m_fZ; // snap values to grid pDoc->SnapToGrid( pDoc->m_plSecondLayer, SNAP_FLOAT_12); theApp.m_vfpCurrent.vfp_plPrimitive = pDoc->m_plSecondLayer; // update all document's views pDoc->UpdateAllViews( NULL); } // otherwise if we are in entity mode else if( pDoc->m_iMode == ENTITY_MODE) { // there must be only one entity selected ASSERT( pDoc->m_selEntitySelection.Count() == 1); // lock selection's dynamic container pDoc->m_selEntitySelection.Lock(); // get first entity CEntity *penEntityOne = pDoc->m_selEntitySelection.Pointer(0); // unlock selection's dynamic container pDoc->m_selEntitySelection.Unlock(); // get placement of first entity CPlacement3D plEntityOnePlacement = penEntityOne->GetPlacement(); plEntityOnePlacement.pl_OrientationAngle(1) = AngleDeg( m_fHeading); plEntityOnePlacement.pl_OrientationAngle(2) = AngleDeg( m_fPitch); plEntityOnePlacement.pl_OrientationAngle(3) = AngleDeg( m_fBanking); plEntityOnePlacement.pl_PositionVector(1) = m_fX; plEntityOnePlacement.pl_PositionVector(2) = m_fY; plEntityOnePlacement.pl_PositionVector(3) = m_fZ; // snap entity's placement pDoc->SnapToGrid( plEntityOnePlacement, SNAP_FLOAT_12); // set placement back to entity penEntityOne->SetPlacement( plEntityOnePlacement); pDoc->SetModifiedFlag( TRUE); pDoc->UpdateAllViews( NULL); m_udSelection.MarkUpdated(); // update all document's views pDoc->UpdateAllViews( NULL); } } }