• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ p函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了p函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: p

Prop *Prop::AllocTextAlign(AlignAttr align)
{
    Prop p(PropTextAlign);
    p.textAlign = align;
    return UniqifyProp(p);
}
开发者ID:Erls-Corporation,项目名称:SumatraPDF-2.2.1,代码行数:6,代码来源:MuiCss.cpp


示例2: p1

double MxSegment<DIM>::volumeFraction(const MxShape<DIM> & aShape, const MxDimVector<double, DIM> & midPt) const {

  MxDimVector<double, DIM> p1(midPt + 0.5 * len * dir);
  MxDimVector<double, DIM> p2(midPt - 0.5 * len * dir);
  double f1 = aShape.func(p1);
  double f2 = aShape.func(p2);
  int f1s = MxUtil::sign(f1);
  int f2s = MxUtil::sign(f2);

  if ((f1s == 1 and f2s != -1) or (f2s == 1 and f1s != -1)) {
    return 1;
  } else if ((f1s == -1 and f2s != 1) or (f2s == -1 and f1s != 1)) {
    return 0;
  } else if (f1s == 0 and f2s == 0) {
    return MxUtil::sign(aShape.func(midPt)) == 1 ? 1 : 0;
  } else {                                                                         // bracketing
    MxDimVector<double, DIM> p(MxUtil::rootFind<MxShape<DIM>, DIM>(aShape, p1, p2, 1.e-12, 20));
    if (f1s == 1)
      return (p - p1).norm() / len;
    else
      return (p - p2).norm() / len;
  }

#if 0
  if      ((f1 > MxUtil::dEps and f2 > -MxUtil::dEps) or 
           (f2 > MxUtil::dEps and f1 > -MxUtil::dEps)) return 1.0;     // one in, other in or on
  else if ((f1 < -MxUtil::dEps and f2 < MxUtil::dEps) or
           (f2 < -MxUtil::dEps and f1 < MxUtil::dEps)) return 0.0;     // one out, other out or on
  else if (fabs(f1) < MxUtil::dEps and fabs(f2) < MxUtil::dEps) {      // both on
    if (aShape.func(midPt) > MxUtil::dEps) return 1.0;
    else return 0.0;
  }
  else {                                                                         // bracketing
    MxDimVector<double, DIM> p(MxUtil::rootFind<MxShape<DIM>, DIM>(aShape, p1, p2, 1.e-12, 20));
    if (f1 > MxUtil::dEps)
      return (p - p1).norm() / len;
    else
      return (p - p2).norm() / len;
  }
#endif

#if 0
  if (f1 * f2 > 0.0) {
    if (f1 > 0.0)
      return 1.0;
    else
      return 0.0;
  }
  else if (f1 == 0.0 and f2 == 0.0) {
    if (aShape.func(midPt) > 0.0) return 1.0;
    else return 0.0;
  }
  else if (f1 * f2 == 0.0) {
    if (f1 > 0.0 or f2 > 0.0) return 1.0;
    else return 0.0;
  }
  else {
    MxDimVector<double, DIM> p(MxUtil::rootFind<MxShape<DIM>, DIM>(aShape, p1, p2, 1.e-12, 20));
    if (f1 > 0.0)
      return (p - p1).norm() / len;
    else
      return (p - p2).norm() / len;
  }
#endif

}
开发者ID:achellies,项目名称:maxwell,代码行数:66,代码来源:MxSegment.cpp


示例3: p

unsigned int IOFactory::findPlugins( const std::string &path )
{
	boost::filesystem::path p( path );

	if ( !exists( p ) ) {
		LOG( Runtime, warning ) << util::MSubject( p ) << " not found";
		return 0;
	}

	if ( !boost::filesystem::is_directory( p ) ) {
		LOG( Runtime, warning ) << util::MSubject( p ) << " is no directory";
		return 0;
	}

	LOG( Runtime, info )   << "Scanning " << util::MSubject( p ) << " for plugins";
	boost::regex pluginFilter( std::string( "^" ) + DL_PREFIX + "isisImageFormat_" + "[[:word:]]+" + DL_SUFFIX + "$", boost::regex::perl | boost::regex::icase );
	unsigned int ret = 0;

	for ( boost::filesystem::directory_iterator itr( p ); itr != boost::filesystem::directory_iterator(); ++itr ) {
		if ( boost::filesystem::is_directory( *itr ) )continue;

		if ( boost::regex_match( itr->path().filename().string(), pluginFilter ) ) {
			const std::string pluginName = itr->path().native();
#ifdef WIN32
			HINSTANCE handle = LoadLibrary( pluginName.c_str() );
#else
			void *handle = dlopen( pluginName.c_str(), RTLD_NOW );
#endif

			if ( handle ) {
#ifdef WIN32
				image_io::FileFormat* ( *factory_func )() = ( image_io::FileFormat * ( * )() )GetProcAddress( handle, "factory" );
#else
				image_io::FileFormat* ( *factory_func )() = ( image_io::FileFormat * ( * )() )dlsym( handle, "factory" );
#endif

				if ( factory_func ) {
					FileFormatPtr io_class( factory_func(), _internal::pluginDeleter( handle, pluginName ) );

					if ( registerFileFormat( io_class ) ) {
						io_class->plugin_file = pluginName;
						ret++;
					} else {
						LOG( Runtime, warning ) << "failed to register plugin " << util::MSubject( pluginName );
					}
				} else {
#ifdef WIN32
					LOG( Runtime, warning )
							<< "could not get format factory function from " << util::MSubject( pluginName );
					FreeLibrary( handle );
#else
					LOG( Runtime, warning )
							<< "could not get format factory function from " << util::MSubject( pluginName ) << ":" << util::MSubject( dlerror() );
					dlclose( handle );
#endif
				}
			} else
#ifdef WIN32
				LOG( Runtime, warning ) << "Could not load library " << util::MSubject( pluginName );

#else
				LOG( Runtime, warning ) << "Could not load library " << util::MSubject( pluginName ) << ":" <<  util::MSubject( dlerror() );
#endif
		} else {
			LOG( Runtime, verbose_info ) << "Ignoring " << *itr << " because it doesn't match " << pluginFilter.str();
		}
	}

	return ret;
}
开发者ID:karda,项目名称:isis,代码行数:70,代码来源:io_factory.cpp


