bool obs_output_active(const obs_output_t *output) { return (output != NULL) ? (active(output) || reconnecting(output)) : false; }
bool Foam::subModelBase::outputTime() const { return active(); }
std::ostream & toStream( std::ostream & out, uint64_t refpos, std::string const & refidname, int const refbase, ConsensusAux & caux, ConsensusAccuracy * consacc = 0, std::ostream * consostr = 0 ) { // insertions if ( I.size() ) { uint64_t const cov = V.size() + iadd; uint64_t maxi = 0; for ( uint64_t i = 0; i < I.size(); ++i ) maxi = std::max(maxi,static_cast<uint64_t>(I[i].size())); // vector of active indices std::vector<uint64_t> active(I.size()); for ( uint64_t i = 0; i < active.size(); ++i ) active[i] = i; // vector for symbol sorting std::vector< std::pair<char,uint8_t> > sortvec(active.size()); for ( uint64_t j = 0; active.size(); ++j ) { // number still active in next round uint64_t o = 0; sortvec.resize(active.size()); for ( uint64_t i = 0; i < active.size(); ++i ) { sortvec[i] = I[active[i]][j]; if ( j+1 < I[active[i]].size() ) active[o++] = active[i]; } active.resize(o); std::sort(sortvec.begin(),sortvec.end()); out << refidname << '\t' << refpos << '\t' << (-static_cast<int64_t>(maxi))+static_cast<int64_t>(j) << '\t'; if ( cov > sortvec.size() ) for ( uint64_t i = 0; i < cov-sortvec.size(); ++i ) { out.put(padsym); caux.C[padsym] += caux.M[padsym]; } for ( uint64_t i = 0; i < sortvec.size(); ++i ) { out.put(sortvec[i].first); caux.C[sortvec[i].first] += caux.M[sortvec[i].first]; } out.put('\t'); uint8_t const consbase = getConsensusBase(caux); out.put(consbase); if ( consostr && consbase != padsym ) consostr->put(consbase); if ( consacc && consbase != padsym ) consacc->insertions++; out.put('\n'); if ( cov > sortvec.size() ) for ( uint64_t i = 0; i < cov-sortvec.size(); ++i ) caux.C[padsym] -= caux.M[padsym]; for ( uint64_t i = 0; i < sortvec.size(); ++i ) caux.C[sortvec[i].first] -= caux.M[sortvec[i].first]; } } std::sort(V.begin(),V.end()); out << refidname << '\t' << refpos << '\t' << 0 << '\t'; for ( uint64_t i = 0; i < V.size(); ++i ) { out.put(V[i].first); caux.C[V[i].first] += caux.M[V[i].first]; } out << "\t"; if ( refbase != -1 ) out.put(refbase); out.put('\t'); uint8_t const consbase = getConsensusBase(caux); if ( consacc && (consbase == padsym) ) { consacc->deletions++; consacc->depthhistogram(0); } if ( refbase != -1 && consacc && (consbase != padsym) ) { if ( consbase == refbase && ( consbase == 'a' || consbase == 'A' || consbase == 'c' || consbase == 'C' || consbase == 'g' || consbase == 'G' || consbase == 't' || consbase == 'T' ) ) consacc->matches++; else consacc->mismatches++; consacc->depthhistogram(V.size()); } out.put(consbase); if ( consostr && consbase != padsym ) consostr->put(consbase); out.put('\n'); for ( uint64_t i = 0; i < V.size(); ++i ) caux.C[V[i].first] -= caux.M[V[i].first]; for ( uint64_t i = 0; i < caux.C.size(); ++i ) assert ( caux.C[i] == 0 ); if ( consacc ) consacc->refbasesprocessed++; return out; }
/* ================ idSmokeParticles::EmitSmoke Called by game code to drop another particle into the list ================ */ bool idSmokeParticles::EmitSmoke( const idDeclParticle *smoke, const int systemStartTime, const float diversity, const idVec3 &origin, const idMat3 &axis ) { bool continues = false; if( !smoke ) { return false; } if( !gameLocal.isNewFrame ) { return false; } // dedicated doesn't smoke. No UpdateRenderEntity, so they would not be freed if( gameLocal.localClientNum < 0 ) { return false; } assert( gameLocal.time == 0 || systemStartTime <= gameLocal.time ); if( systemStartTime > gameLocal.time ) { return false; } idRandom steppingRandom( static_cast<int>( 0xffff * diversity ) ); // for each stage in the smoke that is still emitting particles, emit a new singleSmoke_t for( int stageNum = 0; stageNum < smoke->stages.Num(); stageNum++ ) { const idParticleStage *stage = smoke->stages[stageNum]; if( !stage->cycleMsec ) { continue; } if( !stage->material ) { continue; } if( stage->particleLife <= 0 ) { continue; } // see how many particles we should emit this tic // FIXME: smoke.privateStartTime += stage->timeOffset; int finalParticleTime = static_cast<int>( stage->spawnBunching * stage->cycleMsec ); int deltaMsec = gameLocal.time - systemStartTime; int nowCount = 0, prevCount; if( finalParticleTime == 0 ) { // if spawnBunching is 0, they will all come out at once if( gameLocal.time == systemStartTime ) { prevCount = -1; nowCount = stage->totalParticles - 1; } else { prevCount = stage->totalParticles; } } else { nowCount = static_cast<int>( floor( ( ( float )deltaMsec / finalParticleTime ) * stage->totalParticles ) ); if( nowCount >= stage->totalParticles ) { nowCount = stage->totalParticles - 1; } prevCount = static_cast<int>( floor( ( ( float )( deltaMsec - USERCMD_MSEC ) / finalParticleTime ) * stage->totalParticles ) ); if( prevCount < -1 ) { prevCount = -1; } } if( prevCount >= stage->totalParticles ) { // no more particles from this stage continue; } if( nowCount < stage->totalParticles - 1 ) { // the system will need to emit particles next frame as well continues = true; } // find an activeSmokeStage that matches this activeSmokeStage_t *active( NULL ); int i; for( i = 0; i < activeStages.Num(); i++ ) { active = &activeStages[i]; if( active->stage == stage ) { break; } } if( i == activeStages.Num() ) { // add a new one activeSmokeStage_t newActive; newActive.smokes = NULL; newActive.stage = stage; i = activeStages.Append( newActive ); active = &activeStages[i]; } // add all the required particles for( prevCount++; prevCount <= nowCount; prevCount++ ) { if( !freeSmokes ) { gameLocal.Printf( "idSmokeParticles::EmitSmoke: no free smokes with %d active stages\n", activeStages.Num() ); return true; } singleSmoke_t *newSmoke = freeSmokes; freeSmokes = freeSmokes->next; numActiveSmokes++; newSmoke->index = prevCount; newSmoke->axis = axis; newSmoke->origin = origin; newSmoke->random = steppingRandom; newSmoke->privateStartTime = systemStartTime + prevCount * finalParticleTime / stage->totalParticles; newSmoke->next = active->smokes; active->smokes = newSmoke; steppingRandom.RandomInt(); // advance the random } } return continues; }
static u_i4 pp_directive( FILE *input, STACK_FRAME *stack , bool ifdef ) { i4 n, len; char *words[ MAX_LINE / 2 ], *temp, *p; char *parse_val, *parse_end; STACK_FRAME stack_frame; bool def_dir; u_i4 rtn = NONE; stack_frame.prev = stack; stack_frame.display_mode = TRUE; p = temp = STalloc( infile->yytext ); CMnext( p ); n = sizeof( words ); STgetwords( p, &n, words ); /* process the directive, watch out for the empty directive */ if (n == 0) { ; /* empty directive */ } else if( STequal( words[ 0 ], ERx( "define" ) ) != 0 ) { /* If a symbol was specified look for the value to give it */ if (n > 1) { /* Scan for the 'define' keyword */ parse_val = infile->yytext; CMnext(parse_val); /* Skip over the '#' */ while (CMwhite(parse_val)) CMnext(parse_val); /* Scan past the 'define' keyword */ while (!CMwhite(parse_val)) CMnext(parse_val); /* Scan over white space separating 'define' */ /* keyword and the specified symbol name */ while (CMwhite(parse_val)) CMnext(parse_val); /* Skip over the symbol name */ while (!CMwhite(parse_val)) CMnext(parse_val); /* Skip over white space after the symbol name */ while (CMwhite(parse_val)) CMnext(parse_val); /* At this point we have scanned to the beginning */ /* of the defined value for the symbol, Trim off */ /* any trailing white space */ STtrmwhite(parse_val); /* Define value found, could be the empty string, "" */ if( active( &stack_frame ) ) { define( words[ 1 ], parse_val, FALSE ); } } rtn = DEFINE; } else if( active( &stack_frame ) && STequal( words[ 0 ], ERx( "undef" ) ) != 0 ) { if (n > 1) { undefine( words[ 1 ] ); } rtn = UNDEF; } else if( STequal( words[ 0 ], ERx( "if" ) ) != 0 ) { /* If an expression was specified look for its evaluation */ if (n > 1) { /* Scan for the 'if' keyword */ parse_val = infile->yytext; CMnext(parse_val); /* Skip over the '#' */ while (CMwhite(parse_val)) CMnext(parse_val); /* Scan past the 'if' keyword */ while (!CMwhite(parse_val)) CMnext(parse_val); /* Scan over white space separating 'if' */ /* keyword and the expression */ while (CMwhite(parse_val)) CMnext(parse_val); /* At this point we have scanned to the beginning */ /* of the expression.*/ if( active( &stack_frame ) ) { /* Evaluate boolean expression found */ stack_frame.display_mode = pp_eval_boolexp( &parse_val, ERx("") ); } (void) pp_input( input, &stack_frame, TRUE ); } rtn = IF; } else if( STequal( words[ 0 ], ERx( "ifdef" ) ) != 0 ) { if( active(&stack_frame) && is_defined(words[1], NULL) == OK) { stack_frame.display_mode = TRUE; } else stack_frame.display_mode = FALSE; (void) pp_input( input, &stack_frame, TRUE ); rtn = IFDEF; } else if( STequal( words[ 0 ], ERx( "ifndef" ) ) != 0 ) { if( active(&stack_frame) && is_defined(words[1], NULL) != OK) { stack_frame.display_mode = TRUE; } else stack_frame.display_mode = FALSE; (void) pp_input( input, &stack_frame, TRUE ); rtn = IFNDEF; } else if( STequal( words[ 0 ], ERx( "else" ) ) != 0 ) { if( !ifdef ) { SIfprintf( stderr, E_YAPP007 ); yydump(); } stack_frame.prev->display_mode = ( stack_frame.prev->display_mode == TRUE ) ? FALSE : TRUE; rtn = ELSE; } else if( STequal( words[ 0 ], ERx( "endif" ) ) != 0 ) { rtn = ENDIF; } else if( STequal( words[ 0 ], ERx( "include" ) ) != 0 ) { /* Look for the include filename */ if (n > 1) { /* Scan for the 'include' keyword */ parse_val = infile->yytext; CMnext(parse_val); /* Skip over the '#' */ while (CMwhite(parse_val)) CMnext(parse_val); /* Scan past the include keyword */ while (!CMwhite(parse_val)) CMnext(parse_val); /* Scan over white space separating 'include' */ /* keyword and the specified filename */ while (CMwhite(parse_val)) CMnext(parse_val); /* At this point were expecting "file" or <file> */ /* remember the character which ends the filename */ def_dir = TRUE; if (CMcmpcase(parse_val, ERx("\"")) == 0) { parse_end = ERx("\""); } else if (CMcmpcase(parse_val, ERx("<")) == 0) { parse_end = ERx(">"); def_dir = FALSE; } else { parse_end = ERx(""); } /* Save the include file name in the temp string. */ /* Note, this overwrites the parsed words of the */ /* record since but these are no longer needed. */ p = temp; CMnext(parse_val); while (*parse_val != EOS) { if (CMcmpcase(parse_val, parse_end) == 0) { /* Terminate the file name and call */ /* pp_file to process the file. */ STcopy(ERx(""), p); pp_file(stack, temp, def_dir); break; } CMcpychar(parse_val, p); CMnext(parse_val); CMnext(p); } } rtn = DEFINE; } /* display everthing but legal directives */ if (rtn == NONE && active( &stack_frame ) ) yyputline( infile->yytext ); MEfree( temp ); return( rtn ); }
void QCompressor::process(QSampleBuffer sampleBuffer) { bool isClipping = false; bool isActive = false; _mutex.lock(); double threshold = _threshold; double ratio = _ratio; double attack = _attack; double release = _release; double inputGain = _inputGain; double makeupGain = _makeupGain; bool bypass = _bypass; _mutex.unlock(); if(bypass) { return; } // TODO: To be implemented. Q_UNUSED(attack); Q_UNUSED(release); int bufferSize = sampleBuffer.size(); double inputGainMultiplier = QUnits::dbToLinear(inputGain); double makeupGainMultiplier = QUnits::dbToLinear(makeupGain); for(int i = 0; i < bufferSize; i++) { // Read audio sample double sample = sampleBuffer.readAudioSample(i) * inputGainMultiplier; // Determine peak in dB double peak = QUnits::peak(sample); double resultSample = sample; // Check if peak is over threshold if(peak > QUnits::dbToLinear(threshold)) { // Perform signal compression isActive = true; // Calculate over treshold in linear space double overThreshold = peak - QUnits::dbToLinear(threshold); // Compress signal in logarithmic space double dbOverThresholdCompressed = QUnits::linearToDb(overThreshold) / ratio; double resultingPeak = QUnits::dbToLinear(threshold + dbOverThresholdCompressed); resultSample = resultingPeak * ( sample > 0.0 ? 1.0 : -1.0 ); } double result = resultSample * makeupGainMultiplier; if(result > 1.0) { result = 1.0; isClipping = true; } if(result < -1.0) { result = -1.0; isClipping = true; } sampleBuffer.writeAudioSample(i, result); } if(isClipping) { emit clipping(); } if(isActive) { emit active(); } }
void Input::ProcessInput(InputManager* input) { if (!input) { return; } // bool push_mouse_left = (input->GetMouseLeftCount() > 0); // bool first_key_shift = (input->GetKeyCount(KEY_INPUT_RSHIFT) == 1 // || input->GetKeyCount(KEY_INPUT_LSHIFT) == 1); bool push_key_shift = (input->GetKeyCount(KEY_INPUT_RSHIFT) > 0 || input->GetKeyCount(KEY_INPUT_LSHIFT) > 0); bool push_key_v = (input->GetKeyCount(KEY_INPUT_V) > 0); bool push_key_ctrl = (input->GetKeyCount(KEY_INPUT_LCONTROL) > 0 || input->GetKeyCount(KEY_INPUT_RCONTROL) > 0); bool push_key_return = (input->GetKeyCount(KEY_INPUT_RETURN) > 0); bool first_key_return = (input->GetKeyCount(KEY_INPUT_RETURN) == 1); bool push_repeat_key_return = (input->GetKeyCount(KEY_INPUT_RETURN) + KEY_REPEAT_FRAME) % (KEY_REPEAT_FRAME + 1) == 0; bool push_repeat_key_up = (input->GetKeyCount(KEY_INPUT_UP) + KEY_REPEAT_FRAME) % (KEY_REPEAT_FRAME + 1) == 0; bool push_repeat_key_down = (input->GetKeyCount(KEY_INPUT_DOWN) + KEY_REPEAT_FRAME) % (KEY_REPEAT_FRAME + 1) == 0; // bool push_long_backspace = (input->GetKeyCount(KEY_INPUT_BACK) > 60 * 1.5); auto input_text = text(); if (!active() && push_key_v && push_key_ctrl) { set_active(true); } else { if (push_key_shift && push_key_return) { SetActiveKeyInput(input_handle_); } else if (first_key_return) { if (CheckKeyInput(input_handle_) == 1) { if (on_enter_) { if (on_enter_(unicode::ToString(input_text))) { SetKeyInputString(_T(""), input_handle_); } } SetActiveKeyInput(input_handle_); } } } if (push_repeat_key_up) { cursor_moveto_y_ = cursor_y_ - font_height_ / 2; cursor_moveto_x_ = cursor_x_ + 2; } else if (push_repeat_key_down) { cursor_moveto_y_ = cursor_y_ + font_height_ + font_height_ / 2; cursor_moveto_x_ = cursor_x_ + 2; } if (push_key_shift && push_repeat_key_return && multiline_) { auto buffer = text(); uint32_t pos = GetKeyInputCursorPosition(input_handle_); tstring cursor_front_str = buffer.substr(0, pos); // カーソル前の文字列 tstring cursor_back_str = buffer.substr(pos); // カーソル後の文字列 auto new_string = cursor_front_str + _T('\n') + cursor_back_str; SetKeyInputString(new_string.c_str(), input_handle_); SetKeyInputCursorPosition(pos + 1, input_handle_); CancelSelect(); cursor_drag_count_ = 0; } int cursor_byte_pos, cursor_dot_pos; int draw_dot_pos = 0; TCHAR String[TEXT_BUFFER_SIZE]; GetKeyInputString(String, input_handle_); // 単一行設定の時、最初の行だけを表示 if (!multiline_) { tstring buffer(String, _tcslen(String)); size_t pos; if ((pos = buffer.find(_T('\n'))) != std::string::npos) { SetKeyInputString(buffer.substr(0, pos).c_str(), input_handle_); } } int internal_width = width_ - INPUT_MARGIN_X * 2; // int internal_height = height_ - INPUT_MARGIN * 2; message_lines_.clear(); if (message_.size() > 0) { int current_line = 0; tstring line_buffer; int line_width = 0; int char_count = 0; for (auto it = message_.begin(); it != message_.end(); ++it) { #ifdef UNICODE TCHAR c = *it; int width = GetDrawStringWidthToHandle(&c, 1, font_handle_); line_buffer += c; char_count++; #else unsigned char c = *it; TCHAR string[2] = { 0, 0 }; int width = 0; if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xfc)) { string[0] = c; string[1] = *(it + 1); ++it; width = GetDrawStringWidthToHandle(string, 2, font_handle_); line_buffer += string[0]; line_buffer += string[1]; char_count += 2; } else if (c == '\n') { char_count++; } else { string[0] = c; width = GetDrawStringWidthToHandle(string, 1, font_handle_); line_buffer += string[0]; char_count++; } #endif line_width += width; if (c == _T('\n') || line_width > internal_width - font_height_ / 2) { if (!line_buffer.empty() && line_buffer.back() == _T('\n')) { line_buffer.pop_back(); } message_lines_.push_back(line_buffer); current_line++; line_buffer.clear(); line_width = 0; } } message_lines_.push_back(line_buffer); } if (active()) { // カーソル位置(byte)を取得 cursor_byte_pos = GetKeyInputCursorPosition(input_handle_); if (prev_cursor_pos_ != cursor_byte_pos) { ResetCursorCount(); } prev_cursor_pos_ = cursor_byte_pos; // カーソルのドット単位の位置を取得する cursor_dot_pos = GetDrawStringWidthToHandle(String, cursor_byte_pos, font_handle_); draw_dot_pos += cursor_dot_pos; tstring cursor_front_str(String, cursor_byte_pos); // カーソル前の文字列 tstring cursor_back_str(String + cursor_byte_pos); // カーソル後の文字列 std::vector<tstring> clauses; // 入力中の文節 std::vector<tstring> candidates; // 変換候補 lines_.clear(); selecting_lines_.clear(); clause_lines_.clear(); selecting_clause_lines_.clear(); candidates_.clear(); // 文節データを取得 // int selecting_clause = -1; selecting_candidate_ = -1; IMEINPUTDATA *ImeData = GetIMEInputData(); if (ImeData && active()) { for (int i = 0; i < ImeData->ClauseNum; i++) { clauses.push_back( tstring( ImeData->InputString + ImeData->ClauseData[i].Position, ImeData->ClauseData[i].Length)); } selecting_clause_ = ImeData->SelectClause; if (ImeData->CandidateNum > 0) { for (int i = 0; i < ImeData->CandidateNum; i++) { candidates_.push_back( tstring(ImeData->CandidateList[i], _tcslen(ImeData->CandidateList[i]))); } selecting_candidate_ = ImeData->SelectCandidate; } } // 選択範囲を取得 int select_start, select_end; GetKeyInputSelectArea(&select_start, &select_end, input_handle_); if (select_start > select_end) { std::swap(select_start, select_end); } tstring line_buffer; int line_width = 0; int char_count = 0; // カーソル前のデータを描画 for (auto it = cursor_front_str.begin(); it != cursor_front_str.end(); ++it) { int prev_char_count = char_count; #ifdef UNICODE TCHAR c = *it; int width = GetDrawStringWidthToHandle(&c, 1, font_handle_); line_buffer += c; char_count++; #else unsigned char c = *it; TCHAR string[2] = { 0, 0 }; int width = 0; if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xfc)) { string[0] = c; string[1] = *(it + 1); ++it; width = GetDrawStringWidthToHandle(string, 2, font_handle_); line_buffer += string[0]; line_buffer += string[1]; char_count += 2; } else if (c == '\n') { char_count++; } else { string[0] = c; width = GetDrawStringWidthToHandle(string, 1, font_handle_); line_buffer += string[0]; char_count++; } #endif // 選択範囲を記録 if (select_start < char_count && char_count <= select_end) { selecting_lines_.resize(static_cast<int>(lines_.size() + message_lines_.size()) + 1, std::pair<int, int>(99999, 0)); selecting_lines_[static_cast<int>(lines_.size() + message_lines_.size())].first = std::min( selecting_lines_[static_cast<int>(lines_.size() + message_lines_.size())].first, line_width); selecting_lines_[static_cast<int>(lines_.size() + message_lines_.size())].second = std::max( selecting_lines_[static_cast<int>(lines_.size() + message_lines_.size())].second, line_width + std::max(width, 3)); } if (line_width - width / 2 <= cursor_moveto_x_ && cursor_moveto_x_ <= line_width + width && static_cast<int>(lines_.size() + message_lines_.size()) * font_height_ <= cursor_moveto_y_ && cursor_moveto_y_ <= (static_cast<int>(lines_.size() + message_lines_.size()) + 1) * font_height_) { SetKeyInputCursorPosition(prev_char_count, input_handle_); cursor_moveto_x_ = -1; cursor_moveto_y_ = -1; } line_width += width; if (c == _T('\n') || line_width > internal_width - font_height_ / 2) { if (!line_buffer.empty() && line_buffer.back() == _T('\n')) { line_buffer.pop_back(); } lines_.push_back(line_buffer); if (cursor_moveto_x_ >= line_width && static_cast<int>(lines_.size() + message_lines_.size()) * font_height_ <= cursor_moveto_y_ && cursor_moveto_y_ <= (static_cast<int>(lines_.size() + message_lines_.size()) + 1) * font_height_) { if (c == _T('\n')) { SetKeyInputCursorPosition(char_count - 1, input_handle_); } else { SetKeyInputCursorPosition(char_count, input_handle_); } cursor_moveto_x_ = -1; cursor_moveto_y_ = -1; } line_buffer.clear(); line_width = 0; } } cursor_x_ = line_width; cursor_y_ = static_cast<int>(lines_.size() + message_lines_.size()) * font_height_; // 変換中データを描画 for (uint32_t index = 0; index < clauses.size(); index++) { for (auto it = clauses[index].begin(); it != clauses[index].end(); ++it) { #ifdef UNICODE TCHAR c = *it; int width = GetDrawStringWidthToHandle(&c, 1, font_handle_); line_buffer += tstring(&c, 1); char_count++; #else unsigned char c = *it; TCHAR string[2] = { 0, 0 }; int width = 0; if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xfc)) { string[0] = c; string[1] = *(it + 1); ++it; width = GetDrawStringWidthToHandle(string, 2, font_handle_); line_buffer += string[0]; line_buffer += string[1]; char_count += 2; } else if (c == '\n') { char_count++; } else { string[0] = c; width = GetDrawStringWidthToHandle(string, 1, font_handle_); line_buffer += string[0]; char_count++; } #endif clause_lines_.resize(static_cast<int>(lines_.size() + message_lines_.size()) + 1, std::pair<int, int>(99999, 0)); clause_lines_[static_cast<int>(lines_.size() + message_lines_.size())].first = std::min( clause_lines_[static_cast<int>(lines_.size() + message_lines_.size())].first, line_width); clause_lines_[static_cast<int>(lines_.size() + message_lines_.size())].second = std::max( clause_lines_[static_cast<int>(lines_.size() + message_lines_.size())].second, line_width + width); if (index == static_cast<uint32_t>(selecting_clause_)) { selecting_clause_lines_.resize(static_cast<int>(lines_.size() + message_lines_.size()) + 1, std::pair<int, int>(99999, 0)); selecting_clause_lines_[static_cast<int>(lines_.size() + message_lines_.size())].first = std::min( selecting_clause_lines_[static_cast<int>(lines_.size() + message_lines_.size())].first, line_width); selecting_clause_lines_[static_cast<int>(lines_.size() + message_lines_.size())].second = std::max( selecting_clause_lines_[static_cast<int>(lines_.size() + message_lines_.size())].second, line_width + width); } line_width += width; if (line_width > internal_width - font_height_ / 2) { lines_.push_back(line_buffer); line_buffer.clear(); line_width = 0; } } } // カーソル後のデータを描画 for (auto it = cursor_back_str.begin(); it != cursor_back_str.end(); ++it) { int prev_char_count = char_count; #ifdef UNICODE TCHAR c = *it; int width = GetDrawStringWidthToHandle(&c, 1, font_handle_); line_buffer += tstring(&c, 1); #else unsigned char c = *it; TCHAR string[2] = { 0, 0 }; int width = 0; if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xfc)) { string[0] = c; string[1] = *(it + 1); ++it; width = GetDrawStringWidthToHandle(string, 2, font_handle_); line_buffer += string[0]; line_buffer += string[1]; char_count += 2; } else if (c == '\n') { char_count++; } else { string[0] = c; width = GetDrawStringWidthToHandle(string, 1, font_handle_); line_buffer += string[0]; char_count++; } #endif // 選択範囲を記録 if (select_start < char_count && char_count <= select_end) { selecting_lines_.resize(static_cast<int>(lines_.size() + message_lines_.size()) + 1, std::pair<int, int>(99999, 0)); selecting_lines_[static_cast<int>(lines_.size() + message_lines_.size())].first = std::min( selecting_lines_[static_cast<int>(lines_.size() + message_lines_.size())].first, line_width); selecting_lines_[static_cast<int>(lines_.size() + message_lines_.size())].second = std::max( selecting_lines_[static_cast<int>(lines_.size() + message_lines_.size())].second, line_width + std::max(width, 3)); } if (line_width - width / 2 <= cursor_moveto_x_ && cursor_moveto_x_ <= line_width + width && static_cast<int>(lines_.size() + message_lines_.size()) * font_height_ <= cursor_moveto_y_ && cursor_moveto_y_ <= (static_cast<int>(lines_.size() + message_lines_.size()) + 1) * font_height_) { SetKeyInputCursorPosition(prev_char_count, input_handle_); cursor_moveto_x_ = -1; cursor_moveto_y_ = -1; } line_width += width; if (c == _T('\n') || line_width > internal_width - font_height_ / 2) { if (!line_buffer.empty() && line_buffer.back() == _T('\n')) { line_buffer.pop_back(); } lines_.push_back(line_buffer); if (cursor_moveto_x_ >= line_width && static_cast<int>(lines_.size() + message_lines_.size()) * font_height_ <= cursor_moveto_y_ && cursor_moveto_y_ <= (static_cast<int>(lines_.size() + message_lines_.size()) + 1) * font_height_) { if (c == _T('\n')) { SetKeyInputCursorPosition(char_count - 1, input_handle_); } else { SetKeyInputCursorPosition(char_count, input_handle_); } cursor_moveto_x_ = -1; cursor_moveto_y_ = -1; } line_buffer.clear(); line_width = 0; } } // バッファの残りを描画 lines_.push_back(line_buffer); if (cursor_moveto_x_ >= line_width && static_cast<int>(lines_.size() + message_lines_.size()) * font_height_ <= cursor_moveto_y_ && static_cast<int>(cursor_moveto_y_) <= static_cast<int>(lines_.size() + message_lines_.size()) * font_height_) { SetKeyInputCursorPosition(char_count, input_handle_); cursor_moveto_x_ = -1; cursor_moveto_y_ = -1; } height_ = static_cast<int>(lines_.size() + message_lines_.size()) * font_height_ + INPUT_MARGIN_Y * 2; // height_ = max(height_, min_height_); line_buffer.clear(); line_width = 0; //if (push_key_shift && (push_repeat_key_up || push_repeat_key_down)) { // SetKeyInputSelectArea(GetKeyInputCursorPosition(input_handle_), // prev_cursor_pos_, input_handle_); //} } if (active()) { input->CancelKeyCountAll(); } }
void Invert::child_done(Behavior* b, b8 success) { if (active()) done(!success); }
void Select::run() { active(true); index = 0; children[0]->run(); }
void Succeed::child_done(Behavior* b, b8 success) { if (active()) done(true); }
void Invert::run() { active(true); child->run(); }
void Sequence::run() { active(true); index = 0; children[0]->run(); }
void Delay::run() { timer = duration; active(true); }
void Repeat::run() { active(true); repeat_index = 0; child->run(); }
void FlowClusteringEPG::_compute() { if(!optflow_otl_->pull().prev_pcd_indices_) { edge_otl_.push(NULL); return; } cv::Mat3b img = optflow_otl_->pull().img_; initializeStorage(img.rows * img.cols, 0.10); if(cluster_index_.rows == 0) cluster_index_ = cv::Mat1i(img.size(), -1); const vector<int>& prev_pcd_indices = *optflow_otl_->pull().prev_pcd_indices_; const vector<int>& pcd_indices = *optflow_otl_->pull().pcd_indices_; const KinectCloud& prev_cloud = *index_otl_->pull().previous_pcd_; const KinectCloud& cloud = *index_otl_->pull().current_pcd_; ROS_ASSERT(prev_pcd_indices.size() == pcd_indices.size()); int iter = 0; int max_iter = 500; // TODO: Parameterize. vector<int> prev_sample(3); vector<int> sample(3); vector<bool> active(pcd_indices.size(), true); while(iter < max_iter) { ++iter; sampleFlows(active, prev_pcd_indices, pcd_indices, &prev_sample, &sample); Eigen::Matrix4f transform; pcl::registration::TransformationEstimationSVD<Point, Point> te; te.estimateRigidTransformation(prev_cloud, prev_sample, cloud, sample, transform); // -- See if this transform made any sense at all. size_t num_inliers = 0; for(size_t i = 0; i < sample.size(); ++i) { Vector3f projected = (transform * prev_cloud[prev_sample[i]].getVector4fMap()).head(3); float dist = (projected - cloud[sample[i]].getVector3fMap()).norm(); if(dist < inlier_thresh_) ++num_inliers; } if(num_inliers != 3) continue; // -- Refine the estimate. // -- Get inlier flows. vector<bool> inliers(pcd_indices.size(), false); num_inliers = 0; for(size_t i = 0; i < pcd_indices.size(); ++i) { if(!active[i]) continue; Vector3f projected = (transform * prev_cloud[prev_pcd_indices[i]].getVector4fMap()).head(3); float dist = (projected - cloud[pcd_indices[i]].getVector3fMap()).norm(); if(dist < inlier_thresh_) { inliers[i] = true; active[i] = false; ++num_inliers; } } //cout << "FC: Found cluster with " << num_inliers << " inliers out of " << pcd_indices.size() << endl; // -- Link inliers with edge potentials. clusters_.push_back(vector<int>()); vector<int>& cluster = clusters_.back(); cluster.reserve(num_inliers); size_t id = clusters_.size() - 1; for(size_t i = 0; i < inliers.size(); ++i) { if(!inliers[i]) continue; cluster.push_back(pcd_indices[i]); // Assumes ordered ptcld. // Assumes ordered point cloud. ROS_ASSERT((size_t)img.cols == prev_cloud.width); int y = prev_pcd_indices[i] / img.cols; int x = prev_pcd_indices[i] - y * img.cols; cluster_index_(y, x) = id; } sort(cluster.begin(), cluster.end()); // Make a note if this is the one to ignore. if(num_inliers > max_cluster_size_) { max_cluster_size_ = num_inliers; max_cluster_ = id; } // -- Break if few active flows remaining. int num_active = 0; for(size_t i = 0; i < active.size(); ++i) if(active[i]) ++num_active; if(num_active < 3) break; } //cout << "FC: total clusters = " << clusters_.size() << endl; // -- potentials_ is a sparse matrix, so add links in order. // cluster_index_(y, x) is the id of the cluster this pixel is in. // clusters_[i] is a sorted (ascending) vector of indices into the image. for(int y = 0; y < cluster_index_.rows; ++y) { for(int x = 0; x < cluster_index_.cols; ++x) { int idx0 = y * cluster_index_.cols + x; potentials_.startVec(idx0); if(cluster_index_(y, x) == -1) continue; // Ignore the biggest cluster. if(cluster_index_(y, x) == (int)max_cluster_) continue; // TODO: Gross. const vector<int>& cluster = clusters_[cluster_index_(y, x)]; if(cluster.size() < 5) { for(size_t i = 0; i < cluster.size(); ++i) { int idx1 = cluster[i]; if(i > 0) { ROS_ASSERT(cluster[i] > cluster[i-1]); //cout << "FC: Adding edge between " << idx0 << " and " << idx1 << endl; } if(idx0 != idx1) potentials_.insertBack(idx0, idx1) = 1.0; } } else { for(int i = 0; i < 1; ++i) { int r = rand() % cluster.size(); int idx1 = cluster[r]; //cout << "FC: Adding edge between " << idx0 << " and " << idx1 << endl; if(idx0 != idx1) potentials_.insertBack(idx0, idx1) = 1.0; } } } } potentials_.finalize(); edge_otl_.push(&potentials_); }
// Factory: safe construction of object before thread start std::auto_ptr<ActiveQThread> ActiveQThread::createActiveQThread() { std::auto_ptr<ActiveQThread> active(new ActiveQThread); active->start(); // start the thread return active; }
bool DashClient::activeInScreen(int screen) const { return active() && m_screen == screen; }
/****************************************************************************** * Called when the user requests a search by clicking the dialog OK button. */ void Find::slotFind() { if (!mDialog) return; mHistory = mDialog->findHistory(); // save search history so that it can be displayed again mOptions = mDialog->options() & ~FIND_KALARM_OPTIONS; mOptions |= (mLive->isEnabled() && mLive->isChecked() ? FIND_LIVE : 0) | (mExpired->isEnabled() && mExpired->isChecked() ? FIND_EXPIRED : 0) | (mMessageType->isEnabled() && mMessageType->isChecked() ? FIND_MESSAGE : 0) | (mFileType->isEnabled() && mFileType->isChecked() ? FIND_FILE : 0) | (mCommandType->isEnabled() && mCommandType->isChecked() ? FIND_COMMAND : 0) | (mEmailType->isEnabled() && mEmailType->isChecked() ? FIND_EMAIL : 0); if (!(mOptions & (FIND_LIVE | FIND_EXPIRED)) || !(mOptions & (FIND_MESSAGE | FIND_FILE | FIND_COMMAND | FIND_EMAIL))) { KMessageBox::sorry(mDialog, i18n("No alarm types are selected to search")); return; } // Supply KFind with only those options which relate to the text within alarms long options = mOptions & (KFindDialog::WholeWordsOnly | KFindDialog::CaseSensitive | KFindDialog::RegularExpression); if (mFind) { mFind->setPattern(mDialog->pattern()); mFind->setOptions(options); delete mDialog; // automatically set to 0 findNext(true, true, false); } else { #ifdef MODAL_FIND mFind = new KFind(mDialog->pattern(), options, mListView); #else mFind = new KFind(mDialog->pattern(), options, mListView, mDialog); #endif connect(mFind, SIGNAL(destroyed()), SLOT(slotKFindDestroyed())); delete mDialog; // close the Find dialogue. Automatically set to 0. mFind->closeFindNextDialog(); // prevent 'Find Next' dialog appearing // Set the starting point for the search mListView->sort(); // ensure the whole list is sorted, not just the visible items mStartID = QString::null; mNoCurrentItem = true; bool fromCurrent = false; EventListViewItemBase* item = 0; if (mOptions & KFindDialog::FromCursor) { item = mListView->currentItem(); if (item) { mStartID = item->event().id(); mNoCurrentItem = false; fromCurrent = true; } } // Execute the search mFound = false; findNext(true, false, fromCurrent); if (mFind) emit active(true); } }
void HttpFileTransfer::fillContextPopup(QMenu * m) { QAction *pAction = m->addAction(__tr2qs_ctx("Abort","http"),this,SLOT(abort())); if(!active()) pAction->setEnabled(false); }
bool GadgetDrive::useActive() const { return active(); }
void Input::Draw() { { int alpha = active() ? 255 : 150; if (reverse_color_) { SetDrawBlendMode(DX_BLENDMODE_INVSRC, alpha); } else { SetDrawBlendMode(DX_BLENDMODE_ALPHA, alpha); } DrawGraph(x_, y_, *input_bg_image_handle_[0], TRUE); DrawGraph(x_ + width_ - 12, y_, *input_bg_image_handle_[1], TRUE); DrawGraph(x_, y_ + height_ - 12, *input_bg_image_handle_[2], TRUE); DrawGraph(x_ + width_ - 12, y_ + height_ - 12, *input_bg_image_handle_[3], TRUE); DrawRectExtendGraphF(x_ + 12, y_, x_ + width_ - 12, y_ + 12, 0, 0, 1, 12, *input_bg_image_handle_[1], TRUE); DrawRectExtendGraphF(x_ + 12, y_ + height_ - 12, x_ + width_ - 12, y_ + height_, 0, 0, 1, 12, *input_bg_image_handle_[3], TRUE); DrawRectExtendGraphF(x_, y_ + 12, x_ + 12, y_ + height_ - 12, 0, 0, 12, 1, *input_bg_image_handle_[2], TRUE); DrawRectExtendGraphF(x_ + width_ - 12, y_ + 12, x_ + width_, y_ + height_ - 12, 0, 0, 12, 1, *input_bg_image_handle_[3], TRUE); DrawRectExtendGraphF(x_ + 12, y_ + 12, x_ + width_ - 12, y_ + height_ - 12, 0, 0, 1, 1, *input_bg_image_handle_[3], TRUE); SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0); } { int internal_x = x_ + INPUT_MARGIN_X; int internal_y = y_ + INPUT_MARGIN_Y; // int internal_width = width_ - INPUT_MARGIN * 2; // int internal_height = height_ - INPUT_MARGIN * 2; // 選択範囲の背景を描画 //int current_line = 0; //for (auto it = selecting_lines_.begin(); it != selecting_lines_.end(); ++it) { // auto line = *it; // if (line.first < line.second) { // SetDrawBlendMode(DX_BLENDMODE_ALPHA, 100); // DrawBox(internal_x + line.first, // internal_y + current_line * font_height_, // internal_x + line.second, // internal_y + (current_line + 1) * font_height_, // GetColor(255, 0, 255), TRUE); // SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0); // } // current_line++; //} int current_line = 0; for (auto it = clause_lines_.begin(); it != clause_lines_.end(); ++it) { auto line = *it; if (line.first < line.second) { SetDrawBlendMode(DX_BLENDMODE_ALPHA, 100); DrawBox(internal_x + line.first, internal_y + current_line * font_height_, internal_x + line.second, internal_y + (current_line + 1) * font_height_, GetColor(0, 255, 255), TRUE); SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0); } current_line++; } current_line = 0; candidate_x_ = -1, candidate_y_ = -1; for (auto it = selecting_clause_lines_.begin(); it != selecting_clause_lines_.end(); ++it) { auto line = *it; if (line.first < line.second) { SetDrawBlendMode(DX_BLENDMODE_ALPHA, 100); DrawBox(internal_x + line.first, internal_y + current_line * font_height_, internal_x + line.second, internal_y + (current_line + 1) * font_height_, GetColor(255, 0, 255), TRUE); SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0); if (candidate_x_ < 0) { candidate_x_ = line.first; candidate_y_ = (current_line + 1) * font_height_; } } current_line++; } int text_color = reverse_color_ ? GetColor(255, 255, 255) : GetColor(0, 0, 0); current_line = 0; if (message_lines_.size() > 0) { for (auto it = message_lines_.begin(); it != message_lines_.end(); ++it) { auto line = *it; SetDrawBlendMode(DX_BLENDMODE_ALPHA, 140); DrawStringToHandle(internal_x, internal_y + current_line * font_height_ - 3, line.c_str(), text_color, font_handle_); SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0); current_line++; } } for (auto it = lines_.begin(); it != lines_.end(); ++it) { auto line = *it; DrawStringToHandle(internal_x, internal_y + current_line * font_height_, line.c_str(), text_color, font_handle_); current_line++; } // カーソルを描画 if (clause_lines_.size() <= 0 && active() && blink_count_ < 30) { DrawBox(internal_x + cursor_x_, internal_y + cursor_y_, internal_x + cursor_x_ + 2, internal_y + cursor_y_ + font_height_, text_color, TRUE); } } { int internal_x = x_ + INPUT_MARGIN_X; int internal_y = y_ + INPUT_MARGIN_Y; if (selecting_candidate_ >= 0) { int start_index = (selecting_candidate_ / IME_MAX_PAGE_SIZE) * IME_MAX_PAGE_SIZE; int end_index = std::min(start_index + IME_MAX_PAGE_SIZE, static_cast<int>(candidates_.size() - 1)); int x = candidate_x_; int y; int width = IME_MIN_WIDTH; int height = (end_index - start_index) * font_height_; for (int i = start_index; i < end_index; i++) { auto candidate = candidates_[i]; width = std::max(width, GetDrawStringWidthToHandle(candidate.c_str(), candidate.size(), font_handle_)); } int screen_height; GetScreenState(nullptr, &screen_height, nullptr); if (internal_y + height + candidate_x_ >= screen_height - IME_MARGIN_Y * 2) { y = candidate_y_ - font_height_ - height - IME_MARGIN_Y; } else { y = candidate_y_ + IME_MARGIN_Y; } if (height > 0) { int base_x = internal_x + x - IME_MARGIN_BASE; int base_y = internal_y + y - IME_MARGIN_BASE; int base_width = width + IME_MARGIN_BASE * 2; int base_height = height + IME_MARGIN_BASE * 2; DrawGraph(base_x, base_y, *ime_image_handle_[0], TRUE); DrawGraph(base_x + base_width - 12, base_y, *ime_image_handle_[1], TRUE); DrawGraph(base_x, base_y + base_height - 12, *ime_image_handle_[2], TRUE); DrawGraph(base_x + base_width - 12, base_y + base_height - 12, *ime_image_handle_[3], TRUE); DrawRectExtendGraphF(base_x + 12, base_y, base_x + base_width - 12, base_y + 12, 0, 0, 1, 12, *ime_image_handle_[1], TRUE); DrawRectExtendGraphF(base_x + 12, base_y + base_height - 12, base_x + base_width - 12, base_y + base_height, 0, 0, 1, 12, *ime_image_handle_[3], TRUE); DrawRectExtendGraphF(base_x, base_y + 12, base_x + 12, base_y + base_height - 12, 0, 0, 12, 1, *ime_image_handle_[2], TRUE); DrawRectExtendGraphF(base_x + base_width - 12, base_y + 12, base_x + base_width, base_y + base_height - 12, 0, 0, 12, 1, *ime_image_handle_[3], TRUE); DrawRectExtendGraphF(base_x + 12, base_y + 12, base_x + base_width - 12, base_y + base_height - 12, 0, 0, 1, 1, *ime_image_handle_[3], TRUE); } int line_top = 0; for (int i = start_index; i < end_index; i++) { if (i == selecting_candidate_) { SetDrawBlendMode(DX_BLENDMODE_ALPHA, 100); DrawBox(internal_x + x - 2, internal_y + line_top + y, internal_x + x + width + 2, internal_y + line_top + y + font_height_, GetColor(255, 0, 255), TRUE); SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0); } DrawStringToHandle(internal_x + x, internal_y + line_top + y, candidates_[i].c_str(), GetColor(0, 0, 0), font_handle_); line_top += font_height_; } } } }
float GadgetDrive::addThrust() const { return( active() ? thrust() * damageRatioInv() : 0.0f ); }
bool GadgetELF::useActive() const { return active(); }
/*! Returns true if there is an outgoing call currently dialing, but not yet connected. */ bool DialerControl::isDialing() const { return active().dialing(); }
void CSSSelector::extractPseudoType() const { if (m_match != PseudoClass && m_match != PseudoElement) return; AtomicString active("active"); AtomicString after("after"); AtomicString anyLink("-webkit-any-link"); AtomicString autofill("-webkit-autofill"); AtomicString before("before"); AtomicString checked("checked"); AtomicString fileUploadButton("-webkit-file-upload-button"); AtomicString disabled("disabled"); AtomicString drag("-webkit-drag"); AtomicString dragAlias("-khtml-drag"); // was documented with this name in Apple documentation, so keep an alias AtomicString empty("empty"); AtomicString enabled("enabled"); AtomicString firstChild("first-child"); AtomicString firstLetter("first-letter"); AtomicString firstLine("first-line"); AtomicString firstOfType("first-of-type"); AtomicString nthChild("nth-child("); AtomicString nthOfType("nth-of-type("); AtomicString nthLastChild("nth-last-child("); AtomicString nthLastOfType("nth-last-of-type("); AtomicString focus("focus"); AtomicString hover("hover"); AtomicString indeterminate("indeterminate"); AtomicString lastChild("last-child"); AtomicString lastOfType("last-of-type"); AtomicString link("link"); AtomicString lang("lang("); AtomicString mediaControlsPanel("-webkit-media-controls-panel"); AtomicString mediaControlsMuteButton("-webkit-media-controls-mute-button"); AtomicString mediaControlsPlayButton("-webkit-media-controls-play-button"); AtomicString mediaControlsTimeDisplay("-webkit-media-controls-time-display"); AtomicString mediaControlsTimeline("-webkit-media-controls-timeline"); AtomicString mediaControlsSeekBackButton("-webkit-media-controls-seek-back-button"); AtomicString mediaControlsSeekForwardButton("-webkit-media-controls-seek-forward-button"); AtomicString mediaControlsFullscreenButton("-webkit-media-controls-fullscreen-button"); AtomicString notStr("not("); AtomicString onlyChild("only-child"); AtomicString onlyOfType("only-of-type"); AtomicString root("root"); AtomicString searchCancelButton("-webkit-search-cancel-button"); AtomicString searchDecoration("-webkit-search-decoration"); AtomicString searchResultsDecoration("-webkit-search-results-decoration"); AtomicString searchResultsButton("-webkit-search-results-button"); AtomicString selection("selection"); AtomicString sliderThumb("-webkit-slider-thumb"); AtomicString target("target"); AtomicString visited("visited"); bool element = false; // pseudo-element bool compat = false; // single colon compatbility mode m_pseudoType = PseudoUnknown; if (m_value == active) m_pseudoType = PseudoActive; else if (m_value == after) { m_pseudoType = PseudoAfter; element = true; compat = true; } else if (m_value == anyLink) m_pseudoType = PseudoAnyLink; else if (m_value == autofill) m_pseudoType = PseudoAutofill; else if (m_value == before) { m_pseudoType = PseudoBefore; element = true; compat = true; } else if (m_value == checked) m_pseudoType = PseudoChecked; else if (m_value == fileUploadButton) { m_pseudoType = PseudoFileUploadButton; element = true; } else if (m_value == disabled) m_pseudoType = PseudoDisabled; else if (m_value == drag || m_value == dragAlias) m_pseudoType = PseudoDrag; else if (m_value == enabled) m_pseudoType = PseudoEnabled; else if (m_value == empty) m_pseudoType = PseudoEmpty; else if (m_value == firstChild) m_pseudoType = PseudoFirstChild; else if (m_value == lastChild) m_pseudoType = PseudoLastChild; else if (m_value == lastOfType) m_pseudoType = PseudoLastOfType; else if (m_value == onlyChild) m_pseudoType = PseudoOnlyChild; else if (m_value == onlyOfType) m_pseudoType = PseudoOnlyOfType; else if (m_value == firstLetter) { m_pseudoType = PseudoFirstLetter; element = true; compat = true; } else if (m_value == firstLine) { m_pseudoType = PseudoFirstLine; element = true; compat = true; } else if (m_value == firstOfType) m_pseudoType = PseudoFirstOfType; else if (m_value == focus) m_pseudoType = PseudoFocus; else if (m_value == hover) m_pseudoType = PseudoHover; else if (m_value == indeterminate) m_pseudoType = PseudoIndeterminate; else if (m_value == link) m_pseudoType = PseudoLink; else if (m_value == lang) m_pseudoType = PseudoLang; else if (m_value == mediaControlsPanel) { m_pseudoType = PseudoMediaControlsPanel; element = true; } else if (m_value == mediaControlsMuteButton) { m_pseudoType = PseudoMediaControlsMuteButton; element = true; } else if (m_value == mediaControlsPlayButton) { m_pseudoType = PseudoMediaControlsPlayButton; element = true; } else if (m_value == mediaControlsTimeDisplay) { m_pseudoType = PseudoMediaControlsTimeDisplay; element = true; } else if (m_value == mediaControlsTimeline) { m_pseudoType = PseudoMediaControlsTimeline; element = true; } else if (m_value == mediaControlsSeekBackButton) { m_pseudoType = PseudoMediaControlsSeekBackButton; element = true; } else if (m_value == mediaControlsSeekForwardButton) { m_pseudoType = PseudoMediaControlsSeekForwardButton; element = true; } else if (m_value == mediaControlsFullscreenButton) { m_pseudoType = PseudoMediaControlsFullscreenButton; element = true; } else if (m_value == notStr) m_pseudoType = PseudoNot; else if (m_value == nthChild) m_pseudoType = PseudoNthChild; else if (m_value == nthOfType) m_pseudoType = PseudoNthOfType; else if (m_value == nthLastChild) m_pseudoType = PseudoNthLastChild; else if (m_value == nthLastOfType) m_pseudoType = PseudoNthLastOfType; else if (m_value == root) m_pseudoType = PseudoRoot; else if (m_value == searchCancelButton) { m_pseudoType = PseudoSearchCancelButton; element = true; } else if (m_value == searchDecoration) { m_pseudoType = PseudoSearchDecoration; element = true; } else if (m_value == searchResultsDecoration) { m_pseudoType = PseudoSearchResultsDecoration; element = true; } else if (m_value == searchResultsButton) { m_pseudoType = PseudoSearchResultsButton; element = true; } else if (m_value == selection) { m_pseudoType = PseudoSelection; element = true; } else if (m_value == sliderThumb) { m_pseudoType = PseudoSliderThumb; element = true; } else if (m_value == target) m_pseudoType = PseudoTarget; else if (m_value == visited) m_pseudoType = PseudoVisited; if (m_match == PseudoClass && element) { if (!compat) m_pseudoType = PseudoUnknown; else m_match = PseudoElement; } else if (m_match == PseudoElement && !element) m_pseudoType = PseudoUnknown; }
void InformWindow::run() { show(true); active(true); }
void Best::localSearch( const std::vector<Graph> &graphs, Solution &solution ) { size_t m = solution.alignment.size1(); size_t n = solution.alignment.size2(); // Create reverse alignment mapping std::vector<std::vector<size_t>> map; create_map(graphs, solution, map); // Count number of graphs each edge is covered in edge_count_matrix edges; count_edges(graphs, map, solution, edges); // Build neighbor lists std::vector<neighbor_list> neighbors; create_neighbor_lists(graphs, map, solution, neighbors); // Active index map std::vector<int> active(m, 0); std::random_device rd; std::minstd_rand rand_gen(rd()); int iteration = 0; bool repeat; do { repeat = false; for(size_t g = 0; g < n-1; ++g) { int best_delta = 0; size_t best_i = 0; size_t best_j = 0; #pragma omp parallel { int prv_best_delta = 0; size_t prv_best_i = 0; size_t prv_best_j = 0; #pragma omp for schedule(static, 1) for(size_t i = 0; i < m; ++i) { for(size_t j = i+1; j < m; ++j) { if(active[i] < iteration && active[j] < iteration) continue; int delta = get_delta(i, j, g, neighbors, edges); if(delta > 0) { active[i] = iteration+1; active[j] = iteration+1; } if(delta > prv_best_delta) { prv_best_delta = delta; prv_best_i = i; prv_best_j = j; } } } #pragma omp critical { if(prv_best_delta > best_delta) { best_delta = prv_best_delta; best_i = prv_best_i; best_j = prv_best_j; } } } if(best_delta > 0) { repeat = true; swap(best_i, best_j, g, iteration, neighbors, edges, solution, active); } } iteration++; } while(repeat); // Extract LCS and solution quality finalize(edges, solution); }
int gActionChannel::handle(int e) { int ret = Fl_Group::handle(e); /* do nothing if the widget is deactivated. It could happen for loopmode * channels */ if (!active()) return 1; switch (e) { case FL_DRAG: { if (selected != NULL) { // if you don't drag an empty area /* if onLeftEdge o onRightEdge are true it means that you're resizing * an action. Otherwise move the widget. */ if (selected->onLeftEdge || selected->onRightEdge) { /* some checks: a) cannot resize an action < N pixels, b) no beyond zero, * c) no beyond bar maxwidth. Checks for overlap are done in FL_RELEASE */ if (selected->onRightEdge) { int aw = Fl::event_x()-selected->x(); int ah = selected->h(); if (Fl::event_x() < selected->x()+gAction::MIN_WIDTH) aw = gAction::MIN_WIDTH; else if (Fl::event_x() > parent->coverX) aw = parent->coverX-selected->x(); selected->size(aw, ah); } else { int ax = Fl::event_x(); int ay = selected->y(); int aw = selected->x()-Fl::event_x()+selected->w(); int ah = selected->h(); if (Fl::event_x() < x()) { ax = x(); aw = selected->w()+selected->x()-x(); } else if (Fl::event_x() > selected->x()+selected->w()-gAction::MIN_WIDTH) { ax = selected->x()+selected->w()-gAction::MIN_WIDTH; aw = gAction::MIN_WIDTH; } selected->resize(ax, ay, aw, ah); } } /* move the widget around */ else { int real_x = Fl::event_x() - actionPickPoint; if (real_x < x()) // don't go beyond the left border selected->position(x(), selected->y()); else if (real_x+selected->w() > parent->coverX) // don't go beyond the right border selected->position(parent->coverX-selected->w(), selected->y()); else { if (parent->gridTool->isOn()) { int snpx = parent->gridTool->getSnapPoint(real_x) +x() -1; selected->position(snpx, selected->y()); } else selected->position(real_x, selected->y()); } } redraw(); } ret = 1; break; } case FL_PUSH: { if (Fl::event_button1()) { /* avoid at all costs two overlapping actions. We use 'selected' because * the selected action can be reused in FL_DRAG, in case you want to move * it. */ selected = getSelectedAction(); if (selected == NULL) { /* avoid click on grey area */ if (Fl::event_x() >= parent->coverX) { ret = 1; break; } gAction *a = new gAction( Fl::event_x(), // x y()+4, // y h()-8, // h ((Fl::event_x()-x())*parent->zoom)*2, // actual frame recorder::frames.size-1, // n. of actions recorded parent, // parent window pointer true, // record = true: record it! parent->getActionType()); // type of action add(a); glue_setChannelWithActions(parent->chan); // mainWindow update redraw(); ret = 1; } else { actionOriginalX = selected->x(); actionOriginalW = selected->w(); actionPickPoint = Fl::event_x() - selected->x(); ret = 1; // for dragging } } else if (Fl::event_button3()) { gAction *a = getSelectedAction(); if (a != NULL) { a->delAction(); remove(a); delete a; glue_setChannelWithActions(parent->chan); redraw(); ret = 1; } } break; } case FL_RELEASE: { if (selected == NULL) { ret = 1; break; } /* noChanges = true when you click on an action without doing anything * (dragging or moving it). */ bool noChanges = false; if (actionOriginalX == selected->x()) noChanges = true; if (G_Mixer.chanMode[parent->chan] == SINGLE_PRESS && actionOriginalX+actionOriginalW != selected->x()+selected->w()) noChanges = false; if (noChanges) { ret = 1; selected = NULL; break; } /* step 1: check if the action doesn't overlap with another one. * In case of overlap the moved action returns to the original X * value ("actionOriginalX"). */ bool overlap = false; for (int i=0; i<children() && !overlap; i++) { /* never check against itself. */ if ((gAction*)child(i) == selected) continue; int action_x = ((gAction*)child(i))->x(); int action_w = ((gAction*)child(i))->w(); if (G_Mixer.chanMode[parent->chan] == SINGLE_PRESS) { /* when 2 segments overlap? * start = the highest value between the two starting points * end = the lowest value between the two ending points * if start < end then there's an overlap of end-start pixels. */ int start = action_x >= selected->x() ? action_x : selected->x(); int end = action_x+action_w < selected->x()+selected->w() ? action_x+action_w : selected->x()+selected->w(); if (start < end) { selected->resize(actionOriginalX, selected->y(), actionOriginalW, selected->h()); redraw(); overlap = true; // one overlap: stop checking } } else { if (selected->x() == action_x) { selected->position(actionOriginalX, selected->y()); redraw(); overlap = true; // one overlap: stop checking } } } /* step 2: no overlap? then update the coordinates of the action, ie * delete the previous rec and create a new one. * Anyway the selected action becomes NULL, because when you release * the mouse button the dragging process ends. */ if (!overlap) selected->moveAction(); selected = NULL; ret = 1; break; } } return ret; }
void CControllerAura::update_schedule() { if (!m_object->g_Alive()) return; float dist_to_actor = Actor()->Position().distance_to(m_object->Position()); if ((dist_to_actor > aura_radius + FAKE_MIN_ADD_DIST) && (dist_to_actor < aura_radius + FAKE_MAX_ADD_DIST)) { // first time? if (m_time_fake_aura == 0) { m_time_fake_aura = time() + 5000 + Random.randI(FAKE_AURA_DELAY); if (active()) { m_effector->switch_off (); m_effector = 0; } } else { if (active()) { // check to stop if (m_time_fake_aura < time()) { m_effector->switch_off (); m_effector = 0; m_time_fake_aura = time() + 5000 + Random.randI(FAKE_AURA_DELAY); } } else { // check to start if (m_time_fake_aura < time()) { m_effector = new CPPEffectorControllerAura(m_state, 5000, aura_sound.left, aura_sound.right); Actor()->Cameras().AddPPEffector (m_effector); m_time_fake_aura = time() + 5000 + Random.randI(FAKE_AURA_DURATION); } } } } else { m_time_fake_aura = 0; bool need_be_active = (dist_to_actor < aura_radius); if (active()) { if (!need_be_active) { m_effector->switch_off (); m_effector = 0; m_hit_state = eNone; } else { } } else { if (need_be_active) { // create effector m_effector = new CPPEffectorControllerAura(m_state, 5000, aura_sound.left, aura_sound.right); Actor()->Cameras().AddPPEffector (m_effector); m_hit_state = eEffectoring; m_time_started = time(); } else { } } } if (active()) { CEffectorCam* ce = Actor()->Cameras().GetCamEffector((ECamEffectorType)effControllerAura2); if(!ce) AddEffector(Actor(), effControllerAura2, "effector_controller_aura2", 0.15f); }else{ CEffectorCam* ce = Actor()->Cameras().GetCamEffector((ECamEffectorType)effControllerAura2); if(ce) RemoveEffector(Actor(), effControllerAura2); } }
void UdpServerThread::run() { LOG_ASSERT(udpServer != NULL); VSockAddrList& sockAddrList = udpServer->sockAddrList; // for abbreviate VUdpSession* udpSession = udpServer->udpSession; // for abbreviate // fireEvent(new MsgEvent("******** connected ********")); // gilgil temp 2014.03.01 fireEvent(new StateEvent(VState::Opened)); while (active()) { QByteArray ba; int readLen = udpServer->read(ba); // // Delete session // if (readLen == VERR_FAIL) { QString msg = udpSession->error.msg; fireEvent(new MsgEvent(msg, QThread::currentThreadId())); if (udpSession->error.code == 10054/*WSAECONNRESET*/) // ICMP Destination Unreachable // gilgil temp 2014.04.18 { while (true) { VSockAddrList::iterator it = sockAddrList.findByInAddr(udpSession->addr.sin_addr); if (it == sockAddrList.end()) break; sockAddrList.erase(it); } LOG_DEBUG("count=%d", sockAddrList.size()); // gilgi temp 2009.08.16 } else // other error { VSockAddrList::iterator it = sockAddrList.findBySockAddr(udpSession->addr); if (it != sockAddrList.end()) sockAddrList.erase(it); LOG_DEBUG("count=%d", sockAddrList.size()); // gilgi temp 2009.08.16 } udpSession->error.clear(); continue; } // // Add session // if (sockAddrList.findBySockAddr(udpSession->addr) == sockAddrList.end()) { SOCKADDR_IN* newSockAddr = new SOCKADDR_IN; *newSockAddr = udpSession->addr; sockAddrList.insert(*newSockAddr); LOG_DEBUG("count=%d", sockAddrList.size()); // gilgi temp 2009.08.16 } if (widget->ui->chkShowHexa->checkState() == Qt::Checked) ba = ba.toHex(); QString msg = ba; fireEvent(new MsgEvent(msg, QThread::currentThreadId())); if (widget->ui->chkEcho->checkState() == Qt::Checked) { if (widget->ui->chkEchoBroadcast->checkState() == Qt::Checked) { udpServer->write(ba); // do not check result } else { int writeLen = udpSession->write(ba); if (writeLen == VERR_FAIL) break; } } } // fireEvent(new MsgEvent("******** disconnected ********")); // gilgil temp 2014.03.01 fireEvent(new CloseEvent); }