当前位置: 首页>>代码示例>>C++>>正文


C++ r函数代码示例

本文整理汇总了C++中r函数的典型用法代码示例。如果您正苦于以下问题:C++ r函数的具体用法?C++ r怎么用?C++ r使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了r函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的r函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。