Ejemplo n.º 1
0
/*----------------------------------------------------------------------------------------------
	Background color, used for shape interior, text background
	Arguments:
		nRGB			RGB color value or kclrTransparent
----------------------------------------------------------------------------------------------*/
HRESULT VwGraphicsCairo::put_BackColor(int nRGB)
{
#if DEBUG
	if (m_loggingFile != NULL)
	{
		fprintf(m_loggingFile, "put_BackColor %p %d\n", this, nRGB);
		fflush(m_loggingFile);
	}
#endif
 BEGIN_COM_METHOD;
	// Set values for color from nRGB
	if ((unsigned int)nRGB == kclrTransparent) {
		VwColor newBack;
		newBack.m_transparent = true;
		m_backgroundColor = newBack;
	}
	else {
		VwColor newBack(nRGB);
		m_backgroundColor = newBack;
	}

 END_COM_METHOD(g_fact, IID_IVwGraphics);
}
Ejemplo n.º 2
0
// given a back transition (state in the prefix matching search)
// and match (information how it can be extended with matching a transition)
// create a new back transition (new state in the prefix matching search)
inline void MainCaitra::process_match( int state, const BackTransition &back, const Match &match, const Transition &transition ) {
    int transition_to_state = transition.to_state;
    float score = back.score + transition.score;
    int error = back.error + match.error;

    // common case: prefix is not yet fully matched
    if (match.prefixMatched < prefix.size() ) {
        // check how this new back transition compares against existing ones
        for( backIter oldBack = states[transition_to_state].back.begin(); oldBack != states[transition_to_state].back.end(); oldBack++ ) {
            if (oldBack->prefix_matched == match.prefixMatched) { // already a back path with same prefix match?
                // if better, overwrite
                  if (oldBack->error > error ||
                        (oldBack->error == error && (oldBack->score < score ||
                                                     (oldBack->score == score && oldBack->back_matched < match.prefixMatched)))) {


               /* if ((oldBack->score - errorWeigth * oldBack->error < score - errorWeigth * error) ||
                        ((oldBack->score - errorWeigth * oldBack->error) == (score - errorWeigth * error) && oldBack->back_matched < match.prefixMatched)){
*/
                    //  if (oldBack->score - errorWeigth * oldBack->error < score - errorWeigth * error){

                    oldBack->error = error;
                    oldBack->score = score;
                    oldBack->back_state = state;
                    oldBack->back_matched = back.prefix_matched;
                    oldBack->prefix_matched = match.prefixMatched;
                    oldBack->transition = &transition;
                    // cerr << "\t\t\toverwriting\n";
                }
                // if worse, ignore
                // done in any case
                return ;
            }
        }

        // not recombinable with existing back translation -> just add it
        BackTransition newBack( score, error, match.prefixMatched, state, back.prefix_matched, &transition );
        states[transition_to_state].back.push_back( newBack );

        //cerr << "\t\t\tadding\n";
    }
    // special case: all of the prefix is consumed
    else {
        // add score to complete path
        score += states[transition_to_state].forward_score;

        // first completion ... or ... better than currently best completion?
        if ( best[error].from_state == -1 ||
             score > best[error].score ||
             (score == best[error].score && match.prefixMatched > best[error].prefix_matched) ) {
            best[error].score = score;
            best[error].from_state = state;
            best[error].transition = &transition;
            best[error].output_matched = match.transitionMatched;
            best[error].back_matched = back.prefix_matched;
            best[error].prefix_matched = match.prefixMatched;
            //cerr << "\t\t\tnew best\n";

        }

    }
}