本文整理汇总了C++中r函数的典型用法代码示例。如果您正苦于以下问题:C++ r函数的具体用法?C++ r怎么用?C++ r使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了r函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: runQVfb
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();
}
开发者ID:wpbest,项目名称:copperspice,代码行数:89,代码来源:main.cpp
示例2: pack_rectangle
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;
}
开发者ID:codeoneclick,项目名称:iGaia-Tanks,代码行数:61,代码来源:gameswf_fontlib.cpp
示例3: r
Matrix Matrix::frobeniusNormalized() const{
Matrix r(*this);
double m = 1.0 / frobeniusNorm();
r.map([=](double v){return v*m;});
return r;
}
开发者ID:BrettAM,项目名称:Cs404DataMining,代码行数:6,代码来源:matrix.cpp
示例4: bvSolver
// 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;
//.........这里部分代码省略.........
开发者ID:jamesbornholt,项目名称:stp,代码行数:101,代码来源:STP.cpp
示例5: glClear
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();
}
开发者ID:Alyanorno,项目名称:Awesome-game,代码行数:61,代码来源:graphic.cpp
示例6: _l
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>();
}
开发者ID:ICTSTUDIO,项目名称:ZeroTierOne,代码行数:64,代码来源:Topology.cpp
示例7: r
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;
}
开发者ID:ZacWalk,项目名称:ImageWalker,代码行数:67,代码来源:PrintFolder.cpp
示例8: run
virtual void run(int threads)
{
m_nodes[0](m_messages);
active::run r(threads);
}
开发者ID:alarouche,项目名称:cppao,代码行数:5,代码来源:bench2.cpp
示例9: r
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;
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:94,代码来源:nsWebShellWindow.cpp
示例10: _compactIndexToCoords
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;
}
开发者ID:ArtisticCoding,项目名称:libmesh,代码行数:65,代码来源:Algorithm.hpp
示例11: wxT
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) {}
//.........这里部分代码省略.........
开发者ID:heyuqi,项目名称:GD,代码行数:101,代码来源:FlatAuiTabArt.cpp
示例12: computeGradients
// 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);
}
开发者ID:flynnhe,项目名称:cvlib,代码行数:67,代码来源:utils.cpp
示例13: StartMongoProgram
BSONObj StartMongoProgram( const BSONObj &a ) {
MongoProgramRunner r( a );
r.start();
boost::thread t( r );
return BSON( string( "" ) << int( r.pid() ) );
}
开发者ID:alanw,项目名称:mongo,代码行数:6,代码来源:utils.cpp
示例14: v2fnormalize
static inline Vec2 v2fnormalize(const Vec2 &p)
{
Vec2 r(p.x, p.y);
r.normalize();
return v2f(r.x, r.y);
}
开发者ID:RyunosukeOno,项目名称:rayjack,代码行数:6,代码来源:CCDrawNode.cpp
示例15: switch
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;
}
开发者ID:Armada651,项目名称:mpc-hc,代码行数:62,代码来源:VolumeCtrl.cpp
示例16: r
void statusicon::newEmailNotify()
{
QByteArray r( "qCheckGMail" ) ;
KNotification::event( "qCheckGMail-NewMail","",QPixmap(),0,0,r ) ;
}
开发者ID:mhogomchungu,项目名称:qt-update-notifier,代码行数:5,代码来源:statusicon.cpp
示例17: main
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;
}
开发者ID:devanshdalal,项目名称:CompetitiveProgrammingAlgos,代码行数:76,代码来源:CUBE-3072448.c
示例18: bezier_absolute
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);
}
}
}
开发者ID:jfellus,项目名称:libboiboites,代码行数:76,代码来源:LinkLinkComponent.cpp
示例19: flush
static std::string flush(std::ostringstream &s)
{
std::string r(s.str());
s.str(std::string());
return r;
}
开发者ID:oys0317,项目名称:opensanguo,代码行数:6,代码来源:generate_report.cpp
示例20: cg
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);
|
请发表评论