示例4: p

void
StatsGauge::paintEvent( QPaintEvent* event )
{
    QPainter p( this );
    p.setRenderHint( QPainter::Antialiasing );
    p.setClipRect( event->rect() );

    QSize gaugeSize = m_sizeHint - QSize( 0, 40 );

    QPen pen( TomahawkStyle::NOW_PLAYING_ITEM.lighter() );
    pen.setWidth( 16 );
    p.setPen( pen );

    int fullCircle = 16 * 360;
    p.drawArc( QRect( 12, 12, gaugeSize.width() - 24, gaugeSize.height() - 24 ),
               4*360, (int)( -1.0 * (float)fullCircle * ( invertedAppearance() ? ( 1.0 - m_percentage ) : m_percentage ) ) );

    pen = QPen( TomahawkStyle::NOW_PLAYING_ITEM.darker() );
    pen.setWidth( 6 );
    p.setPen( pen );

    QBrush brush( QColor( "#252020" ) );
    p.setBrush( brush );
    p.drawEllipse( QRect( 28, 28, gaugeSize.width() - 56, gaugeSize.height() - 56 ) );

    pen = QPen( Qt::white );
    p.setPen( pen );
    QFont font = p.font();
    font.setWeight( QFont::Black );

    if ( value() <= 999 )
        font.setPixelSize( 60 );
    else
        font.setPixelSize( 44 );

    p.setFont( font );
    QRect textRect( 0, gaugeSize.height() / 2 - 14, gaugeSize.width(), 62 );
    p.drawText( textRect, Qt::AlignCenter, value() > 0 ? QString::number( value() ) : "-" );

    pen = QPen( QColor( "#8b8b8b" ) );
    p.setPen( pen );
    font = p.font();
    font.setWeight( QFont::Black );
    font.setPixelSize( 16 );
    p.setFont( font );

    textRect = QRect( 0, gaugeSize.height() / 2 - 32, gaugeSize.width(), 20 );
    p.drawText( textRect, Qt::AlignCenter, maximum() > 0 ? tr( "out of %1" ).arg( maximum() ) : "-" );

    if ( !m_text.isEmpty() )
    {
        pen = QPen( Qt::white );
        p.setPen( pen );
        font = p.font();
        font.setWeight( QFont::DemiBold );
        font.setPixelSize( 16 );
        p.setFont( font );

        QColor figColor( "#3e3e3e" );
        p.setBrush( figColor );

        QFontMetrics fm( font );
        int textWidth = fm.width( m_text );
        textRect = QRect( m_sizeHint.width() / 2 - ( textWidth / 2 + 12 ), m_sizeHint.height() - 32, textWidth + 24, 28 );

        TomahawkUtils::drawBackgroundAndNumbers( &p, m_text, textRect );
    }
}
开发者ID:ehaas,项目名称:tomahawk,代码行数:68,代码来源:StatsGauge.cpp


示例5: p

void ContextTile::paintEvent(QPaintEvent *) {
	QStyleOption o;
	o.initFrom(this);
	QPainter p(this);
	style()->drawPrimitive(QStyle::PE_Widget, &o, &p, this);
}
开发者ID:jG0D,项目名称:groundstation,代码行数:6,代码来源:settingstabothercontexttiles.cpp


示例6: p

