void wxSVGFileDCImpl::DoDrawIcon(const class wxIcon & myIcon, wxCoord x, wxCoord y) { wxBitmap myBitmap (myIcon.GetWidth(), myIcon.GetHeight() ); wxMemoryDC memDC; memDC.SelectObject( myBitmap ); memDC.DrawIcon(myIcon,0,0); memDC.SelectObject( wxNullBitmap ); DoDrawBitmap(myBitmap, x, y); }
void wxSVGFileDC::DoDrawIcon(const class wxIcon & myIcon, wxCoord x, wxCoord y) { wxBitmap myBitmap (myIcon.GetWidth(), myIcon.GetHeight() ) ; wxMemoryDC memDC; memDC.SelectObject( myBitmap ); memDC.DrawIcon(myIcon,0,0); memDC.SelectObject( wxNullBitmap ); DoDrawBitmap(myBitmap, x, y); wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawIcon Call executed")) ; return ; }
void OpSequenceModel:: Evaluate(const Phrase &source , const TargetPhrase &targetPhrase , ScoreComponentCollection &scoreBreakdown , ScoreComponentCollection &estimatedFutureScore) const { osmHypothesis obj; obj.setState(OSM->NullContextState()); WordsBitmap myBitmap(source.GetSize()); vector <string> mySourcePhrase; vector <string> myTargetPhrase; vector<float> scores(5); vector <int> alignments; int startIndex = 0; int endIndex = source.GetSize(); const AlignmentInfo &align = targetPhrase.GetAlignTerm(); AlignmentInfo::const_iterator iter; for (iter = align.begin(); iter != align.end(); ++iter) { alignments.push_back(iter->first); alignments.push_back(iter->second); } for (int i = 0; i < targetPhrase.GetSize(); i++) { if (targetPhrase.GetWord(i).IsOOV()) myTargetPhrase.push_back("_TRANS_SLF_"); else myTargetPhrase.push_back(targetPhrase.GetWord(i).GetFactor(0)->GetString().as_string()); } for (int i = 0; i < source.GetSize(); i++) { mySourcePhrase.push_back(source.GetWord(i).GetFactor(0)->GetString().as_string()); } obj.setPhrases(mySourcePhrase , myTargetPhrase); obj.constructCepts(alignments,startIndex,endIndex-1,targetPhrase.GetSize()); obj.computeOSMFeature(startIndex,myBitmap); obj.calculateOSMProb(*OSM); obj.populateScores(scores); estimatedFutureScore.PlusEquals(this, scores); }
// export a bitmap as a raster image in png bool wxSVGFileDCImpl::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC* source, wxCoord xsrc, wxCoord ysrc, wxRasterOperationMode logicalFunc /*= wxCOPY*/, bool useMask /*= false*/, wxCoord /*xsrcMask = -1*/, wxCoord /*ysrcMask = -1*/) { if (logicalFunc != wxCOPY) { wxASSERT_MSG(false, wxT("wxSVGFileDC::DoBlit Call requested nonCopy mode; this is not possible")); return false; } if (useMask != false) { wxASSERT_MSG(false, wxT("wxSVGFileDC::DoBlit Call requested false mask; this is not possible")); return false; } wxBitmap myBitmap (width, height); wxMemoryDC memDC; memDC.SelectObject( myBitmap ); memDC.Blit(0, 0, width, height, source, xsrc, ysrc); memDC.SelectObject( wxNullBitmap ); DoDrawBitmap(myBitmap, xdest, ydest); return false; }
// export a bitmap as a raster image in png bool wxSVGFileDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC* source, wxCoord xsrc, wxCoord ysrc, int logicalFunc /*= wxCOPY*/, bool useMask /*= FALSE*/, wxCoord /*xsrcMask = -1*/, wxCoord /*ysrcMask = -1*/) { if (logicalFunc != wxCOPY) { wxASSERT_MSG(FALSE, wxT("wxSVGFileDC::DoBlit Call requested nonCopy mode; this is not possible")) ; return FALSE ; } if (useMask != FALSE) { wxASSERT_MSG(FALSE, wxT("wxSVGFileDC::DoBlit Call requested False mask ; this is not possible")) ; return FALSE ; } wxBitmap myBitmap (width, height) ; wxMemoryDC memDC; memDC.SelectObject( myBitmap ); memDC.Blit(0, 0, width, height, source, xsrc, ysrc); memDC.SelectObject( wxNullBitmap ); DoDrawBitmap(myBitmap, xdest, ydest); wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoBlit Call executed")) ; return FALSE ; }
FFState* OpSequenceModel::EvaluateWhenApplied( const Hypothesis& cur_hypo, const FFState* prev_state, ScoreComponentCollection* accumulator) const { const TargetPhrase &target = cur_hypo.GetCurrTargetPhrase(); const Bitmap &bitmap = cur_hypo.GetWordsBitmap(); Bitmap myBitmap(bitmap); const Manager &manager = cur_hypo.GetManager(); const InputType &source = manager.GetSource(); // const Sentence &sourceSentence = static_cast<const Sentence&>(source); osmHypothesis obj; vector <string> mySourcePhrase; vector <string> myTargetPhrase; vector<float> scores; //target.GetWord(0) //cerr << target <<" --- "<<target.GetSourcePhrase()<< endl; // English ... //cerr << align << endl; // Alignments ... //cerr << cur_hypo.GetCurrSourceWordsRange() << endl; //cerr << source <<endl; // int a = sourceRange.GetStartPos(); // cerr << source.GetWord(a); //cerr <<a<<endl; //const Sentence &sentence = static_cast<const Sentence&>(curr_hypo.GetManager().GetSource()); const Range & sourceRange = cur_hypo.GetCurrSourceWordsRange(); int startIndex = sourceRange.GetStartPos(); int endIndex = sourceRange.GetEndPos(); const AlignmentInfo &align = cur_hypo.GetCurrTargetPhrase().GetAlignTerm(); // osmState * statePtr; vector <int> alignments; AlignmentInfo::const_iterator iter; for (iter = align.begin(); iter != align.end(); ++iter) { //cerr << iter->first << "----" << iter->second << " "; alignments.push_back(iter->first); alignments.push_back(iter->second); } //cerr<<bitmap<<endl; //cerr<<startIndex<<" "<<endIndex<<endl; for (int i = startIndex; i <= endIndex; i++) { myBitmap.SetValue(i,0); // resetting coverage of this phrase ... mySourcePhrase.push_back(source.GetWord(i).GetFactor(sFactor)->GetString().as_string()); // cerr<<mySourcePhrase[i]<<endl; } for (size_t i = 0; i < target.GetSize(); i++) { if (target.GetWord(i).IsOOV() && sFactor == 0 && tFactor == 0) myTargetPhrase.push_back("_TRANS_SLF_"); else myTargetPhrase.push_back(target.GetWord(i).GetFactor(tFactor)->GetString().as_string()); } //cerr<<myBitmap<<endl; obj.setState(prev_state); obj.constructCepts(alignments,startIndex,endIndex,target.GetSize()); obj.setPhrases(mySourcePhrase , myTargetPhrase); obj.computeOSMFeature(startIndex,myBitmap); obj.calculateOSMProb(*OSM); obj.populateScores(scores,numFeatures); //obj.print(); /* if (bitmap.GetFirstGapPos() == NOT_FOUND) { int xx; cerr<<bitmap<<endl; int a = bitmap.GetFirstGapPos(); obj.print(); cin>>xx; } */ accumulator->PlusEquals(this, scores); return obj.saveState(); //return statePtr; // return NULL; }