int runQVfb( int argc, char *argv[] ) { Q_INIT_RESOURCE(qvfb); QApplication app( argc, argv ); QTranslator translator; QTranslator qtTranslator; QString sysLocale = QLocale::system().name(); QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath); if (translator.load(QLatin1String("qvfb_") + sysLocale, resourceDir) && qtTranslator.load(QLatin1String("qt_") + sysLocale, resourceDir)) { app.installTranslator(&translator); app.installTranslator(&qtTranslator); } int width = 0; int height = 0; int depth = -32; // default, but overridable by skin bool depthSet = false; int rotation = 0; bool cursor = true; QVFb::DisplayType displayType = QVFb::QWS; double zoom = 1.0; QString displaySpec( ":0" ); QString skin; for ( int i = 1; i < argc; i++ ){ QString arg = argv[i]; if ( arg == "-width" ) { width = atoi( argv[++i] ); } else if ( arg == "-height" ) { height = atoi( argv[++i] ); } else if ( arg == "-skin" ) { skin = argv[++i]; } else if ( arg == "-depth" ) { depth = atoi( argv[++i] ); depthSet = true; } else if ( arg == "-nocursor" ) { cursor = false; } else if ( arg == "-mmap" ) { qvfb_protocol = 1; } else if ( arg == "-zoom" ) { zoom = atof( argv[++i] ); } else if ( arg == "-qwsdisplay" ) { displaySpec = argv[++i]; displayType = QVFb::QWS; #ifdef Q_WS_X11 } else if ( arg == "-x11display" ) { displaySpec = argv[++i]; displayType = QVFb::X11; // Usually only the default X11 depth will work with Xnest, // so override the default of 32 with the actual X11 depth. if (!depthSet) depth = -QX11Info::appDepth(); // default, but overridable by skin #endif } else { printf( "Unknown parameter %s\n", arg.toLatin1().constData() ); usage( argv[0] ); exit(1); } } int displayId = 0; QRegExp r( ":[0-9]+" ); int m = r.indexIn( displaySpec, 0 ); int len = r.matchedLength(); if ( m >= 0 ) { displayId = displaySpec.mid( m+1, len-1 ).toInt(); } QRegExp rotRegExp( "Rot[0-9]+" ); m = rotRegExp.indexIn( displaySpec, 0 ); len = rotRegExp.matchedLength(); if ( m >= 0 ) { rotation = displaySpec.mid( m+3, len-3 ).toInt(); } signal(SIGINT, fn_quit_qvfb); signal(SIGTERM, fn_quit_qvfb); QVFb mw( displayId, width, height, depth, rotation, skin, displayType ); mw.setZoom(zoom); //app.setMainWidget( &mw ); mw.enableCursor(cursor); mw.show(); return app.exec(); }
bool pack_rectangle(int* px, int* py, int width, int height) // Find a spot for the rectangle in the current cache image. // Return true if there's a spot; false if there's no room. { // Nice algo, due to JARE: // // * keep a list of "candidate points"; initialize it with {0,0} // // * each time we add a rect, add its lower-left and // upper-right as candidate points. // // * search the candidate points only, when looking // for a good spot. If we find a good one, also try // scanning left or up as well; sometimes this can // close some open space. // // * when we use a candidate point, remove it from the list. // Consider candidate spots. for (int i = 0, n = s_anchor_points.size(); i < n; i++) { const pointi& p = s_anchor_points[i]; recti r(p.m_x, p.m_x + width, p.m_y, p.m_y + height); // Is this spot any good? if (is_rect_available(r)) { // Good spot. Scan left to see if we can tighten it up. while (r.m_x_min > 0) { recti r2(r.m_x_min - 1, r.m_x_min - 1 + width, r.m_y_min, r.m_y_min + height); if (is_rect_available(r2)) { // Shift left. r = r2; } else { // Not clear; stop scanning. break; } } // Mark our covered rect; remove newly covered anchors. add_cover_rect(r); // Found our desired spot. Add new // candidate points to the anchor list. add_anchor_point(pointi(r.m_x_min, r.m_y_max)); // lower-left add_anchor_point(pointi(r.m_x_max, r.m_y_min)); // upper-right *px = r.m_x_min; *py = r.m_y_min; return true; } } // Couldn't find a good spot. return false; }
Matrix Matrix::frobeniusNormalized() const{ Matrix r(*this); double m = 1.0 / frobeniusNorm(); r.map([=](double v){return v*m;}); return r; }
// Acceps a query, calls the SAT solver and generates Valid/InValid. // if returned 0 then input is INVALID if returned 1 then input is // VALID if returned 2 then UNDECIDED SOLVER_RETURN_TYPE STP::TopLevelSTPAux(SATSolver& NewSolver, const ASTNode& original_input) { bm->ASTNodeStats("input asserts and query: ", original_input); DifficultyScore difficulty; if (bm->UserFlags.stats_flag) cerr << "Difficulty Initially:" << difficulty.score(original_input) << endl; // A heap object so I can easily control its lifetime. std::auto_ptr<BVSolver> bvSolver(new BVSolver(bm, simp)); std::auto_ptr<PropagateEqualities> pe( new PropagateEqualities(simp, bm->defaultNodeFactory, bm)); ASTNode inputToSat = original_input; // If the number of array reads is small. We rewrite them through. // The bit-vector simplifications are more thorough than the array // simplifications. For example, // we don't currently do unconstrained elimination on arrays--- but we do for // bit-vectors. // A better way to do this would be to estimate the number of axioms // introduced. // TODO: I chose the number of reads we perform this operation at randomly. bool removed = false; if (((bm->UserFlags.ackermannisation && numberOfReadsLessThan(inputToSat, 50)) || bm->UserFlags.isSet("upfront-ack", "0")) || numberOfReadsLessThan(inputToSat, 10)) { // If the number of axioms that would be added it small. Remove them. bm->UserFlags.ackermannisation = true; inputToSat = arrayTransformer->TransformFormula_TopLevel(inputToSat); if (bm->UserFlags.stats_flag) { cerr << "Have removed array operations" << endl; } removed = true; } const bool arrayops = containsArrayOps(inputToSat); if (removed) { assert(!arrayops); } // Run size reducing just once. inputToSat = sizeReducing(inputToSat, bvSolver.get(), pe.get()); unsigned initial_difficulty_score = difficulty.score(inputToSat); int bitblasted_difficulty = -1; // Fixed point it if it's not too difficult. // Currently we discards all the state each time sizeReducing is called, // so it's expensive to call. if ((!arrayops && initial_difficulty_score < 1000000) || bm->UserFlags.isSet("preserving-fixedpoint", "0")) { inputToSat = callSizeReducing(inputToSat, bvSolver.get(), pe.get(), initial_difficulty_score, bitblasted_difficulty); } if ((!arrayops || bm->UserFlags.isSet("array-difficulty-reversion", "1"))) { initial_difficulty_score = difficulty.score(inputToSat); } if (bitblasted_difficulty != -1 && bm->UserFlags.stats_flag) cout << "Initial Bitblasted size:" << bitblasted_difficulty << endl; if (bm->UserFlags.stats_flag) cout << "Difficulty After Size reducing:" << initial_difficulty_score << endl; // So we can delete the object and release all the hash-buckets storage. std::auto_ptr<Revert_to> revert(new Revert_to()); if ((!arrayops || bm->UserFlags.isSet("array-difficulty-reversion", "1"))) { revert->initialSolverMap.insert(simp->Return_SolverMap()->begin(), simp->Return_SolverMap()->end()); revert->backup_arrayToIndexToRead.insert( arrayTransformer->arrayToIndexToRead.begin(), arrayTransformer->arrayToIndexToRead.end()); revert->toRevertTo = inputToSat; } // round of substitution, solving, and simplification. ensures that // DAG is minimized as much as possibly, and ideally should // garuntee that all liketerms in BVPLUSes have been combined. bm->SimplifyWrites_InPlace_Flag = false; // bm->Begin_RemoveWrites = false; // bm->start_abstracting = false; bm->TermsAlreadySeenMap_Clear(); ASTNode tmp_inputToSAT; do { tmp_inputToSAT = inputToSat; if (bm->soft_timeout_expired) return SOLVER_TIMEOUT; if (bm->UserFlags.optimize_flag) { inputToSat = pe->topLevel(inputToSat, arrayTransformer); // Imagine: // The simplifier simplifies (0 + T) to T // Then bvsolve introduces (0 + T) // Then CreateSubstitutionMap decides T maps to a constant, but leaving // another (0+T). // When we go to simplify (0 + T) will still be in the simplify cache, so // will be mapped to T. // But it shouldn't be T, it should be a constant. // Applying the substitution map fixes this case. // if (simp->hasUnappliedSubstitutions()) { inputToSat = simp->applySubstitutionMap(inputToSat); simp->haveAppliedSubstitutionMap(); } bm->ASTNodeStats(pe_message.c_str(), inputToSat); inputToSat = simp->SimplifyFormula_TopLevel(inputToSat, false); bm->ASTNodeStats(size_inc_message.c_str(), inputToSat); } if (bm->UserFlags.wordlevel_solve_flag && bm->UserFlags.optimize_flag) { inputToSat = bvSolver->TopLevelBVSolve(inputToSat); bm->ASTNodeStats(bitvec_message.c_str(), inputToSat); } } while (tmp_inputToSAT != inputToSat); if (bm->UserFlags.bitConstantProp_flag) { bm->GetRunTimes()->start(RunTimes::ConstantBitPropagation); simplifier::constantBitP::ConstantBitPropagation cb( simp, bm->defaultNodeFactory, inputToSat); inputToSat = cb.topLevelBothWays(inputToSat); bm->GetRunTimes()->stop(RunTimes::ConstantBitPropagation); if (cb.isUnsatisfiable()) { inputToSat = bm->ASTFalse; } bm->ASTNodeStats(cb_message.c_str(), inputToSat); } if (bm->UserFlags.isSet("use-intervals", "1")) { EstablishIntervals intervals(*bm); inputToSat = intervals.topLevel_unsignedIntervals(inputToSat); bm->ASTNodeStats(int_message.c_str(), inputToSat); } // Find pure literals. if (bm->UserFlags.isSet("pure-literals", "1")) { FindPureLiterals fpl; bool changed = fpl.topLevel(inputToSat, simp, bm); if (changed) { inputToSat = simp->applySubstitutionMap(inputToSat); simp->haveAppliedSubstitutionMap(); bm->ASTNodeStats(pl_message.c_str(), inputToSat); } } if (bm->soft_timeout_expired) return SOLVER_TIMEOUT; // Simplify using Ite context if (bm->UserFlags.optimize_flag && bm->UserFlags.isSet("ite-context", "0")) { UseITEContext iteC(bm); inputToSat = iteC.topLevel(inputToSat); bm->ASTNodeStats("After ITE Context: ", inputToSat); } if (bm->UserFlags.isSet("aig-core-simplify", "0")) { AIGSimplifyPropositionalCore aigRR(bm); inputToSat = aigRR.topLevel(inputToSat); bm->ASTNodeStats("After AIG Core: ", inputToSat); } if (bm->UserFlags.isSet("enable-unconstrained", "1")) { // Remove unconstrained. RemoveUnconstrained r(*bm); inputToSat = r.topLevel(inputToSat, simp); bm->ASTNodeStats(uc_message.c_str(), inputToSat); } bm->TermsAlreadySeenMap_Clear(); // bm->start_abstracting = false; bm->SimplifyWrites_InPlace_Flag = false; // bm->Begin_RemoveWrites = false; long final_difficulty_score = difficulty.score(inputToSat); bool worse = false; if (final_difficulty_score > 1.1 * initial_difficulty_score) worse = true; // It's of course very wasteful to do this! Later I'll make it reuse the // work..We bit-blast again, in order to throw it away, so that we can // measure whether the number of AIG nodes is smaller. The difficulty score // is sometimes completelywrong, the sage-app7 are the motivating examples. // The other way to improve it would be to fix the difficulty scorer! if (!worse && (bitblasted_difficulty != -1)) { BBNodeManagerAIG bitblast_nodemgr; BitBlaster<BBNodeAIG, BBNodeManagerAIG> bb( &bitblast_nodemgr, simp, bm->defaultNodeFactory, &(bm->UserFlags)); bb.BBForm(inputToSat); int newBB = bitblast_nodemgr.totalNumberOfNodes(); if (bm->UserFlags.stats_flag) cerr << "Final BB Size:" << newBB << endl; if (bitblasted_difficulty < newBB) worse = true; } if (bm->UserFlags.stats_flag) { cerr << "Initial Difficulty Score:" << initial_difficulty_score << endl; cerr << "Final Difficulty Score:" << final_difficulty_score << endl; } bool optimize_enabled = bm->UserFlags.optimize_flag; if (worse && (!arrayops || bm->UserFlags.isSet("array-difficulty-reversion", "1")) && bm->UserFlags.isSet("difficulty-reversion", "1")) { // If the simplified problem is harder, than the // initial problem we revert back to the initial // problem. if (bm->UserFlags.stats_flag) cerr << "simplification made the problem harder, reverting." << endl; inputToSat = revert->toRevertTo; // I do this to clear the substitution/solver map. // Not sure what would happen if it contained simplifications // that haven't been applied. simp->ClearAllTables(); simp->Return_SolverMap()->insert(revert->initialSolverMap.begin(), revert->initialSolverMap.end()); revert->initialSolverMap.clear(); // Copy back what we knew about arrays at the start.. arrayTransformer->arrayToIndexToRead.clear(); arrayTransformer->arrayToIndexToRead.insert( revert->backup_arrayToIndexToRead.begin(), revert->backup_arrayToIndexToRead.end()); // The arrayTransformer calls simplify. We don't want // it to put back in all the bad simplifications. bm->UserFlags.optimize_flag = false; } revert.reset(NULL); inputToSat = arrayTransformer->TransformFormula_TopLevel(inputToSat); bm->ASTNodeStats("after transformation: ", inputToSat); bm->TermsAlreadySeenMap_Clear(); bm->UserFlags.optimize_flag = optimize_enabled; SOLVER_RETURN_TYPE res; if (!bm->UserFlags.ackermannisation) { bm->counterexample_checking_during_refinement = true; } // We are about to solve. Clear out all the memory associated with caches // that we won't need again. simp->ClearCaches(); simp->haveAppliedSubstitutionMap(); bm->ClearAllTables(); // Deleting it clears out all the buckets associated with hashmaps etc. too. bvSolver.reset(NULL); pe.reset(NULL); if (bm->UserFlags.stats_flag) simp->printCacheStatus(); const bool maybeRefinement = arrayops && !bm->UserFlags.ackermannisation; simplifier::constantBitP::ConstantBitPropagation* cb = NULL; std::auto_ptr<simplifier::constantBitP::ConstantBitPropagation> cleaner; if (bm->UserFlags.bitConstantProp_flag) { bm->GetRunTimes()->start(RunTimes::ConstantBitPropagation); cb = new simplifier::constantBitP::ConstantBitPropagation( simp, bm->defaultNodeFactory, inputToSat); cleaner.reset(cb); bm->GetRunTimes()->stop(RunTimes::ConstantBitPropagation); bm->ASTNodeStats(cb_message.c_str(), inputToSat); if (cb->isUnsatisfiable()) inputToSat = bm->ASTFalse; } ToSATAIG toSATAIG(bm, cb, arrayTransformer); ToSATBase* satBase = bm->UserFlags.isSet("traditional-cnf", "0") ? tosat : &toSATAIG; if (bm->soft_timeout_expired) return SOLVER_TIMEOUT; // If it doesn't contain array operations, use ABC's CNF generation. res = Ctr_Example->CallSAT_ResultCheck( NewSolver, inputToSat, original_input, satBase, maybeRefinement); if (bm->soft_timeout_expired) { if (toSATAIG.cbIsDestructed()) cleaner.release(); return SOLVER_TIMEOUT; } if (SOLVER_UNDECIDED != res) { // If the aig converter knows that it is never going to be called again, // it deletes the constant bit stuff before calling the SAT solver. if (toSATAIG.cbIsDestructed()) cleaner.release(); CountersAndStats("print_func_stats", bm); return res; } // should only go to abstraction refinement if there are array ops. assert(arrayops); assert(!bm->UserFlags.ackermannisation); // Refinement must be enabled too. res = Ctr_Example->SATBased_ArrayReadRefinement( NewSolver, inputToSat, original_input, satBase); if (SOLVER_UNDECIDED != res) { if (toSATAIG.cbIsDestructed()) cleaner.release(); CountersAndStats("print_func_stats", bm); return res; } FatalError("TopLevelSTPAux: reached the end without proper conclusion:" "either a divide by zero in the input or a bug in STP"); // bogus return to make the compiler shut up return SOLVER_ERROR; }
void Graphic::Update() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); int width, height; glfwGetWindowSize( &width, &height ); float nearClip = 1.0f, farClip = 1000.0f, fovDeg = 45.0f, aspect = (float)width / (float)height; glm::mat4 projectionMatrix = glm::perspective(fovDeg, aspect, nearClip, farClip); //DrawLines( projectionMatrix ); glUseProgram( shaderProgram ); glUniformMatrix4fv( glGetUniformLocation(shaderProgram, "projectionMatrix"), 1, GL_FALSE, &projectionMatrix[0][0] ); deapth = -0.01; utility::func( height_map, [&](int i) { HeightMap& m( height_map ); if( m.square_contained[i] == Resource::Stone ) glBindTexture( GL_TEXTURE_2D, glTexture[ mountain ] ); else if( m.square_contained[i] == Resource::Wood ) glBindTexture( GL_TEXTURE_2D, glTexture[ forest ] ); else return; Rectangle r( m.PosX(i), m.PosY(i), m.square_size ); DrawRectangle( r ); } ); deapth = 0; for( int i(0); i < rectangles.size(); i++ ) { deapth = (float)i / 100; glBindTexture( GL_TEXTURE_2D, glTexture[ i ] ); for( int j(0); j < rectangles[i].size(); j++ ) { DrawRectangle( rectangles[i][j] ); deapth += 0.001f; } } // 2D glDepthMask( GL_FALSE ); glDisable( GL_DEPTH_TEST ); for( int i(0); i < hud.size(); i++ ) { glBindTexture( GL_TEXTURE_2D, glTexture[ hud[i].texture ] ); DrawRectangle( hud[i] ); } DrawText( projectionMatrix ); glDepthMask( GL_TRUE ); glEnable( GL_DEPTH_TEST ); glUseProgram(0); glfwSwapBuffers(); }
SharedPtr<Peer> Topology::getBestRoot(const Address *avoid,unsigned int avoidCount,bool strictAvoid) { const uint64_t now = RR->node->now(); Mutex::Lock _l(_lock); if (_amRoot) { /* If I am a root server, the "best" root server is the one whose address * is numerically greater than mine (with wrap at top of list). This * causes packets searching for a route to pretty much literally * circumnavigate the globe rather than bouncing between just two. */ for(unsigned long p=0;p<_rootAddresses.size();++p) { if (_rootAddresses[p] == RR->identity.address()) { for(unsigned long q=1;q<_rootAddresses.size();++q) { const SharedPtr<Peer> *const nextsn = _peers.get(_rootAddresses[(p + q) % _rootAddresses.size()]); if ((nextsn)&&((*nextsn)->hasActiveDirectPath(now))) { (*nextsn)->use(now); return *nextsn; } } break; } } } else { /* If I am not a root server, the best root server is the active one with * the lowest quality score. (lower == better) */ unsigned int bestQualityOverall = ~((unsigned int)0); unsigned int bestQualityNotAvoid = ~((unsigned int)0); const SharedPtr<Peer> *bestOverall = (const SharedPtr<Peer> *)0; const SharedPtr<Peer> *bestNotAvoid = (const SharedPtr<Peer> *)0; for(std::vector< SharedPtr<Peer> >::const_iterator r(_rootPeers.begin());r!=_rootPeers.end();++r) { bool avoiding = false; for(unsigned int i=0;i<avoidCount;++i) { if (avoid[i] == (*r)->address()) { avoiding = true; break; } } const unsigned int q = (*r)->relayQuality(now); if (q <= bestQualityOverall) { bestQualityOverall = q; bestOverall = &(*r); } if ((!avoiding)&&(q <= bestQualityNotAvoid)) { bestQualityNotAvoid = q; bestNotAvoid = &(*r); } } if (bestNotAvoid) { (*bestNotAvoid)->use(now); return *bestNotAvoid; } else if ((!strictAvoid)&&(bestOverall)) { (*bestOverall)->use(now); return *bestOverall; } } return SharedPtr<Peer>(); }
bool CPrintFolder::PrintHeaders(CDCHandle dc, UINT nPage) { try { int nBkMode = dc.SetBkMode(TRANSPARENT); COLORREF clrTextColor = dc.SetTextColor(RGB(0,0,0)); // Draw header and footer!! if (m_bShowFooter || m_bShowPageNumbers) { HFONT hOldFont = dc.SelectFont(m_font); int cy = _rectExtents.bottom - (m_nFooterHeight - m_nPadding); dc.MoveTo(_rectExtents.left + m_nPadding, cy); dc.LineTo(_rectExtents.right - m_nPadding, cy); CRect r(_rectExtents.left, cy, _rectExtents.right, _rectExtents.bottom); if (m_bShowFooter) { DWORD dwStyle = DT_NOCLIP | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOPREFIX; dwStyle |= (!m_bShowPageNumbers) ? DT_CENTER : DT_LEFT; dc.DrawText(_strFooter, -1, r, dwStyle); } if (m_bShowPageNumbers) { DWORD dwStyle = DT_NOCLIP | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOPREFIX; dwStyle |= (!m_bShowFooter) ? DT_CENTER : DT_RIGHT; CString str; str.Format(IDS_PRINT_PAGE_FMT, nPage + 1, GetPageCount()); dc.DrawText(str, -1, &r, dwStyle); } dc.SelectFont(hOldFont); } if (m_bShowHeader) { int cy = (_rectExtents.top + m_nHeaderHeight) - m_nPadding; dc.MoveTo(_rectExtents.left + m_nPadding, cy); dc.LineTo(_rectExtents.right - m_nPadding, cy); CRect r(_rectExtents.left, _rectExtents.top, _rectExtents.right, cy); HFONT hOldFont = dc.SelectFont(m_fontTitle); dc.DrawText(_strHeader, -1, &r, DT_NOCLIP | DT_VCENTER | DT_CENTER | DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOPREFIX); dc.SelectFont(hOldFont); } dc.SetBkMode(nBkMode); dc.SetTextColor(clrTextColor); } catch(_com_error &e) { IW::CMessageBoxIndirect mb; mb.ShowException(IDS_LOW_LEVEL_ERROR_FMT, e); } return true; }
virtual void run(int threads) { m_nodes[0](m_messages); active::run r(threads); }
nsresult nsWebShellWindow::Initialize(nsIXULWindow* aParent, nsIAppShell* aShell, nsIURI* aUrl, PRInt32 aInitialWidth, PRInt32 aInitialHeight, PRBool aIsHiddenWindow, nsWidgetInitData& widgetInitData) { nsresult rv; nsCOMPtr<nsIWidget> parentWidget; mIsHiddenWindow = aIsHiddenWindow; // XXX: need to get the default window size from prefs... // Doesn't come from prefs... will come from CSS/XUL/RDF nsRect r(0, 0, aInitialWidth, aInitialHeight); // Create top level window mWindow = do_CreateInstance(kWindowCID, &rv); if (NS_OK != rv) { return rv; } /* This next bit is troublesome. We carry two different versions of a pointer to our parent window. One is the parent window's widget, which is passed to our own widget. The other is a weak reference we keep here to our parent WebShellWindow. The former is useful to the widget, and we can't trust its treatment of the parent reference because they're platform- specific. The latter is useful to this class. A better implementation would be one in which the parent keeps strong references to its children and closes them before it allows itself to be closed. This would mimic the behaviour of OSes that support top-level child windows in OSes that do not. Later. */ nsCOMPtr<nsIBaseWindow> parentAsWin(do_QueryInterface(aParent)); if (parentAsWin) { parentAsWin->GetMainWidget(getter_AddRefs(parentWidget)); mParentWindow = do_GetWeakReference(aParent); } mWindow->SetClientData(this); mWindow->Create((nsIWidget *)parentWidget, // Parent nsIWidget r, // Widget dimensions nsWebShellWindow::HandleEvent, // Event handler function nsnull, // Device context aShell, // Application shell nsnull, // nsIToolkit &widgetInitData); // Widget initialization data mWindow->GetClientBounds(r); mWindow->SetBackgroundColor(NS_RGB(192,192,192)); // Create web shell mDocShell = do_CreateInstance("@mozilla.org/webshell;1"); NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE); // Make sure to set the item type on the docshell _before_ calling // Create() so it knows what type it is. nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell)); NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE); NS_ENSURE_SUCCESS(EnsureChromeTreeOwner(), NS_ERROR_FAILURE); docShellAsItem->SetTreeOwner(mChromeTreeOwner); docShellAsItem->SetItemType(nsIDocShellTreeItem::typeChrome); r.x = r.y = 0; nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(mDocShell)); NS_ENSURE_SUCCESS(docShellAsWin->InitWindow(nsnull, mWindow, r.x, r.y, r.width, r.height), NS_ERROR_FAILURE); NS_ENSURE_SUCCESS(docShellAsWin->Create(), NS_ERROR_FAILURE); // Attach a WebProgress listener.during initialization... nsCOMPtr<nsIWebProgress> webProgress(do_GetInterface(mDocShell, &rv)); if (webProgress) { webProgress->AddProgressListener(this, nsIWebProgress::NOTIFY_STATE_NETWORK); } if (nsnull != aUrl) { nsCAutoString tmpStr; rv = aUrl->GetSpec(tmpStr); if (NS_FAILED(rv)) return rv; NS_ConvertUTF8toUCS2 urlString(tmpStr); nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell)); NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE); rv = webNav->LoadURI(urlString.get(), nsIWebNavigation::LOAD_FLAGS_NONE, nsnull, nsnull, nsnull); NS_ENSURE_SUCCESS(rv, rv); } return rv; }
H_INLINE void _compactIndexToCoords( P *p, const int *ms, int n, const HC &hc, int M = 0, int m = 0 ) { I e(n), l(n), t(n), w(n), r(n), mask(n), ptrn(n); int d, i, j, b; // Get total precision and max precision // if not supplied if ( M == 0 || m == 0 ) { M = m = 0; for ( i = 0; i < n; i++ ) { if ( ms[i] > m ) m = ms[i]; M += ms[i]; } } // Initialize e.zero(); d = D0; l.zero(); for ( j = 0; j < n; j++ ) p[j].zero(); // Work from MSB to LSB for ( i = m-1; i >= 0; i-- ) { // Get the mask and ptrn extractMask<I>(ms,n,d,i,mask,b); ptrn = e; ptrn.rotr(d,n);//#D ptrn.Rotr(d+1,n); // Get the Hilbert index bits M -= b; r.zero(); // GetBits doesn't do this getBits<HC,I>(hc,b,M,r); // w = GrayCodeRankInv(r) // t = GrayCode(w) grayCodeRankInv<I>(mask,ptrn,r,n,b,t,w); // Reverse the transform // l = T^{-1}_{(e,d)}(t) l = t; transformInv<I>(e,d,n,l); // Distribute these bits // to the coordinates. setLocation<P,I>(p,n,i,l); // Update the entry point and direction. update1<I>(l,t,w,n,e,d); } return; }
void FlatAuiTabArt::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& page, const wxRect& in_rect, int close_button_state, wxRect* out_tab_rect, wxRect* out_button_rect, int* x_extent) { wxCoord normal_textx, normal_texty; wxCoord selected_textx, selected_texty; wxCoord texty; wxFont m_selected_font = m_normal_font; // if the caption is empty, measure some temporary text wxString caption = page.caption; if (caption.empty()) caption = wxT("Xj"); dc.SetFont(m_selected_font); dc.GetTextExtent(caption, &selected_textx, &selected_texty); dc.SetFont(m_normal_font); dc.GetTextExtent(caption, &normal_textx, &normal_texty); // figure out the size of the tab wxSize tab_size = GetTabSize(dc, wnd, page.caption, page.bitmap, page.active, close_button_state, x_extent); wxCoord tab_height = m_tab_ctrl_height - 3; wxCoord tab_width = tab_size.x; wxCoord tab_x = in_rect.x; wxCoord tab_y = in_rect.y + in_rect.height - tab_height; caption = page.caption; // select pen, brush and font for the tab to be drawn if (page.active) { dc.SetFont(m_selected_font); texty = selected_texty; } else { dc.SetFont(m_normal_font); texty = normal_texty; } // create points that will make the tab outline int clip_width = tab_width; if (tab_x + clip_width > in_rect.x + in_rect.width) clip_width = (in_rect.x + in_rect.width) - tab_x; /* wxPoint clip_points[6]; clip_points[0] = wxPoint(tab_x, tab_y+tab_height-3); clip_points[1] = wxPoint(tab_x, tab_y+2); clip_points[2] = wxPoint(tab_x+2, tab_y); clip_points[3] = wxPoint(tab_x+clip_width-1, tab_y); clip_points[4] = wxPoint(tab_x+clip_width+1, tab_y+2); clip_points[5] = wxPoint(tab_x+clip_width+1, tab_y+tab_height-3); // FIXME: these ports don't provide wxRegion ctor from array of points #if !defined(__WXDFB__) && !defined(__WXCOCOA__) // set the clipping region for the tab -- wxRegion clipping_region(WXSIZEOF(clip_points), clip_points); dc.SetClippingRegion(clipping_region); #endif // !wxDFB && !wxCocoa */ // since the above code above doesn't play well with WXDFB or WXCOCOA, // we'll just use a rectangle for the clipping region for now -- dc.SetClippingRegion(tab_x, tab_y, clip_width+1, tab_height-3); wxPoint border_points[4]; if (m_flags &wxAUI_NB_BOTTOM) { border_points[0] = wxPoint(tab_x, tab_y); border_points[1] = wxPoint(tab_x, tab_y+tab_height-4); border_points[2] = wxPoint(tab_x+tab_width, tab_y+tab_height-4); border_points[3] = wxPoint(tab_x+tab_width, tab_y); } else //if (m_flags & wxAUI_NB_TOP) {} { border_points[0] = wxPoint(tab_x, tab_y+tab_height); border_points[1] = wxPoint(tab_x, tab_y); border_points[2] = wxPoint(tab_x+tab_width, tab_y); border_points[3] = wxPoint(tab_x+tab_width, tab_y+tab_height); } // else if (m_flags &wxAUI_NB_LEFT) {} // else if (m_flags &wxAUI_NB_RIGHT) {} int drawn_tab_yoff = border_points[1].y; int drawn_tab_height = border_points[0].y - border_points[1].y; if (page.active) { // draw active tab // draw base background color wxRect r(tab_x, tab_y, tab_width, tab_height); dc.SetPen(wxPen(m_active_colour)); dc.SetBrush(wxBrush(m_active_colour)); dc.DrawRectangle(r.x+1, r.y+1, r.width-1, r.height-4); // this white helps fill out the gradient at the top of the tab dc.SetPen(*wxWHITE_PEN); dc.SetBrush(*wxWHITE_BRUSH); dc.DrawRectangle(r.x+2, r.y+1, r.width-3, r.height-4); // these two points help the rounded corners appear more antialiased dc.SetPen(wxPen(m_active_colour)); dc.DrawPoint(r.x+2, r.y+1); dc.DrawPoint(r.x+r.width-2, r.y+1); // set rectangle down a bit for gradient drawing //r.SetHeight(r.GetHeight()/2); r.x += 2; r.width -= 2; /*r.y += r.height; r.y -= 2;*/ r.y += 1; r.height -= 2; // draw gradient background wxColor top_color = m_active_colour; wxColor bottom_color = m_active_colour; dc.GradientFillLinear(r, bottom_color, top_color, wxSOUTH); // Adapt text color int average = (m_active_colour.Red()+m_active_colour.Green()+m_active_colour.Blue())/3; if (average < 127) dc.SetTextForeground(*wxWHITE); else dc.SetTextForeground(*wxBLACK); } else { // draw inactive tab wxRect r(tab_x, tab_y+1, tab_width, tab_height-3); // start the gradent up a bit and leave the inside border inset // by a pixel for a 3D look. Only the top half of the inactive // tab will have a slight gradient r.x += 3; r.y++; r.width -= 4; r.height /= 2; r.height--; // -- draw top gradient fill for glossy look wxColor top_color = m_base_colour; wxColor bottom_color = gdAuiStepColour(top_color, 160); dc.GradientFillLinear(r, bottom_color, top_color, wxNORTH); r.y += r.height; r.y--; // -- draw bottom fill for glossy look top_color = m_base_colour; bottom_color = m_base_colour; dc.GradientFillLinear(r, top_color, bottom_color, wxSOUTH); // Adapt text color int average = (m_base_colour.Red()+m_base_colour.Green()+m_base_colour.Blue())/3; if (average < 127) dc.SetTextForeground(*wxWHITE); else dc.SetTextForeground(*wxBLACK); } // draw tab outline dc.SetPen(m_border_pen); dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.DrawPolygon(WXSIZEOF(border_points), border_points); // there are two horizontal grey lines at the bottom of the tab control, // this gets rid of the top one of those lines in the tab control if (page.active) { if (m_flags &wxAUI_NB_BOTTOM) dc.SetPen(wxPen(wxColour(gdAuiStepColour(m_base_colour, 170)))); // else if (m_flags &wxAUI_NB_LEFT) {} // else if (m_flags &wxAUI_NB_RIGHT) {} else //for wxAUI_NB_TOP dc.SetPen(m_base_colour_pen); //GDevelop use white pen so as to conform to white background dc.SetPen(*wxWHITE_PEN); dc.DrawLine(border_points[0].x+1, border_points[0].y, border_points[5].x, border_points[5].y); } int text_offset = tab_x + 8; int close_button_width = 0; if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN) { close_button_width = m_active_close_bmp.GetWidth(); } int bitmap_offset = 0; if (page.bitmap.IsOk()) { bitmap_offset = tab_x + 8; // draw bitmap dc.DrawBitmap(page.bitmap, bitmap_offset, drawn_tab_yoff + (drawn_tab_height/2) - (page.bitmap.GetHeight()/2), true); text_offset = bitmap_offset + page.bitmap.GetWidth(); text_offset += 3; // bitmap padding } else { text_offset = tab_x + 8; } wxString draw_text = gdAuiChopText(dc, caption, tab_width - (text_offset-tab_x) - close_button_width); // draw tab text dc.DrawText(draw_text, text_offset, drawn_tab_yoff + (drawn_tab_height)/2 - (texty/2) - 1); // draw focus rectangle if (page.active && (wnd->FindFocus() == wnd)) { wxRect focusRectText(text_offset, (drawn_tab_yoff + (drawn_tab_height)/2 - (texty/2) - 1), selected_textx, selected_texty); wxRect focusRect; wxRect focusRectBitmap; if (page.bitmap.IsOk()) focusRectBitmap = wxRect(bitmap_offset, drawn_tab_yoff + (drawn_tab_height/2) - (page.bitmap.GetHeight()/2), page.bitmap.GetWidth(), page.bitmap.GetHeight()); if (page.bitmap.IsOk() && draw_text.IsEmpty()) focusRect = focusRectBitmap; else if (!page.bitmap.IsOk() && !draw_text.IsEmpty()) focusRect = focusRectText; else if (page.bitmap.IsOk() && !draw_text.IsEmpty()) focusRect = focusRectText.Union(focusRectBitmap); focusRect.Inflate(2, 2); wxRendererNative::Get().DrawFocusRect(wnd, dc, focusRect, 0); } // draw close button if necessary if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN) { wxBitmap bmp = m_disabled_close_bmp; if (close_button_state == wxAUI_BUTTON_STATE_HOVER || close_button_state == wxAUI_BUTTON_STATE_PRESSED) { bmp = m_active_close_bmp; } wxRect rect(tab_x + tab_width - close_button_width - 1, tab_y + (tab_height/2) - (bmp.GetHeight()/2), close_button_width, tab_height); IndentPressedBitmap(&rect, close_button_state); dc.DrawBitmap(bmp, rect.x, rect.y, true); *out_button_rect = rect; } *out_tab_rect = wxRect(tab_x, tab_y, tab_width, tab_height); dc.DestroyClippingRegion(); }
// Given a HOG descriptor of an object to be found, // finds the closest HOG match in the whole image void cv::base::findClosestHOG(const cv::Mat& object, const cv::Mat& image, const HOGSettings& settings, cv::Rect* rect) { // extract the gradients of object cv::Mat_<float> x_grad_obj, y_grad_obj, thetas_obj, mags_obj; computeGradients(object, &x_grad_obj, &y_grad_obj, &thetas_obj, &mags_obj); int cell_size_w = object.cols / settings.cells_per_image_w; int cell_size_h = object.rows / settings.cells_per_image_h; int block_w_in_cells = cell_size_w * settings.cells_per_block_w; int block_h_in_cells = cell_size_h * settings.cells_per_block_h; // compute the object HOG descriptor std::vector<float> descriptor_obj; computeHOGDescriptor(thetas_obj, mags_obj, cell_size_w, cell_size_h, block_w_in_cells, block_h_in_cells, settings.num_orientations, &descriptor_obj); // compute gradients for the whole image cv::Mat_<float> x_grad_im, y_grad_im, thetas_im, mags_im; computeGradients(image, &x_grad_im, &y_grad_im, &thetas_im, &mags_im); float mindist = FLT_MAX; int minx = 0, miny = 0; int minscale_w = INT_MAX; int minscale_h = INT_MAX; std::mutex mtx; #pragma omp parallel for for (int scale_y = settings.min_scale; scale_y <= settings.max_scale; scale_y += settings.cells_per_image_h) { std::vector<float> descriptor; int cell_size_h = scale_y / settings.cells_per_image_h; int block_h_in_cells = cell_size_h * settings.cells_per_block_h; for (int y = 0; y + scale_y < image.rows; y += 4) { for (int dscale_x = -2 * settings.cells_per_image_w; dscale_x <= 2 * settings.cells_per_image_w; dscale_x += settings.cells_per_image_w) { int scale_x = scale_y + dscale_x; for (int x = 0; x + scale_x < image.cols && x + scale_x >= 0; x += 4) { cv::Rect r(x, y, scale_x, scale_y); int cell_size_w = scale_x / settings.cells_per_image_w; int block_w_in_cells = cell_size_w * settings.cells_per_block_w; computeHOGDescriptor(thetas_im(r), mags_im(r), cell_size_w, cell_size_h, block_w_in_cells, block_h_in_cells, settings.num_orientations, &descriptor); float dist = getL2Distance(descriptor, descriptor_obj); mtx.lock(); if (dist < mindist) { mindist = dist; minx = x; miny = y; minscale_w = scale_x; minscale_h = scale_y; } mtx.unlock(); } } } } *rect = cv::Rect(minx, miny, minscale_w, minscale_h); }
BSONObj StartMongoProgram( const BSONObj &a ) { MongoProgramRunner r( a ); r.start(); boost::thread t( r ); return BSON( string( "" ) << int( r.pid() ) ); }
static inline Vec2 v2fnormalize(const Vec2 &p) { Vec2 r(p.x, p.y); r.normalize(); return v2f(r.x, r.y); }
void CVolumeCtrl::OnNMCustomdraw(NMHDR* pNMHDR, LRESULT* pResult) { LPNMCUSTOMDRAW pNMCD = reinterpret_cast<LPNMCUSTOMDRAW>(pNMHDR); LRESULT lr = CDRF_DODEFAULT; if (m_fSelfDrawn) switch (pNMCD->dwDrawStage) { case CDDS_PREPAINT: lr = CDRF_NOTIFYITEMDRAW; break; case CDDS_ITEMPREPAINT: if (pNMCD->dwItemSpec == TBCD_CHANNEL) { CDC dc; dc.Attach(pNMCD->hdc); CRect channelRect; GetChannelRect(channelRect); CRect thumbRect; GetThumbRect(thumbRect); CopyRect(&pNMCD->rc, CRect(channelRect.left, thumbRect.top + 2, channelRect.right - 2, thumbRect.bottom - 2)); CPen shadow(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW)); CPen light(PS_SOLID, 1, GetSysColor(COLOR_3DHILIGHT)); CPen* old = dc.SelectObject(&light); dc.MoveTo(pNMCD->rc.right, pNMCD->rc.top); dc.LineTo(pNMCD->rc.right, pNMCD->rc.bottom); dc.LineTo(pNMCD->rc.left, pNMCD->rc.bottom); dc.SelectObject(&shadow); dc.LineTo(pNMCD->rc.right, pNMCD->rc.top); dc.SelectObject(old); dc.Detach(); lr = CDRF_SKIPDEFAULT; } else if (pNMCD->dwItemSpec == TBCD_THUMB) { CDC dc; dc.Attach(pNMCD->hdc); pNMCD->rc.bottom--; CRect r(pNMCD->rc); r.DeflateRect(0, 0, 1, 0); COLORREF shadow = GetSysColor(COLOR_3DSHADOW); COLORREF light = GetSysColor(COLOR_3DHILIGHT); dc.Draw3dRect(&r, light, 0); r.DeflateRect(0, 0, 1, 1); dc.Draw3dRect(&r, light, shadow); r.DeflateRect(1, 1, 1, 1); dc.FillSolidRect(&r, GetSysColor(COLOR_BTNFACE)); dc.SetPixel(r.left + 7, r.top - 1, GetSysColor(COLOR_BTNFACE)); dc.Detach(); lr = CDRF_SKIPDEFAULT; } break; }; pNMCD->uItemState &= ~CDIS_FOCUS; *pResult = lr; }
void statusicon::newEmailNotify() { QByteArray r( "qCheckGMail" ) ; KNotification::event( "qCheckGMail-NewMail","",QPixmap(),0,0,r ) ; }
int main(){ int t,i,j,k,q,x1,y1,z1,l; t=r(t); while(t--){ n=r(n);p=r(p); char arr[ma],brr[ma]; scanf("%s%s",arr,brr); int n2=n*n; int cou[n+1][n+1][n+1]; for(i=0;i<=n;i++) for(j=0;j<=n;j++) cou[i][j][0]=cou[i][0][j]=cou[0][i][j]=0; for(i=1;i<=n;i++){ int pla[n+1][n+1]; for(j=0;j<=n;j++) pla[j][0]=pla[0][j]=0; for(j=1;j<=n;j++){ int mac=0; for(k=1;k<=n;k++){ if(arr[(i-1)*n2+(j-1)*n+(k-1)]==brr[(i-1)*n2+(j-1)*n+(k-1)]){ mac++; } pla[j][k]=pla[j-1][k]+mac; cou[i][j][k]=cou[i-1][j][k]+pla[j][k]; } } } int curmax=0; int an[41]; for(i=0;i<41;i++)an[i]=0; for(i=1;i<=n;i++){ for(j=1;j<=n;j++){ for(k=1;k<=n;k++){ for(l=1;max(max(i,j),k)+l<=n;l++){ if(l+1<curmax)continue; x1=i+l; y1=j+l; z1=k+l; int dan=cou[x1][y1][z1]-(cou[i-1][y1][z1]+cou[x1][j-1][z1]+cou[x1][y1][k-1])+(cou[i-1][j-1][z1]+cou[x1][j-1][k-1]+cou[i-1][y1][k-1])-cou[i-1][j-1][k-1]; if( (l+1)*(l+1)*(l+1)*p <= dan*100 ){ //~ cout<<dan<<" => "<<i<<"|"<<j<<"|"<<k<<" l= "<<l<<" cuboid:"<<endl; //~ for(x1=0;x1<=l;x1++){ //~ for(y1=0;y1<=l;y1++){ //~ for(z1=0;z1<=l;z1++){ //~ cout<<arr[(i+x1-1)*n2+(j+y1-1)*n+(k+z1-1)]<<"-"<<brr[(i+x1-1)*n2+(j+y1-1)*n+(k+z1-1)]<<"|"; //~ } //~ cout<<" "; //~ } //~ cout<<"\t\t"; //~ } //~ cout<<endl; //~ cout<<p <<" "<< (100*dan)/( (l+1)*(l+1)*(l+1)) <<endl; an[l+1]++; curmax=l+1; } } } } } //~ for(i=1;i<=n;i++){ //~ for(j=1;j<=n;j++){ //~ for(k=1;k<=n;k++){ //~ cout<<cou[i][j][k]<<"|"; //~ } //~ cout<<endl; //~ } //~ cout<<endl; //~ } an[1]=p==0?n2*n:cou[n][n][n]; for(i=n;i>0;i--){ if(an[i]>0){ break; } } if(i>0)printf("%d %d\n",i,an[i]); else printf("-1\n"); } return 0; }
void nsIconDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount) { NS_ABORT_IF_FALSE(!HasError(), "Shouldn't call WriteInternal after error!"); // We put this here to avoid errors about crossing initialization with case // jumps on linux. PRUint32 bytesToRead = 0; nsresult rv; // Performance isn't critical here, so our update rectangle is // always the full icon nsIntRect r(0, 0, mWidth, mHeight); // Loop until the input data is gone while (aCount > 0) { switch (mState) { case iconStateStart: // Grab the width mWidth = (PRUint8)*aBuffer; // Book Keeping aBuffer++; aCount--; mState = iconStateHaveHeight; break; case iconStateHaveHeight: // Grab the Height mHeight = (PRUint8)*aBuffer; // Post our size to the superclass PostSize(mWidth, mHeight); if (HasError()) { // Setting the size lead to an error; this can happen when for example // a multipart channel sends an image of a different size. mState = iconStateFinished; return; } // If We're doing a size decode, we're done if (IsSizeDecode()) { mState = iconStateFinished; break; } // Add the frame and signal rv = mImage->EnsureFrame(0, 0, 0, mWidth, mHeight, gfxASurface::ImageFormatARGB32, &mImageData, &mPixBytesTotal); if (NS_FAILED(rv)) { PostDecoderError(rv); return; } // Tell the superclass we're starting a frame PostFrameStart(); // Book Keeping aBuffer++; aCount--; mState = iconStateReadPixels; break; case iconStateReadPixels: // How many bytes are we reading? bytesToRead = NS_MIN(aCount, mPixBytesTotal - mPixBytesRead); // Copy the bytes memcpy(mImageData + mPixBytesRead, aBuffer, bytesToRead); // Invalidate PostInvalidation(r); // Book Keeping aBuffer += bytesToRead; aCount -= bytesToRead; mPixBytesRead += bytesToRead; // If we've got all the pixel bytes, we're finished if (mPixBytesRead == mPixBytesTotal) { PostFrameStop(); PostDecodeDone(); mState = iconStateFinished; } break; case iconStateFinished: // Consume all excess data silently aCount = 0; break; } } }
void LinkLinkComponent::render(Graphics& g) { LinkComponentStyle* style = (LinkComponentStyle*)this->style; if(!style) return; g.set_opacity(style->opacity); if(!style->glows.empty() && !style->noglows) { Vector2D a = src->center(),b = dst->center(); Vector2D normal = (b-a).normalize().normal(); Rectangle r = bezier_absolute().get_bounds(); r.augment(1000/canvas->get_zoom()); double cursize = 0; for(uint i=0; i<style->glows.size(); i++) { g.reset_clip(); Circle2D csrc(src->get_bounds().augment(cursize/canvas->get_zoom())); Circle2D cdst(dst->get_bounds().augment(cursize/canvas->get_zoom())); g.rectangle(r); g.mask_circle(csrc); g.rectangle(r); g.mask_circle(cdst); Vector2D n = normal*(cursize/canvas->get_zoom()); g.line(Line2D(src->center()-n, dst->center()-n)); g.line(Line2D(src->center()+n, dst->center()+n)); g.stroke_alpha(style->glows[i].color, (i==0? 2:1)*style->glows[i].size/canvas->get_zoom(), style->glows[i].alpha * style->opacity); cursize += (i==0? 1.5:1)*style->glows[i].size; // Blur last if(i==style->glows.size()-1 && style->bPretty) { cursize -= 0.5*style->glows[i].size; float alpha = style->glows[i].alpha/2; while(alpha > 0.01) { alpha *= 0.8; Vector2D n = normal*(cursize/canvas->get_zoom()); g.line(Line2D(src->center()-n, dst->center()-n)); g.line(Line2D(src->center()+n, dst->center()+n)); g.stroke_alpha(style->glows[i].color, 4/canvas->get_zoom(), alpha * style->opacity); cursize += 2; } } } } g.set_color(style->color); g.set_font(style->font_size, style->font, style->font_style); if(style->dashed > 0) g.dash(style->dashed); render_line(g, link->bSelected ? style->thickness_selected : style->thickness); double t1 = render_arrow(g, _scale * (link->bSelected ? style->arrow_size_selected : style->arrow_size )); Bezier b = bezier_absolute(); double t2 = -1; if(style->slashes) { if(t2==-1) t2 = b.intersect_location(src->get_bounds()); if(t2==-1) t2 = 0; g.draw_slashes(style->slashes, b.get((t1+t2)/2), b.get((t1+t2)/2 - 0.01)); } g.scale(_scale); if(!link->text.empty() || !link->text2.empty()) { if(t2==-1) t2 = b.intersect_location(src->get_bounds()); if(t2==-1) t2 = 0; Vector2D p = b.get((t1+t2)/2); if(!link->text.empty() && (style->bText || LinkComponentStyle::bText_force)) { Rectangle r(p.x, p.y+6, 0,0); r.x /= _scale; r.y /= _scale; g.text(link->text, r); } if(!link->text2.empty() && (style->bText2 || LinkComponentStyle::bText2_force)) { Rectangle r(p.x, p.y-6, 0,0); r.x /= _scale; r.y /= _scale; g.set_font(style->font_size_text2, style->font_text2, style->font_style_text2); g.text(link->text2, r); } } }
static std::string flush(std::ostringstream &s) { std::string r(s.str()); s.str(std::string()); return r; }
bool CPrintFolder::DrawImage(CDCHandle dc, CPoint point, IW::Image &image, IW::FolderItem *pItem) { HFONT hOldFont = dc.SelectFont(m_font); UINT uTextStyle = DT_NOPREFIX | DT_EDITCONTROL; if (m_bCenter) uTextStyle |= DT_CENTER; if (!m_bWrap) uTextStyle |= DT_WORD_ELLIPSIS; else uTextStyle |= DT_WORDBREAK; // Calc Text Size CSimpleArray<CString> arrayStrText; CSimpleValArray<int> arrayHeights; pItem->GetFormatText(arrayStrText, m_annotations, true); int i, nHeightText = 0; for(i = 0; i < arrayStrText.GetSize(); i++) { CRect r(point.x, point.y + _sizeSection.cy, point.x + _sizeSection.cx, point.y + _sizeSection.cy); dc.DrawText(arrayStrText[i], -1, &r, uTextStyle | DT_CALCRECT); int nLimit = _sizeThumbNail.cy / 2; if (nHeightText + r.Height() > nLimit) { arrayHeights.Add(nLimit - nHeightText); nHeightText = nLimit; break; } else { nHeightText += r.Height(); arrayHeights.Add(r.Height()); } } CSize sizeThumbNailLocal = _sizeThumbNail; sizeThumbNailLocal.cy -= nHeightText; if (!image.IsEmpty()) { IW::Page page = image.GetFirstPage(); // Best fit rotate if (m_nPrintRotateBest > 0) { bool bRotate = ((sizeThumbNailLocal.cx > sizeThumbNailLocal.cy) && (page.GetWidth() < page.GetHeight())) || ((sizeThumbNailLocal.cx < sizeThumbNailLocal.cy) && (page.GetWidth() > page.GetHeight())); if (bRotate) { IW::Image imageRotate; if (m_nPrintRotateBest == 1) { IW::Rotate270(image, imageRotate, _pStatus); } else { IW::Rotate90(image, imageRotate, _pStatus); } image = imageRotate; } } const int nSizeAverage = (page.GetWidth() + page.GetHeight()) / 2; page = image.GetFirstPage(); page.SetBackGround(m_clrBackGround); const CRect rectBounding = image.GetBoundingRect(); const int nWidthPels = dc.GetDeviceCaps(HORZRES); const int nHeightPels = dc.GetDeviceCaps(VERTRES); const long icx = rectBounding.Width(); const long icy = rectBounding.Height(); const long nDiv = 0x1000; // Scale the image long sh = MulDiv(sizeThumbNailLocal.cx, nDiv, icx); long sw = MulDiv(sizeThumbNailLocal.cy, nDiv, icy); long s = IW::Min(sh, sw); const CSize sizeImage(MulDiv(page.GetWidth(), s, nDiv), MulDiv(page.GetHeight(), s, nDiv)); const CPoint pt(point.x + ((sizeThumbNailLocal.cx - sizeImage.cx) / 2) + m_nPadding, point.y + ((sizeThumbNailLocal.cy - sizeImage.cy) / 2) + m_nPadding); const CRect rectPrint(pt, sizeImage); if ((rectPrint.Width() < page.GetWidth()) && (rectPrint.Height() < page.GetHeight())) { IW::Image imageScaled; IW::Scale(image, imageScaled, rectPrint.Size(), _pStatus); image = imageScaled; page = image.GetFirstPage(); } IW::CRender::DrawToDC(dc, page, rectPrint); } // Draw the Text! CRect rectText(point.x, point.y + _sizeSection.cy - nHeightText, point.x + _sizeSection.cx, point.y + _sizeSection.cy); for(i = 0; i < arrayHeights.GetSize(); i++) { dc.DrawText(arrayStrText[i], -1, &rectText, uTextStyle); rectText.top += arrayHeights[i]; } dc.SelectFont(hOldFont); return true; }
clsparseStatus cg(cldenseVectorPrivate *pX, const clsparseCsrMatrixPrivate* pA, const cldenseVectorPrivate *pB, PTYPE& M, clSParseSolverControl solverControl, clsparseControl control) { assert( pA->num_cols == pB->num_values ); assert( pA->num_rows == pX->num_values ); if( ( pA->num_cols != pB->num_values ) || ( pA->num_rows != pX->num_values ) ) { return clsparseInvalidSystemSize; } //opaque input parameters with clsparse::array type; clsparse::vector<T> x(control, pX->values, pX->num_values); clsparse::vector<T> b(control, pB->values, pB->num_values); cl_int status; T scalarOne = 1; T scalarZero = 0; //clsparse::vector<T> norm_b(control, 1, 0, CL_MEM_WRITE_ONLY, true); clsparse::scalar<T> norm_b(control, 0, CL_MEM_WRITE_ONLY, false); //norm of rhs of equation status = Norm1<T>(norm_b, b, control); CLSPARSE_V(status, "Norm B Failed"); //norm_b is calculated once T h_norm_b = norm_b[0]; #ifndef NDEBUG std::cout << "norm_b " << h_norm_b << std::endl; #endif if (h_norm_b == 0) //special case b is zero so solution is x = 0 { solverControl->nIters = 0; solverControl->absoluteTolerance = 0.0; solverControl->relativeTolerance = 0.0; //we can either fill the x with zeros or cpy b to x; x = b; return clsparseSuccess; } //continuing "normal" execution of cg algorithm const auto N = pA->num_cols; //helper containers, all need to be zeroed clsparse::vector<T> y(control, N, 0, CL_MEM_READ_WRITE, true); clsparse::vector<T> z(control, N, 0, CL_MEM_READ_WRITE, true); clsparse::vector<T> r(control, N, 0, CL_MEM_READ_WRITE, true); clsparse::vector<T> p(control, N, 0, CL_MEM_READ_WRITE, true); clsparse::scalar<T> one(control, 1, CL_MEM_READ_ONLY, true); clsparse::scalar<T> zero(control, 0, CL_MEM_READ_ONLY, true); // y = A*x status = csrmv<T>(one, pA, x, zero, y, control); CLSPARSE_V(status, "csrmv Failed"); //r = b - y status = r.sub(b, y, control); //status = elementwise_transform<T, EW_MINUS>(r, b, y, control); CLSPARSE_V(status, "b - y Failed"); clsparse::scalar<T> norm_r(control, 0, CL_MEM_WRITE_ONLY, false); status = Norm1<T>(norm_r, r, control); CLSPARSE_V(status, "norm r Failed"); //T residuum = 0; clsparse::scalar<T> residuum(control, 0, CL_MEM_WRITE_ONLY, false); //residuum = norm_r[0] / h_norm_b; residuum.div(norm_r, norm_b, control); solverControl->initialResidual = residuum[0]; #ifndef NDEBUG std::cout << "initial residuum = " << solverControl->initialResidual << std::endl; #endif if (solverControl->finished(solverControl->initialResidual)) { solverControl->nIters = 0; return clsparseSuccess; } //apply preconditioner z = M*r M(r, z, control); //copy inital z to p p = z; //rz = <r, z>, here actually should be conjugate(r)) but we do not support complex type. clsparse::scalar<T> rz(control, 0, CL_MEM_WRITE_ONLY, false); status = dot<T>(rz, r, z, control); CLSPARSE_V(status, "<r, z> Failed"); int iteration = 0; bool converged = false; clsparse::scalar<T> alpha (control, 0, CL_MEM_READ_WRITE, false); clsparse::scalar<T> beta (control, 0, CL_MEM_READ_WRITE, false); //yp buffer for inner product of y and p vectors; clsparse::scalar<T> yp(control, 0, CL_MEM_WRITE_ONLY, false); clsparse::scalar<T> rz_old(control, 0, CL_MEM_WRITE_ONLY, false); while(!converged) { solverControl->nIters = iteration; //y = A*p status = csrmv<T>(one, pA, p, zero, y, control); CLSPARSE_V(status, "csrmv Failed"); status = dot<T>(yp, y, p, control); CLSPARSE_V(status, "<y,p> Failed"); // alpha = <r,z> / <y,p> //alpha[0] = rz[0] / yp[0]; alpha.div(rz, yp, control); #ifndef NDEBUG std::cout << "alpha = " << alpha[0] << std::endl; #endif //x = x + alpha*p status = axpy<T>(x, alpha, p, x, control); CLSPARSE_V(status, "x = x + alpha * p Failed"); //r = r - alpha * y; status = axpy<T, EW_MINUS>(r, alpha, y, r, control); CLSPARSE_V(status, "r = r - alpha * y Failed"); //apply preconditioner z = M*r M(r, z, control); //store old value of rz //improve that by move or swap rz_old = rz; //rz = <r,z> status = dot<T>(rz, r, z, control); CLSPARSE_V(status, "<r,z> Failed"); // beta = <r^(i), r^(i)>/<r^(i-1),r^(i-1)> // i: iteration index; // beta is ratio of dot product in current iteration compared //beta[0] = rz[0] / rz_old[0]; beta.div(rz, rz_old, control); #ifndef NDEBUG std::cout << "beta = " << beta[0] << std::endl; #endif //p = z + beta*p; status = axpby<T>(p, one, z, beta, p, control ); CLSPARSE_V(status, "p = z + beta*p Failed"); //calculate norm of r status = Norm1<T>(norm_r, r, control); CLSPARSE_V(status, "norm r Failed"); //residuum = norm_r[0] / h_norm_b; status = residuum.div(norm_r, norm_b, control); CLSPARSE_V(status, "residuum"); iteration++; converged = solverControl->finished(residuum[0]); solverControl->print(); } return clsparseSuccess; }
bool TimeTextCtrl::Layout() { unsigned int i, j; int x, pos; wxMemoryDC memDC; if (mBackgroundBitmap) { delete mBackgroundBitmap; mBackgroundBitmap = NULL; } // Placeholder bitmap so the memDC has something to reference mBackgroundBitmap = new wxBitmap(1, 1); memDC.SelectObject(*mBackgroundBitmap); mDigits.Clear(); mBorderLeft = 1; mBorderTop = 1; mBorderRight = 1; mBorderBottom = 1; int fontSize = 4; wxCoord strW, strH; wxString exampleText = wxT("0"); // Keep making the font bigger until it's too big, then subtract one. memDC.SetFont(wxFont(fontSize, wxFIXED, wxNORMAL, wxNORMAL)); memDC.GetTextExtent(exampleText, &strW, &strH); while(strW <= mDigitBoxW && strH <= mDigitBoxH) { fontSize++; memDC.SetFont(wxFont(fontSize, wxFIXED, wxNORMAL, wxNORMAL)); memDC.GetTextExtent(exampleText, &strW, &strH); } fontSize--; if (mDigitFont) delete mDigitFont; mDigitFont = new wxFont(fontSize, wxFIXED, wxNORMAL, wxNORMAL); memDC.SetFont(*mDigitFont); memDC.GetTextExtent(exampleText, &strW, &strH); mDigitW = strW; mDigitH = strH; // The label font should be a little smaller fontSize--; if (mLabelFont) delete mLabelFont; mLabelFont = new wxFont(fontSize, wxFIXED, wxNORMAL, wxNORMAL); // Figure out the x-position of each field and label in the box x = mBorderLeft; pos = 0; memDC.SetFont(*mLabelFont); memDC.GetTextExtent(mPrefix, &strW, &strH); x += strW; pos += mPrefix.Length(); for(i=0; i<mFields.GetCount(); i++) { mFields[i].fieldX = x; for(j=0; j<(unsigned int)mFields[i].digits; j++) { mDigits.Add(DigitInfo(i, j, pos, wxRect(x, mBorderTop, mDigitBoxW, mDigitBoxH))); x += mDigitBoxW; pos++; } mFields[i].labelX = x; memDC.GetTextExtent(mFields[i].label, &strW, &strH); pos += mFields[i].label.Length(); x += strW; mFields[i].fieldW = x; } mWidth = x + mBorderRight; mHeight = mDigitBoxH + mBorderTop + mBorderBottom; // Draw the background bitmap - it contains black boxes where // all of the digits go and all of the other text wxBrush Brush; delete mBackgroundBitmap; // Delete placeholder mBackgroundBitmap = new wxBitmap(mWidth + mButtonWidth, mHeight); memDC.SelectObject(*mBackgroundBitmap); memDC.SetBrush(*wxLIGHT_GREY_BRUSH); memDC.SetPen(*wxTRANSPARENT_PEN); memDC.DrawRectangle(0, 0, mWidth + mButtonWidth, mHeight); int numberBottom = mBorderTop + (mDigitBoxH - mDigitH)/2 + mDigitH; memDC.GetTextExtent(wxT("0"), &strW, &strH); int labelTop = numberBottom - strH; memDC.SetTextForeground(*wxBLACK); memDC.SetTextBackground(*wxLIGHT_GREY); memDC.DrawText(mPrefix, mBorderLeft, labelTop); theTheme.SetBrushColour( Brush, clrTimeBack ); memDC.SetBrush(Brush); memDC.SetBrush(*wxLIGHT_GREY_BRUSH); for(i=0; i<mDigits.GetCount(); i++) memDC.DrawRectangle(mDigits[i].digitBox); memDC.SetBrush( wxNullBrush ); for(i=0; i<mFields.GetCount(); i++) memDC.DrawText(mFields[i].label, mFields[i].labelX, labelTop); if (mMenuEnabled) { wxRect r(mWidth, 0, mButtonWidth - 1, mHeight - 1); AColor::Bevel(memDC, true, r); memDC.SetBrush(*wxBLACK_BRUSH); memDC.SetPen(*wxBLACK_PEN); AColor::Arrow(memDC, mWidth + 1, (mHeight / 2) - 2, mButtonWidth - 2); } return true; }
// The given `check' function must be called every iteration. // It may call setPreempted() or perform other tasks. bool BaseStrategy::execute(std::function<bool()> check) { ros::Rate r(2); // Hz while (node_.ok() && check() && !isPreempted() && !finished_) { callback_queue_.callAvailable(); // TODO: check map age. // TODO: getNumPublishers here sometimes segfaults on // succeeded/preempted, for no apparent reason. if (slam_map_subscriber_.getNumPublishers() == 0) { // SLAM is not running. ROS_INFO("Waiting for SLAM to start publishing a map..."); } else if (map_ && pose_initialized_) { if (obstacle_map_publisher_.getNumSubscribers() > 0) { obstacle_map_publisher_.publish(createOccupancyGrid(*map_)); } if (!map_ready_) { const int Rfree = std::ceil(initial_free_radius_ / map_->resolution); freeRobotPose(*map_, map_->getIdxForPosition(pose_.position), Rfree); // TODO: This is too conservative. "!= -1" should be used instead, but // for now it's like this to handle the point of a map where the // only frontier is the robot position. if (map_updated_ && map_->isBoxKnown(pose_.position, safety_radius_) == 1) { map_ready_ = true; } else { ROS_INFO_COND(map_updated_, "Position is outside map. Initialization manoeuvres..."); executeInitStep(map_updated_); } } if (map_ready_) { if (map_updated_) { executeStep(); } else { executeControlStep(); } } map_updated_ = false; } else { if (map_updated_) { ROS_INFO("Received map is empty. Initialization manoeuvres..."); } executeInitStep(map_updated_); } r.sleep(); } return finished_; }
vector<pair<btVector3, btConvexHullShape*> > ofxBulletConvexDecomposer::decompose(const ofMesh &meshToDecompose, btVector3 scale ) { assert( meshToDecompose.getMode() == OF_TRIANGLES_MODE ); vector<pair<btVector3, btConvexHullShape*> > convexShapes; int tcount = meshToDecompose.getNumIndices()/3; if ( tcount == 0 ) // nothing to do return convexShapes; // adapted from bullet-2.81-rev2613/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.cpp /* unsigned int depth = 5; float cpercent = 5; float ppercent = 15; unsigned int maxv = 16; float skinWidth = 0.0; // ConvexDecomposition::WavefrontObj wo; ConvexDecomposition::DecompDesc desc; desc.mVcount = meshToDecompose.getNumVertices(); desc.mVertices = (float*)(meshToDecompose.getVerticesPointer()); desc.mTcount = meshToDecompose.getNumIndices()/3; desc.mIndices = meshToDecompose.getIndexPointer(); desc.mDepth = depth; desc.mCpercent = cpercent; desc.mPpercent = ppercent; desc.mMaxVertices = maxv; desc.mSkinWidth = skinWidth; desc.mCallback = this; */ //----------------------------------------------- // HACD //----------------------------------------------- std::vector< HACD::Vec3<HACD::Real> > points; std::vector< HACD::Vec3<long> > triangles; for(int i=0; i<meshToDecompose.getNumVertices(); i++ ) { ofVec3f meshVert = meshToDecompose.getVertex(i); HACD::Vec3<HACD::Real> vertex( meshVert.x, meshVert.y, meshVert.z ); points.push_back(vertex); } for(int i=0;i<meshToDecompose.getNumIndices(); i+=3 ) { HACD::Vec3<long> triangle(meshToDecompose.getIndex(i), meshToDecompose.getIndex(i+1), meshToDecompose.getIndex(i+2) ); triangles.push_back(triangle); } assert(triangles.size()==tcount); HACD::HACD myHACD; myHACD.SetPoints(&points[0]); myHACD.SetNPoints(points.size()); myHACD.SetTriangles(&triangles[0]); myHACD.SetNTriangles(triangles.size()); myHACD.SetCompacityWeight(0.1); myHACD.SetVolumeWeight(0.0); // HACD parameters // Recommended parameters: 2 100 0 0 0 0 size_t nClusters = 2; double concavity = 100; bool invert = false; bool addExtraDistPoints = false; bool addNeighboursDistPoints = false; bool addFacesPoints = false; myHACD.SetNClusters(nClusters); // minimum number of clusters myHACD.SetNVerticesPerCH(100); // max of 100 vertices per convex-hull myHACD.SetConcavity(concavity); // maximum concavity myHACD.SetAddExtraDistPoints(addExtraDistPoints); myHACD.SetAddNeighboursDistPoints(addNeighboursDistPoints); myHACD.SetAddFacesPoints(addFacesPoints); myHACD.SetCallBack( hacdCallback ); myHACD.Compute(); nClusters = myHACD.GetNClusters(); int totalTriangles = 0; int totalPoints = 0; for (int c=0;c<nClusters;c++) { //generate convex result size_t nPoints = myHACD.GetNPointsCH(c); size_t nTriangles = myHACD.GetNTrianglesCH(c); ofLogVerbose("ofxBulletConvexDecomposer") << "cluster " << c <<"/" << nClusters << " points " << nPoints << " triangles " << nTriangles; float* vertices = new float[nPoints*3]; unsigned int* triangles = new unsigned int[nTriangles*3]; HACD::Vec3<HACD::Real> * pointsCH = new HACD::Vec3<HACD::Real>[nPoints]; HACD::Vec3<long> * trianglesCH = new HACD::Vec3<long>[nTriangles]; myHACD.GetCH(c, pointsCH, trianglesCH); // points for(size_t v = 0; v < nPoints; v++) { vertices[3*v] = pointsCH[v].X(); vertices[3*v+1] = pointsCH[v].Y(); vertices[3*v+2] = pointsCH[v].Z(); } // triangles for(size_t f = 0; f < nTriangles; f++) { triangles[3*f] = trianglesCH[f].X(); triangles[3*f+1] = trianglesCH[f].Y(); triangles[3*f+2] = trianglesCH[f].Z(); } ConvexResult r(nPoints, vertices, nTriangles, triangles); convexShapes.push_back( createConvexHullShapeFromConvexResult(r, scale) ); delete [] pointsCH; delete [] trianglesCH; delete [] vertices; delete [] triangles; totalTriangles += nTriangles; } return convexShapes; }
void emit(setcc& i) { PhysReg r(i.d.asReg()); a->Cset(X(r), C(i.cc)); }
std::vector<XNODE_> operator()(std::vector<AST::Node> const& n) const { std::vector<XNODE_> r(n.size()); std::transform(n.begin(), n.end(), r.begin(), *this); return r; }
void AudioPortConfig::trackSelectionChanged() { routeList->clear(); newSrcList->clear(); newDstList->clear(); QListWidgetItem* titem = tracksList->currentItem(); AudioTrack* atrack = (AudioTrack*)song->findTrack(titem->text()); if(atrack) { _selected = atrack; selectedIndex = tracksList->row(titem); //TrackList* tl = song->tracks(); //for(iTrack t = tl->begin(); t != tl->end(); ++t) //{ // if((*t)->isMidiTrack()) // continue; // AudioTrack* track = (AudioTrack*) (*t); // if(track->name() == atrack->name()) // continue; //You cant connect a track to itself //int channels = track->channels(); switch (atrack->type()) { case Track::AUDIO_OUTPUT:/*{{{*/ for(iTrack t = song->tracks()->begin(); t != song->tracks()->end(); ++t) { if((*t)->isMidiTrack()) continue; AudioTrack* track = (AudioTrack*) (*t); if(track->name() == atrack->name() || track->type() == Track::AUDIO_OUTPUT) continue; //You cant connect a track to itself //for (int channel = 0; channel < track->channels(); ++channel) //{ Route r(track, -1); newSrcList->addItem(r.name()); //} } insertInputs(); //newDstList->addItem(Route(track, -1).name()); break; case Track::AUDIO_AUX: newSrcList->clear(); for(iTrack t = song->tracks()->begin(); t != song->tracks()->end(); ++t) { if((*t)->isMidiTrack()) continue; AudioTrack* track = (AudioTrack*) (*t); if(track->name() == atrack->name()) continue; //You cant connect a track to itself if(track->type() == Track::AUDIO_BUSS || track->type() == Track::AUDIO_OUTPUT) newDstList->addItem(Route(track, -1).name()); //newDstList->addItem(Route(track, -1).name()); } break; case Track::AUDIO_INPUT: for(iTrack t = song->tracks()->begin(); t != song->tracks()->end(); ++t) { if((*t)->isMidiTrack()) continue; AudioTrack* track = (AudioTrack*) (*t); if(track->name() == atrack->name()) continue; //You cant connect a track to itself switch(track->type()) { case Track::AUDIO_OUTPUT: case Track::AUDIO_BUSS: case Track::WAVE: newDstList->addItem(Route(track, -1).name()); break; default: break; } } insertOutputs(); break; case Track::WAVE: for(iTrack t = song->tracks()->begin(); t != song->tracks()->end(); ++t) { if((*t)->isMidiTrack()) continue; AudioTrack* track = (AudioTrack*) (*t); if(track->name() == atrack->name()) continue; //You cant connect a track to itself if(track->type() == Track::AUDIO_INPUT) { newSrcList->addItem(Route(track, -1).name()); } else if(track->type() == Track::AUDIO_OUTPUT || track->type() == Track::AUDIO_BUSS) { newDstList->addItem(Route(track, -1).name()); } } break; case Track::AUDIO_BUSS: for(iTrack t = song->tracks()->begin(); t != song->tracks()->end(); ++t) { if((*t)->isMidiTrack()) continue; AudioTrack* track = (AudioTrack*) (*t); if(track->name() == atrack->name()) continue; //You cant connect a track to itself if(track->type() == Track::AUDIO_INPUT || track->type() == Track::WAVE || track->type() == Track::AUDIO_SOFTSYNTH) { //for (int channel = 0; channel < track->channels(); ++channel) //{ newSrcList->addItem(Route(track, -1).name()); //} } else if(track->type() == Track::AUDIO_OUTPUT) { //for (int channel = 0; channel < track->channels(); ++channel) //{ newDstList->addItem(Route(track, -1).name()); //} } } break; case Track::AUDIO_SOFTSYNTH: newSrcList->clear(); for(iTrack t = song->tracks()->begin(); t != song->tracks()->end(); ++t) { if((*t)->isMidiTrack()) continue; AudioTrack* track = (AudioTrack*) (*t); if(track->name() == atrack->name()) continue; //You cant connect a track to itself if(track->type() == Track::AUDIO_OUTPUT || track->type() == Track::AUDIO_BUSS) { //for (int channel = 0; channel < track->channels(); ++channel) //{ newDstList->addItem(Route(track, -1).name()); //} } } break; default: break;/*}}}*/ } //} QTreeWidgetItem* widgetItem; const RouteList* rl = atrack->outRoutes(); for (ciRoute r = rl->begin(); r != rl->end(); ++r) { QString src(""); if (atrack->type() == Track::AUDIO_OUTPUT) { widgetItem = new QTreeWidgetItem(routeList, QStringList() << src << QString("") << atrack->name() << r->name() << QString::number(r->channel), Track::AUDIO_OUTPUT); } else { widgetItem = new QTreeWidgetItem(routeList, QStringList() << src << QString("") << atrack->name() << r->name() << QString::number(0), Track::AUDIO_OUTPUT); } widgetItem->setTextAlignment(1, Qt::AlignHCenter); widgetItem->setTextAlignment(4, Qt::AlignHCenter); } const RouteList* rli = atrack->inRoutes(); for (ciRoute ri = rli->begin(); ri != rli->end(); ++ri) { QString src(""); if (atrack->type() == Track::AUDIO_INPUT) { widgetItem = new QTreeWidgetItem(routeList, QStringList() << ri->name() << QString::number(ri->channel) << atrack->name() << src << QString(""), Track::AUDIO_INPUT); } else { widgetItem = new QTreeWidgetItem(routeList, QStringList() << ri->name() << QString::number(0) << atrack->name() << src << QString(""), Track::AUDIO_INPUT); } widgetItem->setTextAlignment(1, Qt::AlignHCenter); widgetItem->setTextAlignment(4, Qt::AlignHCenter); } routeSelectionChanged(); // init remove button srcSelectionChanged(); // init select button } }
Matrix Matrix::Ident(size_t n){ Matrix r(n, n, 0.0); for(size_t i=0; i<n; i++) r.set(i, i, 1.0); return r; }
ring_iterator operator -- (int) { ring_iterator r(*this); --(*this); return r; }