void CNuGenDimensionDoc::OnSTLImport() { CString Path; CFileDialog dlg( TRUE, NULL, // Open File Dialog _T("*.stl"), // Default extension OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, // No default filename _T("STL (*.stl)|*.stl||"));// Filter string if (dlg.DoModal() != IDOK) return; Path = dlg.GetPathName(); GetDocTemplate()->OpenDocumentFile(NULL); sgFileManager::ImportSTL(sgGetScene(),Path.GetBuffer()); POSITION pos = GetFirstViewPosition(); while (pos != NULL) { CView* pView = GetNextView(pos); pView->OnInitialUpdate(); } //AfxMessageBox("Sorry, its DEMO"); }
void CInputDoc::OnFileSaveAs() { CDocTemplate* pDT = GetDocTemplate(); CString sFileTypeName; pDT->GetDocString(sFileTypeName, CDocTemplate::regFileTypeName); CString sFilter; pDT-> GetDocString(sFilter, CDocTemplate::filterName); CString sExt;//="txt"; pDT-> GetDocString(sExt, CDocTemplate::filterExt); sFilter += "|*"; sFilter += sExt; sFilter+= "||"; CFileDialog dlg( FALSE, sExt, this->GetPathName(), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, sFilter, NULL ); //CString sPrompt("Save As"); //char* lpszPrompt = new char[sPrompt.GetLength()+1]; //strcpy(lpszPrompt, sPrompt); dlg.m_ofn.lpstrTitle = "Save As";//lpszPrompt; if(IDOK == dlg.DoModal()) { this->SetPathName(dlg.GetPathName()); OnSaveDocument(dlg.GetPathName()); } }
BOOL COleLinkingDoc::RegisterIfServerAttached(LPCTSTR lpszPathName, BOOL bMessage) { ASSERT_VALID(this); ASSERT(lpszPathName == NULL || AfxIsValidString(lpszPathName)); CDocTemplate* pTemplate = GetDocTemplate(); ASSERT_VALID(pTemplate); COleObjectFactory* pFactory = (COleObjectFactory*)pTemplate->m_pAttachedFactory; if (pFactory != NULL) { // always attach the document to the server at this time ASSERT_KINDOF(COleObjectFactory, pFactory); m_pFactory = pFactory; // register with OLE Server if (!Register(pFactory, lpszPathName)) { if (bMessage) { // only report error when message box allowed ReportSaveLoadException(lpszPathName, NULL, FALSE, AFX_IDP_FAILED_TO_NOTIFY); } return FALSE; } } return TRUE; }
BOOL CDocument::DoSave(LPCTSTR lpszPathName, BOOL bReplace) // Save the document data to a file // lpszPathName = path name where to save document file // if lpszPathName is NULL then the user will be prompted (SaveAs) // note: lpszPathName can be different than 'm_strPathName' // if 'bReplace' is TRUE will change file name if successful (SaveAs) // if 'bReplace' is FALSE will not change path name (SaveCopyAs) { CString newName = lpszPathName; if (newName.IsEmpty()) { CDocTemplate* pTemplate = GetDocTemplate(); ASSERT(pTemplate != NULL); newName = m_strPathName; if (bReplace && newName.IsEmpty()) { newName = m_strTitle; // check for dubious filename int iBad = newName.FindOneOf(_T(":/\\")); if (iBad != -1) newName.ReleaseBuffer(iBad); // append the default suffix if there is one CString strExt; if (pTemplate->GetDocString(strExt, CDocTemplate::filterExt) && !strExt.IsEmpty()) { ASSERT(strExt[0] == '.'); int iStart = 0; newName += strExt.Tokenize(_T(";"), iStart); } } if (!AfxGetApp()->DoPromptFileName(newName, bReplace ? AFX_IDS_SAVEFILE : AFX_IDS_SAVEFILECOPY, OFN_HIDEREADONLY | OFN_PATHMUSTEXIST, FALSE, pTemplate)) return FALSE; // don't even attempt to save } CWaitCursor wait; if (!OnSaveDocument(newName)) { if (lpszPathName == NULL) { // be sure to delete the file TRY { CFile::Remove(newName); } CATCH_ALL(e) { TRACE(traceAppMsg, 0, "Warning: failed to delete file after failed SaveAs.\n"); DELETE_EXCEPTION(e); } END_CATCH_ALL } return FALSE; }
void CGenViewerCtrl::OnDocumentNameChanged(void) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); // TODO: Add your property handler code here GetDocTemplate()->OpenDocumentFile(m_documentName); SetModifiedFlag(); }
// modified from doccore.cpp BOOL CBonfireDoc::DoSave(LPCTSTR lpszPathName, BOOL bReplace) // Save the document data to a file // lpszPathName = path name where to save document file // if lpszPathName is NULL then the user will be prompted (SaveAs) // note: lpszPathName can be different than 'm_strPathName' // if 'bReplace' is TRUE will change file name if successful (SaveAs) // if 'bReplace' is FALSE will not change path name (SaveCopyAs) { CString newName = lpszPathName; if (newName.IsEmpty()) { CDocTemplate* pTemplate = GetDocTemplate(); ASSERT(pTemplate != NULL); newName = m_strPathName; if (bReplace && newName.IsEmpty()) { newName = m_strTitle; // check for dubious filename int iBad = newName.FindOneOf(_T(" #%;/\\")); if (iBad != -1) newName.ReleaseBuffer(iBad); // append the default suffix if there is one CString strExt; if (pTemplate->GetDocString(strExt, CDocTemplate::filterExt) && !strExt.IsEmpty()) { ASSERT(strExt[0] == '.'); newName += strExt; } } if (SaveFileDialog(AfxGetMainWnd(),newName,newName,NULL, GetFileFilter(FILTER_FILES),6,GetDefExt(FILTER_FILES)) <= 0) return FALSE; // don't even attempt to save } CWaitCursor wait; if (!OnSaveDocument(newName)) { if (lpszPathName == NULL) { // be sure to delete the file TRY { CFile::Remove(newName); } CATCH_ALL(e) { TRACE0("Warning: failed to delete file after failed SaveAs.\n"); do { e->Delete(); } while (0); //DELETE_EXCEPTION(e); } END_CATCH_ALL } return FALSE; }
BOOL DocRoot::SaveDocument(const char* pszPathName) { if (gs_Exec.Busy()) { LogError("SysCAD", 0, "Must not be running"); return False; } char Fn[512]; CString TmpFn; if (pszPathName==NULL) { TmpFn=GetTitle(); pszPathName = TmpFn.GetBuffer(0); } if (strpbrk(pszPathName, ":\\")==NULL) { strcpy(Fn, PrjFiles()); strcat(Fn, pszPathName); } else strcpy(Fn, pszPathName); CString Ext; VERIFY(GetDocTemplate()->GetDocString(Ext, CDocTemplate::filterExt)); pchar ext=Ext.GetBuffer(0); const int l=strlen(Fn); const int el=strlen(ext); if (l<=el) strcat(Fn, ext); else if (_stricmp(&Fn[l-el], ext)!=0) { if (Fn[l-el]=='.') Fn[l-el]=0; //"old" or "incorect" extension needs to be replaced strcat(Fn, ext); } FILE* pFile= fopen(Fn, "wt"); flag b=(pFile!=NULL); if (b) b=WriteDocument(Fn, pFile); if (pFile) fclose(pFile); if (b) { SetPathName(Fn); SetModifiedFlag(FALSE); gs_pCmd->Print("%s - Saved\n", Fn); } else { gs_pCmd->Print("%s - NOT SAVED\n", Fn); } return b; }
///////////////////////////////////////////////////////////////////////// // manually register two images with selected points void CRemoteDoc::OnRegisterManual() { ImageVector<RealPixel> img_vector; POSITION pos = GetDocTemplate()->GetFirstDocPosition(); while(pos) { CRemoteDoc *pDoc = (CRemoteDoc*)(GetDocTemplate()->GetNextDoc(pos)); if(pDoc) { Image<RealPixel> temp; image_cast(pDoc->GetImage(), temp); img_vector.push_back(temp); } else break; } if(img_vector.size() != 2) throw rss::Exception("Two Images are required for CPSelect."); CPSelect cp_select; cp_select.set_image_pointer(&img_vector[0], &img_vector[1]); if( cp_select.DoModal() == IDOK ) { std::vector<rss::Point> BasePoints(cp_select.base_pt); std::vector<rss::Point> RegPoints(cp_select.reg_pt); if(BasePoints.size() != RegPoints.size()) return; ControlPoints cp(BasePoints.size()); for(size_t i=0; i<BasePoints.size(); i++) cp[i] = std::make_pair(BasePoints[i], RegPoints[i]); HomoModel model = HomoModel::CreateFromCP(cp, HomoModel::Similarity); pos = GetDocTemplate()->GetFirstDocPosition(); CRemoteDoc *pDoc1 = (CRemoteDoc*)( GetDocTemplate()->GetNextDoc(pos) ); CRemoteDoc *pDoc2 = (CRemoteDoc*)( GetDocTemplate()->GetNextDoc(pos) ); HomoTrans<pixel_type> trans( model, pDoc1->GetImage().size() ); Image<pixel_type> result( pDoc2->GetImage()); trans( pDoc1->GetImage(), result ); pDoc1->SetImage(result); } }
void OleDocRoot::SetTitle(LPCTSTR lpszTitle) { CString s(lpszTitle); CDocTemplate* pTempl = GetDocTemplate(); if (pTempl) { flag Found = True; while (Found) { Found = False; POSITION Pos = pTempl->GetFirstDocPosition(); while (Pos && !Found) { CDocument * pDoc = pTempl->GetNextDoc(Pos); if (pDoc!=this) { CString Title = pDoc->GetTitle(); if (Title.GetLength()==s.GetLength() && _stricmp((const char*)s, (const char*)Title)==0) Found = True; } } if (Found) { CString Ext = ""; int DotPos = s.ReverseFind('.'); if (DotPos>=0) { Ext = s.Mid(DotPos, 256); s = s.Left(DotPos); } int _Pos = s.ReverseFind('_'); if (_Pos>=0) { CString ss = s.Mid(_Pos+1, 256); s = s.Left(_Pos+1); if (ss.GetLength()>0) { char Buff[32]; sprintf(Buff, "%d", atoi((const char*)ss) + 1); s += Buff; } else s += "1"; } else s += "_1"; s += Ext; } } } COleLinkingDoc::SetTitle((const char*)s); }
BOOL OleDocRoot::OnNewDocument() { if (!COleLinkingDoc::OnNewDocument()) return False; if (gs_Exec.Busy()) { LogError("SysCAD", 0, "Must not be running"); return False; } if (gs_pPrj->pPrjDoc==NULL && !gs_pPrj->bDoingLoad)//sPrjFile.Length() > 0) { LogError("SysCAD", 0, "A project must be opened or a new project created."); return False; } /*CString s = GetTitle(); Strng T = PrjFiles(); T += (const char*)s; GetDocTemplate()->GetDocString(s, CDocTemplate::filterExt); T += (const char*)s; SetPathName(T()); Strng T1,T2; T1.FnName(T()); T2.FnExt(T()); T = T1; T += T2; SetTitle(T());*/ gs_pCmd->ProcessAStr("\x1b"); //Ensure there are no half complete commands gs_pCmd->ProcessAStr("\x1b"); //Ensure there are no half complete commands, call more than once! CString s; GetDocTemplate()->GetDocString(s, CDocTemplate::filterExt); m_strReqdPathName = PrjFiles(); m_strReqdPathName += (LPCTSTR)GetTitle(); m_strReqdPathName += (LPCTSTR)s; // OnAttachDoc(); // OnActivate(True); //gs_pCmd->SetDocForCmds(this); //gs_pCmd->ProcessAStr("CLEAR DOCUMENT \r"); //gs_pCmd->SetDocForCmds(NULL); bIsOpen = True; return True; }
BOOL DocRoot::OpenDocument(const char* pszPathName) { if (gs_Exec.Busy()) { LogError("SysCAD", 0, "Must not be running"); return False; } SetModifiedFlag(FALSE); gs_pPrj->bDocChanged=0; char Fn[512]; if (strpbrk(pszPathName, ":\\")==NULL) { strcpy(Fn, PrjFiles()); strcat(Fn, pszPathName); } else strcpy(Fn, pszPathName); CString Ext; VERIFY(GetDocTemplate()->GetDocString(Ext, CDocTemplate::filterExt)); //GetDocTemplate()->GetDocString(Ext, CDocTemplate::filterExt); pchar ext=Ext.GetBuffer(0); const int l=strlen(Fn); const int el=strlen(ext); if (l<=el || (_stricmp(&Fn[l-el], ext)!=0 && Fn[l-el]!='.')) strcat(Fn, ext); FILE* pFile= fopen(Fn, "rt"); flag b=(pFile!=NULL); if (b && !feof(pFile)) b=ReadDocument(Fn, pFile); if (pFile) fclose(pFile); if (b) { SetPathName(Fn); //LogNote("Document", 0, "Loaded : %s", Fn); Who really wants to know? } else { LogError("Document", 0, "NOT Loaded : %s", Fn); } return b; }
BOOL OleDocRoot::OnSaveDocument(const char* pszPathName) { gs_pCmd->ProcessAStr("\x1b"); //Ensure there are no half complete commands gs_pCmd->ProcessAStr("\x1b"); //Ensure there are no half complete commands, call more than once! if (gs_Exec.Busy()) { LogError("SysCAD", 0, "Must not be running"); return False; } //KGA : 7/5/96 : document sometimes not active ??? causes cmd to go to wrong document/window!!! //if (pFirstDoc!=this) // OnActivate(True); gs_pCmd->ProcessAStr("\x1b"); //Ensure there are no half complete commands, call more than once! //Check if a SaveAs is using a filename that is allready open in this project... // //TODO RESTORE /****/ const int len = strlen(pszPathName); CDocTemplate* pTempl = GetDocTemplate(); if (pTempl) { POSITION Pos = pTempl->GetFirstDocPosition(); while (Pos) { CDocument * pDoc = pTempl->GetNextDoc(Pos); if (pDoc!=this) { CString PathName = pDoc->GetPathName(); if (PathName.GetLength()==len && _stricmp((const char*)PathName, pszPathName)==0) { LogError("SysCAD", LF_Exclamation, "Save As '%s' failed. Document/window allready open!", pszPathName); return False; } } } } /***/ //Strng Cmd; //Cmd.Set("SAVE DOCUMENT %s\r",pszPathName); //gs_pCmd->ProcessAStr(Cmd()); return COleLinkingDoc::OnSaveDocument(pszPathName);//dn.GetBuffer(0)); }
BOOL COXChildFrameState::ApplyProperties() const { ASSERT_VALID(this); CDocTemplate* pDocTemplate = NULL; CDocument* pDoc = NULL; CView* pView = NULL; CFrameWnd* pFrameWnd = NULL; // Create a new document with the info we have pDocTemplate = GetDocTemplate(m_sDocClassName, m_sFrameClassName, m_sViewClassName); if (pDocTemplate == NULL) { TRACE0("COXChildFrameState::ApplyProperties : Could not find the necessary doc template\n"); // Did you change the class name of the document ? // Did you remove the doc template from your program ? return FALSE; } // Open the document LPCTSTR pszDocPath = m_sDocPath; if (m_sDocPath.IsEmpty()) pszDocPath = NULL; if (!OpenDocument(pDocTemplate, pszDocPath, pDoc, pFrameWnd, pView)) { TRACE0("COXChildFrameState::ApplyProperties : Failed to open document, failing\n"); return FALSE; } // Restore the position of the frame window and show it ASSERT(pFrameWnd != NULL); VERIFY(pFrameWnd->SetWindowPlacement(&m_framePlacement)); if (m_bSaveSplitterPanes) ApplySplitterPanes(pFrameWnd); ASSERT_VALID(this); return TRUE; }
BOOL CEtsEodManagerDoc::DoSaveAs() { CDocTemplate* pTemplate = GetDocTemplate(); ASSERT(pTemplate != NULL); CString strNewName; if(m_bIsCurrent) { strNewName = CModuleVersionEx::GetFilePath(m_strPathName); COleDateTime dtToday(COleDateTime::GetCurrentTime()); strNewName += _T("EodReport_"); strNewName += dtToday.Format(_T("%Y%m%d")); CString strExt; pTemplate->GetDocString(strExt, CDocTemplate::filterExt); strNewName += strExt; } else strNewName = m_strPathName; if(!AfxGetApp()->DoPromptFileName(strNewName, AFX_IDS_SAVEFILECOPY, OFN_HIDEREADONLY | OFN_PATHMUSTEXIST, FALSE, pTemplate)) return FALSE; // don't even attempt to save strNewName.Trim(); if(_IsCurrent(strNewName)) { AfxGetMainWnd()->MessageBox(_T("Can't save opened report to current report file."), NULL, MB_ICONSTOP); return FALSE; } CWaitCursor wait; if(!OnSaveDocument(strNewName)) return FALSE; return TRUE; // success }
BOOL DocRoot::OnNewDocument() { if (!CDocument::OnNewDocument()) return False; if (gs_Exec.Busy()) { LogError("SysCAD", 0, "Must not be running"); return False; } if (gs_pPrj->pPrjDoc==NULL && !gs_pPrj->bDoingLoad)//sPrjFile.Length() > 0) { LogError("SysCAD", 0, "A project must be opened or a new project created."); return False; } /*CString s = GetTitle(); Strng T = PrjFiles(); T += (const char*)s; GetDocTemplate()->GetDocString(s, CDocTemplate::filterExt); T += (const char*)s; SetPathName(T()); Strng T1,T2; T1.FnName(T()); T2.FnExt(T()); T = T1; T += T2; SetTitle(T());*/ gs_pCmd->ProcessAStr("\x1b"); //Ensure there are no half complete commands gs_pCmd->ProcessAStr("\x1b"); //Ensure there are no half complete commands, call more than once! CDocTemplate* pTemplate = GetDocTemplate(); CString s; bool GrfChangeName = false; if (1) { pTemplate->GetDocString(s, CDocTemplate::filterExt); if (s==".scg") { s = "05_Flowsheet.scg"; SetTitle(s); //this may alter title; GrfChangeName = true; //ChooseTitle(this, s); //SetTitle(s); } } if (!GrfChangeName) { s = GetTitle(); Strng T = (const char*)s; pTemplate->GetDocString(s, CDocTemplate::filterExt); T += (const char*)s; SetTitle(T()); //this may alter title; } Strng PathN = PrjFiles(); s = GetTitle(); PathN += (const char*)s; SetPathName(PathN()); //do this AFTER SetTitle OnAttachDoc(); OnActivate(True); //gs_pCmd->SetDocForCmds(this); //gs_pCmd->ProcessAStr("CLEAR DOCUMENT \r"); //gs_pCmd->SetDocForCmds(NULL); bIsOpen = True; return True; }
//NBNB: KGA: I am overiding this undocumented function; // 3 May 1996 from doccore.cpp; check with future versions of MFC // Last checked Feb 1997 with MSVC++/MFC version 4.2 BOOL DocRoot::DoSave(LPCTSTR lpszPathName, BOOL bReplace) // Save the document data to a file // lpszPathName = path name where to save document file // if lpszPathName is NULL then the user will be prompted (SaveAs) // note: lpszPathName can be different than 'm_strPathName' // if 'bReplace' is TRUE will change file name if successful (SaveAs) // if 'bReplace' is FALSE will not change path name (SaveCopyAs) { CString newName = lpszPathName; if (newName.IsEmpty()) { CDocTemplate* pTemplate = GetDocTemplate(); ASSERT(pTemplate != NULL); newName = m_strPathName; if (bReplace && newName.IsEmpty()) { newName = m_strTitle; #ifndef _MAC // check for dubious filename int iBad = newName.FindOneOf(_T(" #%;/\\")); #else int iBad = newName.FindOneOf(_T(":")); #endif if (iBad != -1) newName.ReleaseBuffer(iBad); #ifndef _MAC // append the default suffix if there is one CString strExt; if (pTemplate->GetDocString(strExt, CDocTemplate::filterExt) && !strExt.IsEmpty()) { ASSERT(strExt[0] == '.'); newName += strExt; } #endif } if (!ScdApp()->DoPromptFileName(newName, bReplace ? AFX_IDS_SAVEFILE : AFX_IDS_SAVEFILECOPY, OFN_HIDEREADONLY | OFN_PATHMUSTEXIST, FALSE, pTemplate, false)) return FALSE; // don't even attempt to save } CWaitCursor wait; if (!OnSaveDocument(newName)) { /* KGA, DO NOT DELETE !!! if (0 lpszPathName == NULL) { // be sure to delete the file TRY { CFile::Remove(newName); } CATCH_ALL(e) { TRACE0("Warning: failed to delete file after failed SaveAs.\n"); DELETE_EXCEPTION(e); } END_CATCH_ALL }*/ return FALSE; } // reset the title and change the document name if (bReplace) SetPathName(newName); return TRUE; // success }
void DocRoot::SetTitle(LPCTSTR lpszTitle) { CString s(lpszTitle); CDocTemplate* pTempl = GetDocTemplate(); if (pTempl) { CString se; pTempl->GetDocString(se, CDocTemplate::filterExt); bool Grf = (se==".scg"); int No = 5; flag Found = True; while (Found) { Found = False; POSITION Pos = pTempl->GetFirstDocPosition(); while (Pos && !Found) { CDocument* pDoc = pTempl->GetNextDoc(Pos); if (pDoc!=this) { CString Title = pDoc->GetTitle(); if (Title.GetLength()==s.GetLength() && _stricmp((const char*)s, (const char*)Title)==0) Found = True; } } if (Found) { CString Ext = ""; int DotPos = s.ReverseFind('.'); if (DotPos>=0) { Ext = s.Mid(DotPos, 256); s = s.Left(DotPos); } if (Grf) { s.Format("%02d%s", No, "_Flowsheet"); No += 5; } else { int _Pos = s.ReverseFind('_'); if (_Pos>=0) { CString ss = s.Mid(_Pos+1, 256); s = s.Left(_Pos+1); if (ss.GetLength()>0) { char Buff[32]; sprintf(Buff, "%d", atoi((const char*)ss) + 1); s += Buff; } else s += "1"; } else s += "_1"; } s += Ext; } } } CDocument::SetTitle((const char*)s); }
void CRemoteDoc::OnRegisterFeaturelessFourier() { //parameters: SimilarityEstimation::GradientOperator filter = SimilarityEstimation::OP_ROBERT; SimilarityEstimation::HighpassFilter highpass = SimilarityEstimation::FILTER_NONE; bool isTranslation = false; bool isRotation = false; bool isScaling = false; //get parameters from user FourierRegisterDialog dialog; if(dialog.DoModal()==IDOK) { isTranslation = static_cast<bool>(dialog.isTranslation); isRotation = static_cast<bool>(dialog.isRotation); isScaling = static_cast<bool>(dialog.isScaling); bool has_parameter = dialog.m_bPara; double base_width = dialog.m_WidthBase; double base_height = dialog.m_HeightBase; double base_focus = dialog.m_FocusBase; double ref_width = dialog.m_WidthRef; double ref_height = dialog.m_HeightRef; double ref_focus = dialog.m_FocusRef; if( !dialog.filter.CompareNoCase("NONE") ) filter = SimilarityEstimation::OP_NONE; else if( !dialog.filter.CompareNoCase("Robert")) filter = SimilarityEstimation::OP_ROBERT; else if( !dialog.filter.CompareNoCase("NONE")) filter = SimilarityEstimation::OP_SOBEL; else filter = SimilarityEstimation::OP_NONE; if( !dialog.highpass.CompareNoCase("NONE") ) highpass = SimilarityEstimation::FILTER_NONE; else if( !dialog.highpass.CompareNoCase("LAP1") ) highpass = SimilarityEstimation::FILTER_1; else if( !dialog.highpass.CompareNoCase("LAP2") ) highpass = SimilarityEstimation::FILTER_2; else if( !dialog.highpass.CompareNoCase("LAP3") ) highpass = SimilarityEstimation::FILTER_3; else if( !dialog.highpass.CompareNoCase("LAP4") ) highpass = SimilarityEstimation::FILTER_4; else highpass = SimilarityEstimation::FILTER_NONE; CString image_name = dialog.image; /*FourierBasedAffineModel<float> model;*/ Image<RealPixel> image2; image_cast(GetImage(), image2); Image<RealPixel> image1; POSITION pos = GetDocTemplate()->GetFirstDocPosition(); while(pos) { CRemoteDoc *pDoc= (CRemoteDoc *) (GetDocTemplate()->GetNextDoc(pos)); if(pDoc->GetTitle() == image_name) { image_cast(pDoc->GetImage(), image1); //image1 = pDoc->GetImage(); } } if(has_parameter) { // para 输入参数,para[0]为可见光相机焦距,para[1]为可见光相机底 // 片水平尺寸,para[2]为可见光相机底片垂直尺寸,para[3]为红 // 外相机焦距,para[4]为红外相机底片水平尺寸,para[5]为红外 double scale1 = base_focus / ref_focus * ref_width / base_width * image1.width() / image2.width(); double scale2 = base_focus / ref_focus * ref_height / base_height * image1.height() / image2.height(); double scale = sqrt(scale1*scale2); HomoModel pre_trans_model; pre_trans_model.SetSimilarity(scale, 0, image2.width() * (1 - scale) / 2.0, image2.height() * (1 - scale) / 2.0); HomoTrans<RealPixel> pre_trans(pre_trans_model, image1.size()); Image<RealPixel> temp; pre_trans.operator ()(image2, temp); //image_cast(temp, image2); image2 = temp; } HomoModel model; SimilarityEstimation sim_est(isTranslation, isRotation, isScaling, filter, highpass); /* compute model param */ sim_est( image1, image2, model); Image<pixel_type> result; HomoTrans<pixel_type> homo_trans(model, image1.size()); homo_trans.operator()(GetImage(), result); SetImage(result); } }
void CDocument::OnFileSendMail() { ASSERT_VALID(this); ASSERT(_afxIsMailAvail); // update handler always gets called first CWaitCursor wait; _AFX_MAIL_STATE* pMailState = _afxMailState; if (pMailState->m_hInstMail == NULL) pMailState->m_hInstMail = ::LoadLibraryA("MAPI32.DLL"); if (pMailState->m_hInstMail == NULL) { AfxMessageBox(AFX_IDP_FAILED_MAPI_LOAD); return; } ASSERT(pMailState->m_hInstMail != NULL); ULONG (PASCAL *lpfnSendMail)(ULONG, ULONG, MapiMessage*, FLAGS, ULONG); (FARPROC&)lpfnSendMail = GetProcAddress(pMailState->m_hInstMail, "MAPISendMail"); if (lpfnSendMail == NULL) { AfxMessageBox(AFX_IDP_INVALID_MAPI_DLL); return; } ASSERT(lpfnSendMail != NULL); TCHAR szTempName[_MAX_PATH]; TCHAR szPath[_MAX_PATH]; BOOL bRemoveTemp = FALSE; if (m_strPathName.IsEmpty() || IsModified()) { // save to temporary path VERIFY(GetTempPath(_countof(szPath), szPath) != 0); VERIFY(GetTempFileName(szPath, _T("afx"), 0, szTempName) != 0); // save it, but remember original modified flag BOOL bModified = IsModified(); BOOL bResult = DoSave(szTempName, FALSE); SetModifiedFlag(bModified); if (!bResult) { TRACE0("Warning: file save failed during File.Send Mail.\n"); return; } bRemoveTemp = TRUE; } else { // use actual file since it isn't modified lstrcpyn(szTempName, m_strPathName, _countof(szTempName)); } #ifdef _UNICODE char szTempNameA[_MAX_PATH]; _wcstombsz(szTempNameA, szTempName, _countof(szTempNameA)); #endif // build an appropriate title for the attachment TCHAR szTitle[_MAX_PATH]; if (!m_strPathName.IsEmpty()) AfxGetFileName(m_strPathName, szTitle, _countof(szTitle)); else { lstrcpyn(szTitle, m_strTitle, _countof(szTitle)); if (m_strTitle.Find('.') == -1) // no extension { // append the default suffix if there is one CString strExt; CDocTemplate* pTemplate = GetDocTemplate(); if (pTemplate != NULL && pTemplate->GetDocString(strExt, CDocTemplate::filterExt)) { lstrcat(szTitle, strExt); } } } #ifdef _UNICODE char szTitleA[_MAX_PATH]; _wcstombsz(szTitleA, szTitle, _countof(szTitleA)); #endif // prepare the file description (for the attachment) MapiFileDesc fileDesc; memset(&fileDesc, 0, sizeof(fileDesc)); fileDesc.nPosition = (ULONG)-1; #ifdef _UNICODE fileDesc.lpszPathName = szTempNameA; fileDesc.lpszFileName = szTitleA; #else fileDesc.lpszPathName = szTempName; fileDesc.lpszFileName = szTitle; #endif // prepare the message (empty with 1 attachment) MapiMessage message; memset(&message, 0, sizeof(message)); message.nFileCount = 1; message.lpFiles = &fileDesc; // prepare for modal dialog box AfxGetApp()->EnableModeless(FALSE); HWND hWndTop; CWnd* pParentWnd = CWnd::GetSafeOwner(NULL, &hWndTop); // some extra precautions are required to use MAPISendMail as it // tends to enable the parent window in between dialogs (after // the login dialog, but before the send note dialog). pParentWnd->SetCapture(); ::SetFocus(NULL); pParentWnd->m_nFlags |= WF_STAYDISABLED; int nError = lpfnSendMail(0, (ULONG)pParentWnd->GetSafeHwnd(), &message, MAPI_LOGON_UI|MAPI_DIALOG, 0); // after returning from the MAPISendMail call, the window must // be re-enabled and focus returned to the frame to undo the workaround // done before the MAPI call. ::ReleaseCapture(); pParentWnd->m_nFlags &= ~WF_STAYDISABLED; pParentWnd->EnableWindow(TRUE); ::SetActiveWindow(NULL); pParentWnd->SetActiveWindow(); pParentWnd->SetFocus(); if (hWndTop != NULL) ::EnableWindow(hWndTop, TRUE); AfxGetApp()->EnableModeless(TRUE); if (nError != SUCCESS_SUCCESS && nError != MAPI_USER_ABORT && nError != MAPI_E_LOGIN_FAILURE) { AfxMessageBox(AFX_IDP_FAILED_MAPI_SEND); } // remove temporary file, if temporary file was used if (bRemoveTemp) CFile::Remove(szTempName); }