void DiagramCanvas::paint_all( QRect& r )
{
    int i;
    QPainter p( &buffer );
    QPen pen;
    QBrush brush;
    QPointArray a;
    QColor color;
    QRegion mask, crossing_disk;
    set<double>::iterator dbl_it;

    for ( i=0; i<crossingList.size(); ++i )
    {
        Crossing *c = crossingList[i];

        c->under->underpasses.insert( c->under->underpasses.end(), c->position_on_understrand );
    }

    for ( i=0; i<edgeList.size(); ++i )
    {
        Edge *e = edgeList[i];

        pen.setWidth( e->thickness );
        pen.setColor( CANVAS );
        p.setPen( pen );

        QPoint v, v1, v2, p1, p2 ;

        p1 = e->vertex[begin]->position;
        p2 = e->vertex[end]->position;
        p.drawLine( p1, p2 );
/*
      if (e->edge_type==singular)
        {

                v = p1 - p2;
                v1.setX( v.x() - v.y() );
                v1.setY( v.x() + v.y() );
                v2.setX( v.x() + v.y() );
                v2.setY( -v.x() + v.y() );

                v1 = 5 * v1 / sqrt( double (v1.x() * v1.x() + v1.y() * v1.y()) );
                v2 = 5 * v2 / sqrt( double (v2.x() * v2.x() + v2.y() * v2.y()) );
                v  = v / 2;
                pen.setWidth( ARROW );
                p.setPen( pen );
                p.drawLine( p2+v, p2+v1+v );
                p.drawLine( p2+v, p2+v2+v );
        }
*/
    }

    for ( i=0; i<edgeList.size(); ++i )
    {
        Edge *e = edgeList[i];

        color = (e->edge_type == drilled) ? DRILLED : colorList[e->arc_id % 18 ];

        pen.setWidth( e->thickness );
        pen.setColor( color );
        p.setPen( pen );

        brush.setColor( color );
        brush.setStyle( SolidPattern );
        p.setBrush( brush );

        if ( e->underpasses.size() > 0 )
        {
            p.setClipping( TRUE );
            mask = QRegion( 0, 0, width(), height(), QRegion::Rectangle );

            for ( dbl_it=e->underpasses.begin(); dbl_it!=e->underpasses.end(); ++dbl_it )
            {
                QPoint center = time_to_point( e, *dbl_it );
                crossing_disk = QRegion( center.x()-7, center.y()-7, 14, 14 , QRegion::Ellipse );
                mask -= crossing_disk;
            }

            p.setClipRegion( mask );
            QPoint v, v1, v2, p1, p2 ;

            p1 = e->vertex[begin]->position;
            p2 = e->vertex[end]->position;
            p.drawLine( p1, p2 );
/*
            if (e->edge_type==singular)
            {
                v = p1 - p2;
                v1.setX( v.x() - v.y() );
                v1.setY( v.x() + v.y() );
                v2.setX( v.x() + v.y() );
                v2.setY( -v.x() + v.y() );

                v1 = 5 * v1 / sqrt( double (v1.x() * v1.x() + v1.y() * v1.y()) );
                v2 = 5 * v2 / sqrt( double (v2.x() * v2.x() + v2.y() * v2.y()) );
                v  = v / 2;
                pen.setWidth( ARROW );
                p.setPen( pen );
                p.drawLine( p2+v, p2+v1+v );
                p.drawLine( p2+v, p2+v2+v );
//.........这里部分代码省略.........
开发者ID:DamianHeard,项目名称:orb,代码行数:101,代码来源:diagram_canvas.cpp


示例7: WndProc

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    static int  cxChar, cxCaps, cyChar, cyClient, iVscrollPos ;
    HDC         hdc ;    
    int         i, y ;    
    PAINTSTRUCT ps ;
//    TCHAR       szBuffer[10] ;    
    TEXTMETRIC  tm ;    
	static int LoadDLLTag=0;
	static int poehackTag=0;
	static BOOL	show_flag=TRUE;

	switch (message)    
    {
	case WM_LBUTTONDOWN:
		if(LoadDLLTag==1)
		{
			show_flag=!show_flag;
	        InvalidateRect (hwnd, NULL, TRUE) ;
			return 0;
		}
		LoadDLLTag=1;
		PoeIntercept(hwnd);
		/*
		typedef void(*pExecute)(DWORD);
		pExecute p;
		p=(pExecute)GetProcAddress(poehackModule,"Execute");
		if(p)
			p((DWORD)hwnd);
		*/
		return 0;
	case WM_RBUTTONDOWN: 
		if(poehackTag==1){
			return 0;
		}
		char dllFullName[10240];
		GetCurrentDirectory(255, dllFullName);
		strcpy(dllFullName, "c:\\bot\\d3\\poehack.dll");
		
		poehackModule = LoadLibrary(dllFullName);
		if(!poehackModule) _showinfo("poehack load failed: %s",dllFullName);
		else
		{
			_showinfo("poehack loaded");
			poehackTag=1;
		}
		if(!_PassValueAddr)
			_PassValueAddr=(pPassValue)GetProcAddress(poehackModule,"PassValue");
		_showinfo("_PassValueAddr %x",_PassValueAddr);		
		return 0;
	case WM_MBUTTONDOWN:		
		if(poehackTag==0) return 0;

		_value.id = DO_UNLOAD;
		if(_PassValueAddr) _PassValueAddr(&_value);

		/*
		typedef void(*pUnload)();
		pUnload p;
		p=(pUnload)GetProcAddress(poehackModule,"Unload");
		if(p) p();
		*/
		FreeLibrary(poehackModule);
		poehackModule=NULL;
		_PassValueAddr=NULL;
		_showinfo("poehack unloaded");
		poehackTag=0;
		return 0;
	case WM_CREATE:
		hdc = GetDC (hwnd) ;
	    GetTextMetrics (hdc, &tm) ;
		cxChar = tm.tmAveCharWidth ;
	    cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2) * cxChar / 2 ;
		cyChar = tm.tmHeight + tm.tmExternalLeading ;

	    ReleaseDC (hwnd, hdc) ;
		SetScrollRange (hwnd, SB_VERT, 0, NUMLINES - 1, FALSE) ;
	    SetScrollPos   (hwnd, SB_VERT, iVscrollPos, TRUE) ;
		_window_up=TRUE;
        return 0 ;

    case WM_SIZE:
        cyClient = HIWORD (lParam) ;
        return 0 ;

    case WM_VSCROLL:
        switch (LOWORD (wParam))
          {
			case SB_LINEUP:
          iVscrollPos -= 1 ;
        break ;
     
    case SB_LINEDOWN:
        iVscrollPos += 1 ;
        break ;

    case SB_PAGEUP:
        iVscrollPos -= cyClient / cyChar ;
        break ;
     
//.........这里部分代码省略.........
开发者ID:roybai,项目名称:poe,代码行数:101,代码来源:win.cpp


示例8: evaluateDefines

bool Bass::executeInstruction(Instruction& i) {
  activeInstruction = &i;
  string s = i.statement;
  evaluateDefines(s);

  if(s.match("macro ?*(*) {") || s.match("global macro ?*(*) {")) {
    bool local = s.beginsWith("global ") == false;
    s.ltrim<1>("global ");
    s.trim<1>("macro ", ") {");
    lstring p = s.split<1>("(");
    bool scoped = p(0).beginsWith("scope ");
    p(0).ltrim<1>("scope ");
    lstring a = p(1).empty() ? lstring{} : p(1).qsplit(",").strip();
    setMacro(p(0), a, ip, scoped, local);
    ip = i.ip;
    return true;
  }

  if(s.match("define ?*(*)") || s.match("global define ?*(*)")) {
    bool local = s.beginsWith("global ") == false;
    s.ltrim<1>("global ");
    lstring p = s.trim<1>("define ", ")").split<1>("(");
    setDefine(p(0), p(1), local);
    return true;
  }

  if(s.match("evaluate ?*(*)") || s.match("global evaluate ?*(*)")) {
    bool local = s.beginsWith("global ") == false;
    s.ltrim<1>("global ");
    lstring p = s.trim<1>("evaluate ", ")").split<1>("(");
    setDefine(p(0), evaluate(p(1)), local);
    return true;
  }

  if(s.match("variable ?*(*)") || s.match("global variable ?*(*)")) {
    bool local = s.beginsWith("global ") == false;
    s.ltrim<1>("global ");
    lstring p = s.trim<1>("variable ", ")").split<1>("(");
    setVariable(p(0), evaluate(p(1)), local);
    return true;
  }

  if(s.match("if ?* {")) {
    s.trim<1>("if ", " {").strip();
    bool match = evaluate(s, Evaluation::Strict);
    ifStack.append(match);
    if(match == false) {
      ip = i.ip;
    }
    return true;
  }

  if(s.match("} else if ?* {")) {
    if(ifStack.last()) {
      ip = i.ip;
    } else {
      s.trim<1>("} else if ", " {").strip();
      bool match = evaluate(s, Evaluation::Strict);
      ifStack.last() = match;
      if(match == false) {
        ip = i.ip;
      }
    }
    return true;
  }

  if(s.match("} else {")) {
    if(ifStack.last()) {
      ip = i.ip;
    } else {
      ifStack.last() = true;
    }
    return true;
  }

  if(s.match("} endif")) {
    ifStack.removeLast();
    return true;
  }

  if(s.match("while ?* {")) {
    s.trim<1>("while ", " {").strip();
    bool match = evaluate(s, Evaluation::Strict);
    if(match == false) ip = i.ip;
    return true;
  }

  if(s.match("} endwhile")) {
    ip = i.ip;
    return true;
  }

  if(s.match("?*(*)")) {
    lstring p = string{s}.rtrim<1>(")").split<1>("(");
    lstring a = p(1).empty() ? lstring{} : p(1).qsplit(",").strip();
    string name = {p(0), ":", a.size()};  //arity overloading
    if(auto macro = findMacro({name})) {
      struct Parameter {
        enum class Type : unsigned { Define, Variable } type;
        string name;
//.........这里部分代码省略.........
开发者ID:gnaghi,项目名称:bass,代码行数:101,代码来源:execute.cpp


示例9: aw

void AGXContinuousTrack::createTrackConstraint()
{
    AGXLinkPtr agxFootLinkStart = _feet[0];
    AGXLinkPtr agxFootLinkEnd = _feet[_feet.size() - 1];

    // Connect footLinkStart and footLinkEnd with Hinge
    // Create Hinge with world coordination
    LinkPtr link = agxFootLinkStart->getOrgLink();
    const Vector3& a = link->a();                       // local
    const Vector3 aw = link->attitude() * a;            // world
    const Vector3& p = link->p();                       // world
    AGXHingeDesc hd;
    hd.frameAxis = agx::Vec3(aw(0), aw(1), aw(2));
    hd.frameCenter = agx::Vec3(p(0), p(1), p(2));
    hd.rigidBodyA = agxFootLinkStart->getAGXRigidBody();
    hd.rigidBodyB = agxFootLinkEnd->getAGXRigidBody();
    hd.motor.enable = false;
    hd.lock.enable = false;
    hd.range.enable = false;
    agx::ConstraintRef constraint = AGXObjectFactory::createConstraint(hd);
    link->setJointType(Link::ROTATIONAL_JOINT);
    agxFootLinkStart->setAGXConstraint(constraint);
    getAGXBody()->getAGXScene()->getSimulation()->add(constraint);

    // Create PlaneJoint to prvent the track falling off
    // Create joint with parent(example:chasis) coordination 
    const Vector3& b = link->b();
    const agx::Vec3 a0 = agx::Vec3(a(0), a(1), a(2));   // Rotate axis of track. local
    const agx::Vec3& b0 = agx::Vec3(b(0), b(1), b(2));  // Vector from parent to footLinkStart
    const agx::Vec3& p0 = (a0 * b0) * a0;             // Middle position of track(projection vector of b0 to a0). local
    agx::Vec3 nx = agx::Vec3::Z_AXIS().cross(a0);       // Check a0 is parallel to Z. X-Y consists plane joint.
    agx::OrthoMatrix3x3 rotation;
    if (nx.normalize() > 1.0e-6) {
        nx.normal();
        rotation.setColumn(0, nx);
        agx::Vec3 ny = a0.cross(nx);
        ny.normal();
        rotation.setColumn(1, ny);
        rotation.setColumn(2, a0);
    }
    agx::AffineMatrix4x4 af(rotation, p0);
    AGXPlaneJointDesc pd;
    pd.frameB = AGXObjectFactory::createFrame();
    pd.frameB->setMatrix(af);
    pd.rigidBodyB = agxFootLinkStart->getAGXParentLink()->getAGXRigidBody();

    // Generate collision group name to disable collision between tracks
    std::stringstream trackCollsionGroupName;
    trackCollsionGroupName.str("");
    trackCollsionGroupName << "SelfCollisionContinuousTrack" << agx::UuidGenerator().generate().str() << std::flush;
    getAGXBody()->addCollisionGroupNameToDisableCollision(trackCollsionGroupName.str());

    for (int i = 0; i < (int)_feet.size(); ++i) {
        AGXLinkPtr agxLink = _feet[i];
        // Add plane joint
        pd.frameA = AGXObjectFactory::createFrame();
        pd.rigidBodyA = agxLink->getAGXRigidBody();
        agx::PlaneJointRef pj = AGXObjectFactory::createConstraintPlaneJoint(pd);
        getAGXBody()->getAGXScene()->getSimulation()->add((agx::ConstraintRef)pj);

        // Force enable collision between other links
        agxLink->getAGXGeometry()->removeGroup(getAGXBody()->getCollisionGroupName());
        // Disable collision between tracks
        agxLink->getAGXGeometry()->addGroup(trackCollsionGroupName.str());
    }
}
开发者ID:kindsenior,项目名称:choreonoid,代码行数:66,代码来源:AGXBodyExtension.cpp


示例10: main

int main(int argc, char *argv[]) {
	bool error = false;
	uint8_t buffer[256];
	uint16_t bufferSize = 256;
	StreamParser p(streamReader, buffer, bufferSize, handlers, 1, NULL);
	
	while(p.parse() >= 0);
	
	int16_t theInt = 400;
	float theFloat = 213423.23466432;
	uint16_t functionID = 1;
	
	char *stri = (char *)"hello world";
	
	uint8_t indexTable[] = { Object::T_UINT16, Object::T_INT16, Object::T_STRING, Object::T_FLOAT, Object::T_INT32, Object::T_INT64, (uint8_t)(strlen(stri) + 1) };
	Object o(indexTable, 6);
	
	uint8_t dataBuffer[o.getDataSize()];
	o.setDataBuffer(dataBuffer);
	
	o.uint16At(0, functionID); //function id
	o.int16At(1, theInt); //payload argument
	o.strAt(2, stri, strlen(stri) + 1);
	if(!o.floatAt(3, theFloat)) {
		printf("Failed to set float value\n");
	}
	o.int32At(4, 345589619);
	o.int64At(5, 9384760934765065ll);
	
	if(o.int64At(5) != 9384760934765065ll) {
		printf("Retrieved int64 does not equal actual A:%lld, R:%lld\n", (long long int)9384760934765065ll, (long long int)o.int64At(5));
	}
	
	if(o.int32At(4) != 345589619) {
		printf("Retrieved int32 does not equal actual\n");
	}
	
	if(o.floatAt(3) != theFloat) {
		printf("Retrieved float does not equal actual A:%f, R:%f\n", theFloat, o.floatAt(3));
	}
	
	if(o.int16At(1) != theInt) {
		printf("Retrieved int does not equal actual A:%d R:%d\n", theInt, o.int16At(1));
	}
	
	StreamParser::PacketHeader ph = StreamParser::makePacket(16, o.getSize());
	
	printf("generated packet: ");
	printHex(&ph, sizeof(ph));
	o.writeTo(writer, NULL);
	printf("\n");
	
	
	testBuffer = ((uint8_t *)(&ph));
	testBufferSize = sizeof(StreamParser::PacketHeader);
	testBufferIndex = 0;
	
	printf("rpc call: ");
	if(rpc.call(10, "cCds", -10, 10, 320, "hello world") <= 0) {
		printf("error doing rpc call");
	}
	printf("\n");
	
	if(error) {
		printf("FAIELD: Object & RPC buffer tests\n");
	} else {
		printf("PASSED: Object & RPC buffer tests\n");
	}

	printf("Calling socket tests\n");
	socketTest();
	printf("PASSED: Socket Tests\n");

}
开发者ID:timstableford,项目名称:LightweightRPC,代码行数:74,代码来源:StreamParserTest.cpp


示例11: switch

//! called if an event happened.
bool MainMenu::onEvent(const NEvent& event)
{
	if (isEnabled())
	{
		switch(event.EventType)
		{
		case sEventGui:
			switch(event.GuiEvent.EventType)
			{
			case guiElementFocusLost:
				if (event.GuiEvent.Caller == this && !isMyChild(event.GuiEvent.Element))
				{
					closeAllSubMenus_();
					setHoverIndex_( -1 );
				}
				break;
			case guiElementFocused:
				if (event.GuiEvent.Caller == this )
				{
					bringToFront();
				}
				break;
			default:
				break;
			}
			break;
		case sEventMouse:
			switch(event.MouseEvent.Event)
			{
			case mouseLbtnPressed:
			{
				if (!getEnvironment()->hasFocus(this))
				{
					getEnvironment()->setFocus(this);
				}

    	  bringToFront();

				Point p(event.MouseEvent.getPosition() );
				bool shouldCloseSubMenu = hasOpenSubMenu_();
				if (!getAbsoluteClippingRect().isPointInside(p))
				{
					shouldCloseSubMenu = false;
				}
				isHighlighted_( event.MouseEvent.getPosition(), true);
				if ( shouldCloseSubMenu )
				{
          getEnvironment()->removeFocus(this);
				}

				return true;
			}

			case mouseLbtnRelease:
			{
        Point p(event.MouseEvent.getPosition() );
				if (!getAbsoluteClippingRect().isPointInside(p))
				{
					int t = sendClick_(p);
					if ((t==0 || t==1) && isFocused())
						removeFocus();
				}

			  return true;
			}

      case mouseMoved:
      {
				if (getEnvironment()->hasFocus(this) && getHoveredIndex() >= 0)
				{
				  int oldHighLighted = getHoveredIndex();
					isHighlighted_( event.MouseEvent.getPosition(), true);
					if ( getHoveredIndex() < 0 )
          {
            setHoverIndex_( oldHighLighted );   // keep last hightlight active when moving outside the area
          }
				}
				return true;
      }

      default:
			break;
			}
		break;
		
    default:
		break;
		}
	}

	return Widget::onEvent(event);
}
开发者ID:BlackFoks,项目名称:opencaesar3,代码行数:93,代码来源:mainmenu.cpp


示例12: p

void toPieChart::paintEvent(QPaintEvent *)
{
    QPainter p(this);
    paintChart(&p, QRect(0, 0, width(), height()));
}
开发者ID:Daniel1892,项目名称:tora,代码行数:5,代码来源:topiechart.cpp


示例13: main

int main()
{
    GetPsig p("test");
}
开发者ID:ddboline,项目名称:top_dilepton_me,代码行数:4,代码来源:GetPsig_t.cpp


示例14: p

void Particle::setThreeMomentum(const double px, const double py, const double pz)
{
  ThreeVector p(px, py, pz);
  this->setThreeMomentum(p);
}
开发者ID:ASavojardoW,项目名称:pp6calculator,代码行数:5,代码来源:PP6Particle.cpp


示例15: p

// fix shadowing problem in OS X
void MainWindow::paintEvent( QPaintEvent *event)
{
    QPainter p( this );
    p.setCompositionMode( QPainter::CompositionMode_Clear );
    p.fillRect( this->rect(), Qt::transparent );
}
开发者ID:Chhabi,项目名称:Penguin-Subtitle-Player,代码行数:7,代码来源:mainwindow.cpp


示例16: main

int main(int argc, char **argv)
{
    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
    if(argc<3){
        std::cout<<"This node is intend to use offline"<<std::endl<<"provide a logfile (produced with the dumpernode) and the output calibration file you want"<<std::endl;
        std::cout<<"example:"<<std::endl<<"offlineCalibration <input log filename> <output calibration filename>"<<std::endl;
        return 0;
    }
    float c0,c1,c2,c3=0;
    c0=1.0f;
    if(argc==7){
        c3=atof(argv[3]);
        c2=atof(argv[4]);
        c1=atof(argv[5]);
        c0=atof(argv[6]);
        std::cout<<"polynomial coeffs: d^3*"<<c3<<" + d^2*"<<c2<<" + d*"<<c1<<" + "<<c0<<std::endl;
    }
    std::fstream log;
    log.open(argv[1]);
    string topic;
    int height;
    int width;
    log >> topic;
    log >> height;
    log >> width;
    Matrix3f k;
    log >> k(0,0);
    log >> k(0,1);
    log >> k(0,2);
    log >> k(1,0);
    log >> k(1,1);
    log >> k(1,2);
    log >> k(2,0);
    log >> k(2,1);
    log >> k(2,2);
    string filename;
    //calibrationMatrix c(480,640,8000,4,8);
    int rows =480;
    int cols = 640;
    calibrationMatrix c(rows,cols,8000,4,16);
    //calibrationMatrix c(rows,cols,8000,4,64);
    while(!log.eof()){
        log>>filename;
        std::cout<< "opening "<<filename<<"\r"<<std::flush;
        cv::Mat data = cv::imread(filename,cv::IMREAD_ANYDEPTH);
        pointCloud p(data,k);
        //VOXELIZER
        pcl::PointCloud<pcl::PointXYZ>* pcl;
        pcl=p.pclCloud();
        calibration::voxelize(pcl,pcl,20);
        pointCloud p2(pcl);
        //CENTER SQUARE CLOUD
        pcl::PointCloud<pcl::PointXYZ>* square= new pcl::PointCloud<pcl::PointXYZ>();
        calibration::computeCenterSquareCloud(data,k,square,cols/10,rows/10,c0,c1,c2,c3); //100 100
        pointCloud p3(square);
        //CENTER PLANE
        Eigen::Vector4f centerModel;
        calibration::computerCenterPlane(square,centerModel,40);
        std::cout.flush();
        planeCloud centerPlaneCloud;
        centerPlaneCloud.model=centerModel;
        Eigen::Vector4f center;
        pcl::compute3DCentroid(*square,center);
        //std::cout<<"CENTROID DISTANCE: "<<center[2]<<" ( "<<center.transpose()<<" )"<<std::endl;
        centerPlaneCloud.com=center.head(3);
        //NORMALS
        pcl::PointCloud<pcl::Normal>* normals= new pcl::PointCloud<pcl::Normal>();
        calibration::computeNormals(p2.pclCloud(),normals,100);
        //REJECTION
        Eigen::Vector3f ref;
        std::vector<bool> valid;
        ref<<centerModel[0],centerModel[1],centerModel[2];
        pcl::PointCloud<pcl::PointXYZ> outFromNormalRejection;
        pcl::PointCloud<pcl::PointXYZ>* tmpCloud =p2.pclCloud();
        calibration::pointrejection(&ref,0.7f,tmpCloud,normals,&outFromNormalRejection,&valid);

        //pointCloud outFromNormalRejectionCloud(&outFromNormalRejection);
        //ERROR PER POINT
        pcl::PointCloud<pcl::PointXYZ> error;
        calibration::computeErrorPerPoint(tmpCloud,&error,center.head(3),ref,&valid);
        //std::cout<<"error cloud has "<<error.size()<<" points"<<std::endl;
        //std::cout<<"voxel cloud has "<<p2.pclCloud()->size()<<" points"<<std::endl;
        pcl::PointCloud<pcl::PointXYZ>* cloudToCalibrate=p2.pclCloud();
        //COMPUTE CALIBRATION MATRIX
        std::cout.flush();
        calibration::computeCalibrationMatrix(*cloudToCalibrate,error,k,&valid,c);
        std::cout.flush();
        //CALIBRATE POINT CLOUD
        pcl::PointCloud<pcl::PointXYZ> fixedCloud;
        calibration::calibratePointCloudWithMultipliers(*cloudToCalibrate,fixedCloud,c,k);
        std::cout.flush();

        error.clear();
        valid.clear();
        error.clear();
        cloudToCalibrate->clear();
        delete cloudToCalibrate;
        tmpCloud->clear();
        delete tmpCloud;
        p2.cloud.clear();
//.........这里部分代码省略.........
开发者ID:johnjsb,项目名称:easydepthcalib,代码行数:101,代码来源:offlineCalibration.cpp


示例17: while

/// Process queued scripts
void Map::ScriptsProcess()
{
    if (m_scriptSchedule.empty())
        return;

    ///- Process overdue queued scripts
    ScriptScheduleMap::iterator iter = m_scriptSchedule.begin();
    // ok as multimap is a *sorted* associative container
    while (!m_scriptSchedule.empty() && (iter->first <= sWorld->GetGameTime()))
    {
        ScriptAction const& step = iter->second;

        Object* source = NULL;
        if (step.sourceGUID)
        {
            switch (GUID_HIPART(step.sourceGUID))
            {
                case HIGHGUID_ITEM: // as well as HIGHGUID_CONTAINER
                    if (Player* player = HashMapHolder<Player>::Find(step.ownerGUID))
                        source = player->GetItemByGuid(step.sourceGUID);
                    break;
                case HIGHGUID_UNIT:
                case HIGHGUID_VEHICLE:
                    source = HashMapHolder<Creature>::Find(step.sourceGUID);
                    break;
                case HIGHGUID_PET:
                    source = HashMapHolder<Pet>::Find(step.sourceGUID);
                    break;
                case HIGHGUID_PLAYER:
                    source = HashMapHolder<Player>::Find(step.sourceGUID);
                    break;
                case HIGHGUID_GAMEOBJECT:
                    source = HashMapHolder<GameObject>::Find(step.sourceGUID);
                    break;
                case HIGHGUID_CORPSE:
                    source = HashMapHolder<Corpse>::Find(step.sourceGUID);
                    break;
                case HIGHGUID_MO_TRANSPORT:
                    for (MapManager::TransportSet::iterator iter = sMapMgr->m_Transports.begin(); iter != sMapMgr->m_Transports.end(); ++iter)
                    {
                        if ((*iter)->GetGUID() == step.sourceGUID)
                        {
                            source = *iter;
                            break;
                        }
                    }
                    break;
                default:
                    sLog->outError("%s source with unsupported high guid (GUID: " UI64FMTD ", high guid: %u).",
                        step.script->GetDebugInfo().c_str(), step.sourceGUID, GUID_HIPART(step.sourceGUID));
                    break;
            }
        }

        Object* target = NULL;
        if (step.targetGUID)
        {
            switch (GUID_HIPART(step.targetGUID))
            {
                case HIGHGUID_UNIT:
                case HIGHGUID_VEHICLE:
                    target = HashMapHolder<Creature>::Find(step.targetGUID);
                    break;
                case HIGHGUID_PET:
                    target = HashMapHolder<Pet>::Find(step.targetGUID);
                    break;
                case HIGHGUID_PLAYER:                       // empty GUID case also
                    target = HashMapHolder<Player>::Find(step.targetGUID);
                    break;
                case HIGHGUID_GAMEOBJECT:
                    target = HashMapHolder<GameObject>::Find(step.targetGUID);
                    break;
                case HIGHGUID_CORPSE:
                    target = HashMapHolder<Corpse>::Find(step.targetGUID);
                    break;
                default:
                    sLog->outError("%s target with unsupported high guid (GUID: " UI64FMTD ", high guid: %u).",
                        step.script->GetDebugInfo().c_str(), step.targetGUID, GUID_HIPART(step.targetGUID));
                    break;
            }
        }

        switch (step.script->command)
        {
            case SCRIPT_COMMAND_TALK:
                if (step.script->Talk.ChatType > CHAT_TYPE_WHISPER && step.script->Talk.ChatType != CHAT_MSG_RAID_BOSS_WHISPER)
                {
                    sLog->outError("%s invalid chat type (%u) specified, skipping.", step.script->GetDebugInfo().c_str(), step.script->Talk.ChatType);
                    break;
                }
                if (step.script->Talk.Flags & SF_TALK_USE_PLAYER)
                {
                    if (Player* pSource = _GetScriptPlayerSourceOrTarget(source, target, step.script))
                    {
                        LocaleConstant loc_idx = pSource->GetSession()->GetSessionDbLocaleIndex();
                        std::string text(sObjectMgr->GetTrinityString(step.script->Talk.TextID, loc_idx));

                        switch (step.script->Talk.ChatType)
                        {
//.........这里部分代码省略.........
开发者ID:Neecro,项目名称:SkyFireEMU_rebase,代码行数:101,代码来源:MapScripts.cpp


示例18: printf

// Draw
void
TestView::Draw(BRect updateRect)
{
	if (fCopyBitsJustCalled) {
		printf("TestView::Draw(%.1f, %.1f, %.1f, %.1f) after CopyBits()\n",
			   updateRect.left, updateRect.top, updateRect.right, updateRect.bottom);
		fCopyBitsJustCalled = false;
	}

	// background
//	SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
//	FillRect(updateRect);

	BRect r(Bounds());

	// draw some pattern with lines
	float width = r.Width();
	float height = r.Height();
	int32 lineCount = 20;
	SetPenSize(2.0);
	for (int32 i = 0; i < lineCount; i++) {
		SetHighColor(255, (255 / lineCount) * i, 255 - (255 / lineCount) * i);
		StrokeLine(BPoint(r.left + (width / lineCount) * i, r.top),
				   BPoint(r.left, r.top + (height / lineCount) * i));
		StrokeLine(BPoint(r.right - (width / lineCount) * i, r.bottom),
				   BPoint(r.right, r.bottom - (height / lineCount) * i));
	}
	StrokeLine(BPoint(r.left, r.bottom), BPoint(r.right, r.top));

	// source and dest rect
	SetPenSize(1.0);

	SetHighColor(0, 255, 0, 255);
	StrokeRect(fSourceRect);

	SetHighColor(0, 0, 255, 255);
	StrokeRect(fDestRect);

	// text
	SetHighColor(128, 0, 50, 255);

	const char* message = "Left-Click and drag";
	width = StringWidth(message);
	BPoint p(r.left + r.Width() / 2.0 - width / 2.0,
			 r.top + r.Height() / 2.0 - 50.0);

	DrawString(message, p);

	message = "to set source rect!";
	width = StringWidth(message);
	p.x = r.left + r.Width() / 2.0 - width / 2.0;
	p.y += 20;

	DrawString(message, p);

	message = "Right-Click and drag";
	width = StringWidth(message);
	p.x = r.left + r.Width() / 2.0 - width / 2.0;
	p.y += 30.0;

	DrawString(message, p);

	message = "to set destination rect!";
	width = StringWidth(message);
	p.x = r.left + r.Width() / 2.0 - width / 2.0;
	p.y += 20;

	DrawString(message, p);
}
开发者ID:mmanley,项目名称:Antares,代码行数:70,代码来源:main.cpp


示例19: p

Position Game::getFreePosition(){
    Position p(0, 0);
    while (! this->map->isFree(p)) p = Position(qrand()%this->map->getSize(), qrand()%this->map->getSize());
    return p;
}
开发者ID:Ditwoo,项目名称:bomberman,代码行数:5,代码来源:game.cpp


示例20: p

void PairsTab::addPair() {
    FEMPair* p(TruncationWizard::exec(this));
    delete p;
}
开发者ID:BOPOHOB,项目名称:NPO,代码行数:4,代码来源:pairstab.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ p0函数代码示例发布时间:2022-05-30
下一篇:
C++ owner_transfer函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap