#include #include "stdafx.h" #include "acp_base.h" #include "ITF.h" #include "caminter.hpp" #include "camresrc.h" //******************************************************************************************************** //******************************************************************************************************** //******************************************************************************************************** void Camera_Interface::SendDialogBarCommandToCamera(CPA_BaseObject *_p_oCamera,UINT nID) { Camera *p_oCamera; ASSERT(_p_oCamera != NULL); p_oCamera = (Camera*)_p_oCamera; ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName)); p_oCamera->GetDialogBar()->OnCommand(nID); } //******************************************************************************************************** //******************************************************************************************************** //******************************************************************************************************** void Camera_Interface::ShowDialogBar(CPA_BaseObject *_p_oCamera) { Camera *p_oCamera; ASSERT(_p_oCamera != NULL); p_oCamera = (Camera*)_p_oCamera; ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName)); p_oCamera->GetDialogBar()->Show(); } //******************************************************************************************************** //******************************************************************************************************** //******************************************************************************************************** void Camera_Interface::HideDialogBar(CPA_BaseObject *_p_oCamera) { Camera *p_oCamera; ASSERT(_p_oCamera != NULL); p_oCamera = (Camera*)_p_oCamera; ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName)); p_oCamera->GetDialogBar()->Hide(); } //******************************************************************************************************** //******************************************************************************************************** //******************************************************************************************************** BOOL Camera_Interface::OnToolTipNotify (CPA_BaseObject *_p_oCamera, TOOLTIPTEXT *p_TTT, UINT nID) { Camera *p_oCamera; ASSERT(_p_oCamera != NULL); p_oCamera = (Camera*)_p_oCamera; ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName)); return p_oCamera->GetDialogBar()->GetToolTipText(p_TTT,nID); } //================================================================================================== //================================================================================================== //================================================================================================== //================================================================================================== //================================================================================================== //================================================================================================== //================================================================================================== //================================================================================================== //================================================================================================== //================================================================================================== //================================================================================================== //================================================================================================== //================================================================================================== //================================================================================================== //================================================================================================== //================================================================================================== //================================================================================================== //================================================================================================== //================================================================================================== //================================================================================================== //================================================================================================== //******************************************************************************************************** //******************************************************************************************************** //******************************************************************************************************** DialogBar::DialogBar() { m_p_oParentWnd = NULL; m_p_oCamera = NULL; m_p_oInterface = NULL; } //******************************************************************************************************** //******************************************************************************************************** //******************************************************************************************************** DialogBar::DialogBar(DialogBar& r_src) : m_oToolBar(r_src.m_oToolBar) { m_p_oParentWnd = NULL; m_p_oCamera = NULL; m_p_oInterface = NULL; } //******************************************************************************************************** //******************************************************************************************************** //******************************************************************************************************** void DialogBar::SetCamera(Camera *p_oCamera) { m_p_oCamera = p_oCamera; m_p_oInterface = (Camera_Interface*) p_oCamera->GetEditor(); } //******************************************************************************************************** //******************************************************************************************************** //******************************************************************************************************** void DialogBar::InitInertCameraDialogBar(Camera *p_oCamera) { //ToolBar definition tdstButtonDef a_stButtonDef[] = { {ID_FREEVIEW, TRUE, "Select Camera View"}, {ID_FRONTVIEW, FALSE, "Front View"}, {ID_RIGHTVIEW, FALSE, "Right View"}, {ID_LEFTVIEW, FALSE, "Left View"}, {ID_TOPVIEW, FALSE, "Top View"}, {ID_BOTTOMVIEW, FALSE, "Bottom View"}, {ID_BACKVIEW, FALSE, "Back View"}, {ID_ENDFAMILY, FALSE, ""}, {ID_NOTTARGETED,TRUE, "Target : None"}, {ID_POINTTARGETED,TRUE, "Target : Point"}, {ID_SOTARGETED,TRUE, "Target : Object"}, {ID_ENDFAMILY, FALSE, ""}, {ID_PREFERENCES,TRUE, "Settings"}, {ID_ENDFAMILY, FALSE, ""}, {ID_SELECTCAMERA,TRUE, "Select Camera Slot"}, {ID_ENDFAMILY, FALSE, ""}, {ID_SAVECAMERA,TRUE, "Get New Camera Slot"}, {ID_ENDFAMILY, FALSE, ""}, }; m_oToolBar.Define(a_stButtonDef,18,IDR_CAMERATB,ID_ENDFAMILY,18,18); m_oToolBar.SetVisibility(ID_FREEVIEW,FALSE); m_oToolBar.SetInitialPermission(ID_SOTARGETED,FALSE); m_oToolBar.SetPermission(ID_SOTARGETED,FALSE); //camera definition m_p_oCamera = p_oCamera; m_p_oInterface = (Camera_Interface*) p_oCamera->GetEditor(); } //******************************************************************************************************** //******************************************************************************************************** //******************************************************************************************************** void DialogBar::Hide() { if (m_p_oParentWnd != NULL) { m_oToolBar.ShowWindow(SW_HIDE); m_p_oParentWnd->m_p_oCamera = NULL; } } //******************************************************************************************************** //******************************************************************************************************** //******************************************************************************************************** void DialogBar::Show() { if (!M_bEditorsActive()) return; if (m_p_oParentWnd != NULL) { m_oToolBar.ShowWindow(SW_SHOW); m_p_oParentWnd->m_p_oCamera = m_p_oCamera; } } //******************************************************************************************************** //******************************************************************************************************** //******************************************************************************************************** BOOL DialogBar::GetToolTipText(TOOLTIPTEXT *p_TTT, UINT nID) { return m_oToolBar.GetToolTipText(p_TTT,nID); } //******************************************************************************************************** //******************************************************************************************************** //******************************************************************************************************** void DialogBar::Create(CPA_DialogBar *p_oPopUpParent, CPoint oPos) { //if a window was given for ToolBar if (p_oPopUpParent != NULL && p_oPopUpParent->m_hWnd != NULL) { if (m_p_oParentWnd == NULL) { // the dialog bar has not been created yet for this window... // create toolbar m_oToolBar.CreateToolBarCtrl(p_oPopUpParent,oPos); m_p_oParentWnd = p_oPopUpParent; } else { // the dialog bar has already been created, check if it's the same window ASSERT(m_p_oParentWnd == p_oPopUpParent); } } } //******************************************************************************************************** //******************************************************************************************************** //******************************************************************************************************** void DialogBar::Destroy() { // detach toolbar from its window if (m_p_oParentWnd != NULL) { m_oToolBar.DestroyWindow(); m_p_oParentWnd->m_p_oCamera = NULL; m_p_oParentWnd = NULL; } } //******************************************************************************************************** //******************************************************************************************************** //******************************************************************************************************** void DialogBar::OnCommand(UINT nID) { CPA_CameraSlots *p_oCameraSlot; DEV_ViewPort3D *p_oFocusViewport; // get the focus viewport p_oFocusViewport = m_p_oCamera->GetViewport(); // get the camera slots p_oCameraSlot = p_oFocusViewport->GetParentMultiDevice3D()->GetWorld()->GetCameraSlots(); switch(nID) { case ID_FREEVIEW: break; case ID_FRONTVIEW: m_p_oCamera->FrontView(); break; case ID_RIGHTVIEW: m_p_oCamera->RightView(); break; case ID_LEFTVIEW: m_p_oCamera->LeftView(); break; case ID_TOPVIEW: m_p_oCamera->TopView(); break; case ID_BOTTOMVIEW: m_p_oCamera->BottomView(); break; case ID_BACKVIEW: m_p_oCamera->BackView(); break; case ID_NOTTARGETED: m_p_oCamera->SetTargetType(tNone); break; case ID_POINTTARGETED: m_p_oCamera->SetTargetType(tPoint); m_p_oCamera->Update(); m_p_oInterface->GetInterface()->fn_vUpdateAll(E_mc_JustDraw); break; case ID_SOTARGETED: m_p_oCamera->SetTargetType(tSuperObject); m_p_oCamera->Update(); m_p_oInterface->GetInterface()->fn_vUpdateAll(E_mc_JustDraw); break; case ID_PREFERENCES: m_p_oCamera->Preferences(); break; case ID_SELECTCAMERA: { Camera *p_oCamera; Camera_Interface *p_oInterface; //Stefan Dumitrean 22-06-98 ( slots ) long lSlotNum; // let the user choose a slot camera from a popup menu p_oCamera = (Camera*)p_oCameraSlot->GetCameraFromPopUpMenu(lSlotNum,m_p_oParentWnd,MakeACopy); //End Stefan Dumitrean 22-06-98 ( slots ) //and set this new camera in the focus viewport // the old camera (if any) is totally destroyed if (p_oCamera != NULL) { CPA_SuperObject *p_oCameraSO,*p_oOldCameraSO; //Stefan Dumitrean 29-06-98 ( slots ) // get or build a superobject for this camera if( p_oCameraSlot->IsSpecialSlot(lSlotNum)) p_oOldCameraSO = p_oFocusViewport->GetCameraSO( ); else { p_oCameraSO = m_p_oInterface->AssociateSuperObject(p_oCamera); // put this camera in the viewport p_oOldCameraSO = p_oFocusViewport->ChangeCamera(p_oCameraSO); } //End Stefan Dumitrean 29-06-98 ( slots ) //Stefan Dumitrean 22-06-98 ( slots ) // if normal slot, save the camera position in the current slot if (!p_oCameraSlot->IsSpecialSlot( p_oCameraSlot->GetCurrentSlot())) p_oCameraSlot->SaveCameraInSlot(p_oCameraSlot->GetCurrentSlot(),"",p_oOldCameraSO->GetObject(),MakeACopy); // special slot : ask for save in a new slot else { if (AfxMessageBox("The current slot is the default one. \n Do you want to save it in a new slot ?", MB_ICONWARNING|MB_OKCANCEL) == IDOK) { Camera_NewSlot oDialog; CString csName; long lSlotNumber = p_oCameraSlot->FindFirstEmptySlot(); csName.Format("Default Slot %i", lSlotNumber); HINSTANCE hOldInst = AfxGetResourceHandle(); AfxSetResourceHandle( m_p_oInterface->GetDLLIdentity()->hModule ); // call dialog to find new name if (oDialog.fn_iDoDialog(csName, TRUE) == IDOK) { if( lSlotNumber >= 0 ) p_oCameraSlot->SaveCameraInSlot(lSlotNumber,oDialog.GetName(),p_oOldCameraSO->GetObject(),MakeACopy); else p_oCameraSlot->SaveCameraInSlot(-1,oDialog.GetName(),p_oOldCameraSO->GetObject(),MakeACopy); } AfxSetResourceHandle( hOldInst ); } } m_p_oInterface->SaveSlotsPositions(); if (p_oCameraSlot->IsSpecialSlot(lSlotNum) || !p_oCameraSlot->IsSlotReserved(lSlotNum)) p_oCameraSlot->SetCurrentSlot(lSlotNum); //End Stefan Dumitrean 22-06-98 ( slots ) //Stefan Dumitrean 26-06-98 ( slots ) if (!p_oCameraSlot->IsSpecialSlot(lSlotNum)) { // keep in memory the interface, because if I destroy the old camera,I destroy "THIS" p_oInterface = m_p_oInterface; // remove the old camera from the hierarchy, and destroy it m_p_oInterface->DestroyCamera(p_oOldCameraSO); // and put the new camera in the hierarchy p_oInterface->InsertCameraInHierarchy(p_oCameraSO); //restore the editor and selection saved with the slot 2-07-98 if (!p_oCameraSlot->IsSlotReserved(lSlotNum)) { p_oCameraSlot->SetCurrentEditorForSlotNr(lSlotNum); p_oCameraSlot->SetCurrentSelectionForSlotNr(lSlotNum); } p_oCamera->GetMainWorld()->GetInterface()->fn_vUpdateAll(E_mc_JustDraw); } //End Stefan Dumitrean 26-06-98 ( slots ) } } break; case ID_SAVECAMERA: { HINSTANCE hOldInst = AfxGetResourceHandle(); AfxSetResourceHandle( m_p_oInterface->GetDLLIdentity()->hModule ); Camera_NewSlot oDialog; CString csName; long lNewSlot; //Stefan Dumitrean 22-06-98 ( slots ) // special slot if (p_oCameraSlot->IsSpecialSlot(p_oCameraSlot->GetCurrentSlot())) { if (AfxMessageBox("The current slot is the default one. \n Do you want to save it in a new slot ?", MB_ICONWARNING|MB_OKCANCEL) == IDOK) { long lNewSlot = p_oCameraSlot->FindFirstEmptySlot(); csName.Format("Default Slot %i", lNewSlot); // call dialog to find new name if (oDialog.fn_iDoDialog(csName, TRUE) == IDOK) { if( lNewSlot >= 0 ) p_oCameraSlot->SaveCameraInSlot(lNewSlot,oDialog.GetName(),m_p_oCamera,MakeACopy); else p_oCameraSlot->SaveCameraInSlot(-1,oDialog.GetName(),m_p_oCamera,MakeACopy); // set new current slot p_oCameraSlot->SetCurrentSlot(lNewSlot); } } } // get an empty slot lNewSlot = p_oCameraSlot->FindFirstEmptySlot(); csName.Format("Slot %i", lNewSlot); // call dialog to find new name if (oDialog.fn_iDoDialog(csName) == IDOK) { long lSlotNum = p_oCameraSlot->SaveCameraInSlot(lNewSlot,oDialog.GetName(),m_p_oCamera,MakeACopy); // save the camera position in the current slot if( !p_oCameraSlot->IsSpecialSlot(p_oCameraSlot->GetCurrentSlot())) p_oCameraSlot->SaveCameraInSlot(p_oCameraSlot->GetCurrentSlot(),"",m_p_oCamera,MakeACopy); // update current slot if (!p_oCameraSlot->IsSlotReserved(lSlotNum)) p_oCameraSlot->SetCurrentSlot(lSlotNum); } //BEGIN CPA2 Laurentiu Barza 24-03-98 m_p_oInterface->SaveSlotsPositions(); //END CPA2 Laurentiu Barza 24-03-98 AfxSetResourceHandle( hOldInst ); } break; default: break; } p_oFocusViewport->SetFocus(); } //################################################################################# // Camera_NewSlot dialog //################################################################################# /*---------------------------------------- ----------------------------------------*/ Camera_NewSlot::Camera_NewSlot (CWnd* pParent) : CDialog (Camera_NewSlot::IDD, &g_oBaseFrame) { //{{AFX_DATA_INIT(Camera_NewSlot) //}}AFX_DATA_INIT } /*---------------------------------------- ----------------------------------------*/ void Camera_NewSlot::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(Camera_NewSlot) DDX_Control(pDX, IDC_SLOT_NAME, m_cNewName); //}}AFX_DATA_MAP } /*---------------------------------------- ----------------------------------------*/ BEGIN_MESSAGE_MAP(Camera_NewSlot, CDialog) //{{AFX_MSG_MAP(Camera_NewSlot) //}}AFX_MSG_MAP END_MESSAGE_MAP() /*---------------------------------------- ----------------------------------------*/ int Camera_NewSlot::fn_iDoDialog (CString _csName, BOOL bDefault) { // create the dialog m_csName = _csName; m_bDefault = bDefault; return DoModal(); } /*---------------------------------------- ----------------------------------------*/ BOOL Camera_NewSlot::OnInitDialog (void) { // Create the dialog CDialog::OnInitDialog(); // init window text if (!m_bDefault) SetWindowText("CREATE NEW SLOT"); else SetWindowText("REGISTER DEFAULT SLOT"); // init name m_cNewName.SetWindowText(m_csName); return TRUE; } /*---------------------------------------- ----------------------------------------*/ void Camera_NewSlot::OnOK (void) { // get new name m_cNewName.GetWindowText(m_csName); // close dialog CDialog::OnOK(); } /*---------------------------------------- ----------------------------------------*/ void Camera_NewSlot::OnCancel (void) { // get new name m_cNewName.GetWindowText(m_csName); // close dialog CDialog::OnCancel(); }