FX_BOOL CPDF_PageOrganizer::UpdateReference(CPDF_Object* pObj, CPDF_Document* pDoc, ObjectNumberMap* pObjNumberMap) { switch (pObj->GetType()) { case CPDF_Object::REFERENCE: { CPDF_Reference* pReference = pObj->AsReference(); uint32_t newobjnum = GetNewObjId(pDoc, pObjNumberMap, pReference); if (newobjnum == 0) return FALSE; pReference->SetRef(pDoc, newobjnum); break; } case CPDF_Object::DICTIONARY: { CPDF_Dictionary* pDict = pObj->AsDictionary(); auto it = pDict->begin(); while (it != pDict->end()) { const CFX_ByteString& key = it->first; CPDF_Object* pNextObj = it->second; ++it; if (key == "Parent" || key == "Prev" || key == "First") continue; if (!pNextObj) return FALSE; if (!UpdateReference(pNextObj, pDoc, pObjNumberMap)) pDict->RemoveFor(key); } break; } case CPDF_Object::ARRAY: { CPDF_Array* pArray = pObj->AsArray(); for (size_t i = 0; i < pArray->GetCount(); ++i) { CPDF_Object* pNextObj = pArray->GetObjectAt(i); if (!pNextObj) return FALSE; if (!UpdateReference(pNextObj, pDoc, pObjNumberMap)) return FALSE; } break; } case CPDF_Object::STREAM: { CPDF_Stream* pStream = pObj->AsStream(); CPDF_Dictionary* pDict = pStream->GetDict(); if (pDict) { if (!UpdateReference(pDict, pDoc, pObjNumberMap)) return FALSE; } else { return FALSE; } break; } default: break; } return TRUE; }
OrbitalElements MpcorbEphemeris::VGetOrbitalElements(const std::string& name, const Epoch& epoch) { UpdateReference(name); keplerian::LagrangianPropagator propagator; m_cachedOrbitalElements = propagator.PropagateOrbitalElements(m_referenceOrbitalElements, ASTRO_MU_SUN, epoch - m_referenceEpoch); return m_cachedOrbitalElements; }
bool CGroupObject::SetReference(LPCSTR ref_name) { shared_str old_refs = m_ReferenceName; m_ReferenceName = ref_name; bool bres = UpdateReference(); if (false==bres) m_ReferenceName = old_refs; return bres; }
bool CGroupObject::SetReference(LPCSTR ref_name) { shared_str old_refs = m_ReferenceName_; SetRefName(ref_name); bool bres = UpdateReference(old_refs!=ref_name); if (false==bres) SetRefName(old_refs.c_str()); return bres; }
OrbitalElements MpcorbEphemeris::GetReferenceOrbitalElements(const std::string& name) { if (IsValidName(name)) { UpdateReference(name); return m_referenceOrbitalElements; } else { OTL_ERROR() << "Name " << Bracket(name) << " not found"; } return OrbitalElements(); }
Epoch MpcorbEphemeris::GetReferenceEpoch(const std::string& name) { if (IsValidName(name)) { UpdateReference(name); return m_referenceEpoch; } else { OTL_ERROR() << "Name " << Bracket(name) << " not found"; } return Epoch(); }
FX_DWORD CPDF_PageOrganizer::GetNewObjId(CPDF_Document* pDoc, ObjectNumberMap* pObjNumberMap, CPDF_Reference* pRef) { if (!pRef) return 0; FX_DWORD dwObjnum = pRef->GetRefObjNum(); FX_DWORD dwNewObjNum = 0; const auto it = pObjNumberMap->find(dwObjnum); if (it != pObjNumberMap->end()) dwNewObjNum = it->second; if (dwNewObjNum) return dwNewObjNum; CPDF_Object* pDirect = pRef->GetDirect(); if (!pDirect) return 0; CPDF_Object* pClone = pDirect->Clone(); if (!pClone) return 0; if (CPDF_Dictionary* pDictClone = pClone->AsDictionary()) { if (pDictClone->KeyExist("Type")) { CFX_ByteString strType = pDictClone->GetString("Type"); if (!FXSYS_stricmp(strType, "Pages")) { pDictClone->Release(); return 4; } if (!FXSYS_stricmp(strType, "Page")) { pDictClone->Release(); return 0; } } } dwNewObjNum = pDoc->AddIndirectObject(pClone); (*pObjNumberMap)[dwObjnum] = dwNewObjNum; if (!UpdateReference(pClone, pDoc, pObjNumberMap)) { pClone->Release(); return 0; } return dwNewObjNum; }
bool Help::Update(void) { GameInput &input = GameInput::GetInstance(); float x = input.GetXf(); float y = input.GetYf(); int nextPage = -1; if(m_Exist) { switch(m_State) { case INDEX: nextPage = UpdateIndex(); if(nextPage >= 0) { m_OldPage = -1; //前ページ保存 m_Page = nextPage; //次ページ格納 m_State = REFERENCE;//ステート切替 m_PageAlpha = 0; //α初期化 } break; case REFERENCE: m_State = UpdateReference(); break; } //閉じるボタン処理 if(Close()) { m_Exist = false; m_OffFrame = true; } } //ボタンの拡縮 if(x >= 0.9425f && y <= 0.07f) m_Help_Button_Scale += (1.3f - m_Help_Button_Scale) * 0.3f; else m_Help_Button_Scale += (1.0f - m_Help_Button_Scale) * 0.3f; return m_Exist; }
void CGroupObject::ReferenceChange(PropValue* sender) { UpdateReference (true); }
FX_BOOL CPDF_PageOrganizer::ExportPage(CPDF_Document* pSrcPDFDoc, CFX_WordArray* nPageNum, CPDF_Document* pDestPDFDoc, int nIndex) { int curpage = nIndex; nonstd::unique_ptr<ObjectNumberMap> pObjNumberMap(new ObjectNumberMap); for (int i = 0; i < nPageNum->GetSize(); ++i) { CPDF_Dictionary* pCurPageDict = pDestPDFDoc->CreateNewPage(curpage); CPDF_Dictionary* pSrcPageDict = pSrcPDFDoc->GetPage(nPageNum->GetAt(i) - 1); if (!pSrcPageDict || !pCurPageDict) return FALSE; // Clone the page dictionary/////////// FX_POSITION SrcPos = pSrcPageDict->GetStartPos(); while (SrcPos) { CFX_ByteString cbSrcKeyStr; CPDF_Object* pObj = pSrcPageDict->GetNextElement(SrcPos, cbSrcKeyStr); if (cbSrcKeyStr.Compare(("Type")) && cbSrcKeyStr.Compare(("Parent"))) { if (pCurPageDict->KeyExist(cbSrcKeyStr)) pCurPageDict->RemoveAt(cbSrcKeyStr); pCurPageDict->SetAt(cbSrcKeyStr, pObj->Clone()); } } // inheritable item/////////////////////// CPDF_Object* pInheritable = nullptr; // 1 MediaBox //required if (!pCurPageDict->KeyExist("MediaBox")) { pInheritable = PageDictGetInheritableTag(pSrcPageDict, "MediaBox"); if (!pInheritable) { // Search the "CropBox" from source page dictionary, // if not exists,we take the letter size. pInheritable = PageDictGetInheritableTag(pSrcPageDict, "CropBox"); if (pInheritable) { pCurPageDict->SetAt("MediaBox", pInheritable->Clone()); } else { // Make the default size to be letter size (8.5'x11') CPDF_Array* pArray = new CPDF_Array; pArray->AddNumber(0); pArray->AddNumber(0); pArray->AddNumber(612); pArray->AddNumber(792); pCurPageDict->SetAt("MediaBox", pArray); } } else { pCurPageDict->SetAt("MediaBox", pInheritable->Clone()); } } // 2 Resources //required if (!pCurPageDict->KeyExist("Resources")) { pInheritable = PageDictGetInheritableTag(pSrcPageDict, "Resources"); if (!pInheritable) return FALSE; pCurPageDict->SetAt("Resources", pInheritable->Clone()); } // 3 CropBox //Optional if (!pCurPageDict->KeyExist("CropBox")) { pInheritable = PageDictGetInheritableTag(pSrcPageDict, "CropBox"); if (pInheritable) pCurPageDict->SetAt("CropBox", pInheritable->Clone()); } // 4 Rotate //Optional if (!pCurPageDict->KeyExist("Rotate")) { pInheritable = PageDictGetInheritableTag(pSrcPageDict, "Rotate"); if (pInheritable) pCurPageDict->SetAt("Rotate", pInheritable->Clone()); } ///////////////////////////////////////////// // Update the reference FX_DWORD dwOldPageObj = pSrcPageDict->GetObjNum(); FX_DWORD dwNewPageObj = pCurPageDict->GetObjNum(); (*pObjNumberMap)[dwOldPageObj] = dwNewPageObj; UpdateReference(pCurPageDict, pDestPDFDoc, pObjNumberMap.get()); ++curpage; } return TRUE; }
FX_BOOL CPDF_PageOrganizer::UpdateReference(CPDF_Object* pObj, CPDF_Document* pDoc, ObjectNumberMap* pObjNumberMap) { switch (pObj->GetType()) { case PDFOBJ_REFERENCE: { CPDF_Reference* pReference = pObj->AsReference(); FX_DWORD newobjnum = GetNewObjId(pDoc, pObjNumberMap, pReference); if (newobjnum == 0) return FALSE; pReference->SetRef(pDoc, newobjnum); break; } case PDFOBJ_DICTIONARY: { CPDF_Dictionary* pDict = pObj->AsDictionary(); FX_POSITION pos = pDict->GetStartPos(); while (pos) { CFX_ByteString key(""); CPDF_Object* pNextObj = pDict->GetNextElement(pos, key); if (!FXSYS_strcmp(key, "Parent") || !FXSYS_strcmp(key, "Prev") || !FXSYS_strcmp(key, "First")) { continue; } if (pNextObj) { if (!UpdateReference(pNextObj, pDoc, pObjNumberMap)) pDict->RemoveAt(key); } else { return FALSE; } } break; } case PDFOBJ_ARRAY: { CPDF_Array* pArray = pObj->AsArray(); FX_DWORD count = pArray->GetCount(); for (FX_DWORD i = 0; i < count; ++i) { CPDF_Object* pNextObj = pArray->GetElement(i); if (!pNextObj) return FALSE; if (!UpdateReference(pNextObj, pDoc, pObjNumberMap)) return FALSE; } break; } case PDFOBJ_STREAM: { CPDF_Stream* pStream = pObj->AsStream(); CPDF_Dictionary* pDict = pStream->GetDict(); if (pDict) { if (!UpdateReference(pDict, pDoc, pObjNumberMap)) return FALSE; } else { return FALSE; } break; } default: break; } return TRUE; }
int db_FrameToReferenceRegistration::AddFrame(const unsigned char * const * im, double H[9],bool force_reference,bool prewarp) { m_current_is_reference = false; if(!m_reference_set || force_reference) { db_Identity3x3(m_H_ref_to_ins); db_Copy9(H,m_H_ref_to_ins); UpdateReference(im,true,true); return 0; } const unsigned char * const * imptr = im; if (m_quarter_resolution) { if (m_quarter_res_image) { GenerateQuarterResImage(im); } imptr = (const unsigned char * const* )m_quarter_res_image; } double H_last[9]; db_Copy9(H_last,m_H_ref_to_ins); db_Identity3x3(m_H_ref_to_ins); m_sq_cost_computed = false; // detect corners on inspection image and match to reference image features:s // @jke - Adding code to time the functions. TODO: Remove after test #if PROFILE double iTimer1, iTimer2; char str[255]; strcpy(profile_string,"\n"); sprintf(str,"[%dx%d] %p\n",m_im_width,m_im_height,im); strcat(profile_string, str); #endif // @jke - Adding code to time the functions. TODO: Remove after test #if PROFILE iTimer1 = now_ms(); #endif m_cd.DetectCorners(imptr, m_x_corners_ins,m_y_corners_ins,&m_nr_corners_ins); // @jke - Adding code to time the functions. TODO: Remove after test # if PROFILE iTimer2 = now_ms(); double elapsedTimeCorner = iTimer2 - iTimer1; sprintf(str,"Corner Detection [%d corners] = %g ms\n",m_nr_corners_ins, elapsedTimeCorner); strcat(profile_string, str); #endif // @jke - Adding code to time the functions. TODO: Remove after test #if PROFILE iTimer1 = now_ms(); #endif if(prewarp) m_cm.Match(m_reference_image,imptr,m_x_corners_ref,m_y_corners_ref,m_nr_corners_ref, m_x_corners_ins,m_y_corners_ins,m_nr_corners_ins, m_match_index_ref,m_match_index_ins,&m_nr_matches,H,0); else m_cm.Match(m_reference_image,imptr,m_x_corners_ref,m_y_corners_ref,m_nr_corners_ref, m_x_corners_ins,m_y_corners_ins,m_nr_corners_ins, m_match_index_ref,m_match_index_ins,&m_nr_matches); // @jke - Adding code to time the functions. TODO: Remove after test # if PROFILE iTimer2 = now_ms(); double elapsedTimeMatch = iTimer2 - iTimer1; sprintf(str,"Matching [%d] = %g ms\n",m_nr_matches,elapsedTimeMatch); strcat(profile_string, str); #endif // copy out matching features: for ( int i = 0; i < m_nr_matches; ++i ) { int offset = 3*i; m_corners_ref[offset ] = m_x_corners_ref[m_match_index_ref[i]]; m_corners_ref[offset+1] = m_y_corners_ref[m_match_index_ref[i]]; m_corners_ref[offset+2] = 1.0; m_corners_ins[offset ] = m_x_corners_ins[m_match_index_ins[i]]; m_corners_ins[offset+1] = m_y_corners_ins[m_match_index_ins[i]]; m_corners_ins[offset+2] = 1.0; } // @jke - Adding code to time the functions. TODO: Remove after test #if PROFILE iTimer1 = now_ms(); #endif // perform the alignment: db_RobImageHomography(m_H_ref_to_ins, m_corners_ref, m_corners_ins, m_nr_matches, m_K, m_K, m_temp_double, m_temp_int, m_homography_type,NULL,m_max_iterations,m_max_nr_matches,m_scale, m_nr_samples, m_chunk_size); // @jke - Adding code to time the functions. TODO: Remove after test # if PROFILE iTimer2 = now_ms(); double elapsedTimeHomography = iTimer2 - iTimer1; sprintf(str,"Homography = %g ms\n",elapsedTimeHomography); strcat(profile_string, str); #endif SetOutlierThreshold(); // Compute the inliers for the db compute m_H_ref_to_ins ComputeInliers(m_H_ref_to_ins); // Update the max inlier count m_max_inlier_count = (m_max_inlier_count > m_num_inlier_indices)?m_max_inlier_count:m_num_inlier_indices; // Fit a least-squares model to just the inliers and put it in m_H_ref_to_ins if(m_linear_polish) Polish(m_inlier_indices, m_num_inlier_indices); if (m_quarter_resolution) { m_H_ref_to_ins[2] *= 2.0; m_H_ref_to_ins[5] *= 2.0; } #if PROFILE sprintf(str,"#Inliers = %d \n",m_num_inlier_indices); strcat(profile_string, str); #endif /* ///// CHECK IF CURRENT TRANSFORMATION GOOD OR BAD //// ///// IF BAD, then update reference to the last correctly aligned inspection frame; if(m_num_inlier_indices<5)//0.9*m_nr_matches || m_nr_matches < 20) { db_Copy9(m_H_ref_to_ins,H_last); UpdateReference(imptr,false); // UpdateReference(m_aligned_ins_image,false); } else { ///// IF GOOD, then update the last correctly aligned inspection frame to be this; //db_CopyImage_u(m_aligned_ins_image,imptr,m_im_width,m_im_height,m_over_allocation); */ if(m_do_motion_smoothing) SmoothMotion(); // Disable debug printing // db_PrintDoubleMatrix(m_H_ref_to_ins,3,3); db_Copy9(H, m_H_ref_to_ins); m_nr_frames_processed++; { if ( (m_nr_frames_processed % m_reference_update_period) == 0 ) { //UpdateReference(imptr,false, false); #if MB UpdateReference(imptr,false, true); #else UpdateReference(imptr,false, false); #endif } } return 1; }
void CSceneObject::ReferenceChange(PropValue* sender) { Scene->BeforeObjectChange(this); UpdateReference (); }
CEditableObject* CSceneObject::SetReference(LPCSTR ref_name) { m_ReferenceName = ref_name; return UpdateReference(); }
FX_BOOL CPDF_PageOrganizer::ExportPage(CPDF_Document* pSrcPDFDoc, std::vector<uint16_t>* pPageNums, CPDF_Document* pDestPDFDoc, int nIndex) { int curpage = nIndex; std::unique_ptr<ObjectNumberMap> pObjNumberMap(new ObjectNumberMap); int nSize = pdfium::CollectionSize<int>(*pPageNums); for (int i = 0; i < nSize; ++i) { CPDF_Dictionary* pCurPageDict = pDestPDFDoc->CreateNewPage(curpage); CPDF_Dictionary* pSrcPageDict = pSrcPDFDoc->GetPage(pPageNums->at(i) - 1); if (!pSrcPageDict || !pCurPageDict) return FALSE; // Clone the page dictionary for (const auto& it : *pSrcPageDict) { const CFX_ByteString& cbSrcKeyStr = it.first; CPDF_Object* pObj = it.second; if (cbSrcKeyStr.Compare(("Type")) && cbSrcKeyStr.Compare(("Parent"))) { if (pCurPageDict->KeyExist(cbSrcKeyStr)) pCurPageDict->RemoveFor(cbSrcKeyStr); pCurPageDict->SetFor(cbSrcKeyStr, pObj->Clone()); } } // inheritable item CPDF_Object* pInheritable = nullptr; // 1 MediaBox //required if (!pCurPageDict->KeyExist("MediaBox")) { pInheritable = PageDictGetInheritableTag(pSrcPageDict, "MediaBox"); if (!pInheritable) { // Search the "CropBox" from source page dictionary, // if not exists,we take the letter size. pInheritable = PageDictGetInheritableTag(pSrcPageDict, "CropBox"); if (pInheritable) { pCurPageDict->SetFor("MediaBox", pInheritable->Clone()); } else { // Make the default size to be letter size (8.5'x11') CPDF_Array* pArray = new CPDF_Array; pArray->AddNumber(0); pArray->AddNumber(0); pArray->AddNumber(612); pArray->AddNumber(792); pCurPageDict->SetFor("MediaBox", pArray); } } else { pCurPageDict->SetFor("MediaBox", pInheritable->Clone()); } } // 2 Resources //required if (!pCurPageDict->KeyExist("Resources")) { pInheritable = PageDictGetInheritableTag(pSrcPageDict, "Resources"); if (!pInheritable) return FALSE; pCurPageDict->SetFor("Resources", pInheritable->Clone()); } // 3 CropBox //Optional if (!pCurPageDict->KeyExist("CropBox")) { pInheritable = PageDictGetInheritableTag(pSrcPageDict, "CropBox"); if (pInheritable) pCurPageDict->SetFor("CropBox", pInheritable->Clone()); } // 4 Rotate //Optional if (!pCurPageDict->KeyExist("Rotate")) { pInheritable = PageDictGetInheritableTag(pSrcPageDict, "Rotate"); if (pInheritable) pCurPageDict->SetFor("Rotate", pInheritable->Clone()); } // Update the reference uint32_t dwOldPageObj = pSrcPageDict->GetObjNum(); uint32_t dwNewPageObj = pCurPageDict->GetObjNum(); (*pObjNumberMap)[dwOldPageObj] = dwNewPageObj; UpdateReference(pCurPageDict, pDestPDFDoc, pObjNumberMap.get()); ++curpage; } return TRUE; }
void CURSOR::Plot( wxDC& aDC, mpWindow& aWindow ) { if( !m_window ) m_window = &aWindow; if( !m_visible ) return; const auto& dataX = m_trace->GetDataX(); const auto& dataY = m_trace->GetDataY(); if( dataX.size() <= 1 ) return; if( m_updateRequired ) { m_coords.x = m_trace->s2x( aWindow.p2x( m_dim.x ) ); // Find the closest point coordinates auto maxXIt = std::upper_bound( dataX.begin(), dataX.end(), m_coords.x ); int maxIdx = maxXIt - dataX.begin(); int minIdx = maxIdx - 1; // Out of bounds checks if( minIdx < 0 ) { minIdx = 0; maxIdx = 1; m_coords.x = dataX[0]; } else if( maxIdx >= (int) dataX.size() ) { maxIdx = dataX.size() - 1; minIdx = maxIdx - 1; m_coords.x = dataX[maxIdx]; } const double leftX = dataX[minIdx]; const double rightX = dataX[maxIdx]; const double leftY = dataY[minIdx]; const double rightY = dataY[maxIdx]; // Linear interpolation m_coords.y = leftY + ( rightY - leftY ) / ( rightX - leftX ) * ( m_coords.x - leftX ); m_updateRequired = false; // Notify the parent window about the changes wxQueueEvent( aWindow.GetParent(), new wxCommandEvent( EVT_SIM_CURSOR_UPDATE ) ); } else { m_updateRef = true; } if( m_updateRef ) { UpdateReference(); m_updateRef = false; } // Line length in horizontal and vertical dimensions const wxPoint cursorPos( aWindow.x2p( m_trace->x2s( m_coords.x ) ), aWindow.y2p( m_trace->y2s( m_coords.y ) ) ); wxCoord leftPx = m_drawOutsideMargins ? 0 : aWindow.GetMarginLeft(); wxCoord rightPx = m_drawOutsideMargins ? aWindow.GetScrX() : aWindow.GetScrX() - aWindow.GetMarginRight(); wxCoord topPx = m_drawOutsideMargins ? 0 : aWindow.GetMarginTop(); wxCoord bottomPx = m_drawOutsideMargins ? aWindow.GetScrY() : aWindow.GetScrY() - aWindow.GetMarginBottom(); aDC.SetPen( wxPen( *wxWHITE, 1, m_continuous ? wxPENSTYLE_SOLID : wxPENSTYLE_LONG_DASH ) ); if( topPx < cursorPos.y && cursorPos.y < bottomPx ) aDC.DrawLine( leftPx, cursorPos.y, rightPx, cursorPos.y ); if( leftPx < cursorPos.x && cursorPos.x < rightPx ) aDC.DrawLine( cursorPos.x, topPx, cursorPos.x, bottomPx ); }