예제 #1
0
파일: prob15.c 프로젝트: jcp19/euler
/* recursivamente: muito lento!!*/
long unsigned lp(int x, int y)
{
	long unsigned int result;
	if(x == 0 || y == 0)
		result = 1;
	else if (x == y)
		result = lp(x-1, y) * 2;
	else
		result = lp(x-1, y) + lp (x, y-1);
	return result;
}
예제 #2
0
파일: edit.c 프로젝트: NANO-DEV/NANO-S16
/*
 * Check the local screen buffer before actually updating
 * the screen
 */
static void editor_putchar(uint col, uint row, uchar c)
{
  uchar buff_c = 0;
  ul_t screen_offset = col + (row-1)*SCREEN_WIDTH;
  lmemcpy(lp(&buff_c), screen_buff + screen_offset, 1L);

  if(col==mouse_x && row==mouse_y) { /* Draw mouse where it's located */
    c = '+';
  }

  if(c != buff_c) {
    lmemcpy(screen_buff + screen_offset, lp(&c), 1L);
    putchar_attr(col, row, c, EDITOR_ATTRIBUTES);
  }
}
예제 #3
0
int SymmetryMod::Display (TimeValue t, INode* inode, ViewExp *vpt, int flagst, ModContext *mc) {

	if ( ! vpt || ! vpt->IsAlive() )
	{
		// why are we here
		DbgAssert(!_T("Invalid viewport!"));
		return FALSE;
	}


	GraphicsWindow *gw = vpt->getGW();
	Point3 pt[4];
	Matrix3 tm = CompMatrix(t,inode,mc);
	int savedLimits;

	gw->setRndLimits((savedLimits = gw->getRndLimits()) & ~GW_ILLUM);
	gw->setTransform(tm);
	if (mp_ip && mp_ip->GetSubObjectLevel() == 1) {
		gw->setColor(LINE_COLOR,GetUIColor(COLOR_SEL_GIZMOS));
	} else {
		gw->setColor(LINE_COLOR,GetUIColor(COLOR_GIZMOS));
	}
	
	DrawLineProc lp(gw);
	DrawGizmo (vpt->GetScreenScaleFactor(tm.GetTrans())*SCREEN_SCALE,lp);

	gw->setRndLimits(savedLimits);
	return 0;
}
예제 #4
0
int SymmetryMod::HitTest (TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt, ModContext* mc) {

	if ( ! vpt || ! vpt->IsAlive() )
	{
		// why are we here
		DbgAssert(!_T("Invalid viewport!"));
		return FALSE;
	}


	GraphicsWindow *gw = vpt->getGW();
	Point3 pt;
	HitRegion hr;
	int savedLimits, res = 0;
	Matrix3 tm = CompMatrix(t,inode,mc);

	MakeHitRegion(hr,type, crossing,4,p);
	gw->setHitRegion(&hr);	
	gw->setRndLimits(((savedLimits = gw->getRndLimits()) | GW_PICK) & ~GW_ILLUM);	
	gw->setTransform(tm);
	gw->clearHitCode();
	DrawLineProc lp(gw);
	DrawGizmo(
		vpt->GetScreenScaleFactor(tm.GetTrans())*SCREEN_SCALE,lp);
	gw->setRndLimits(savedLimits);
	if (gw->checkHitCode()) {
		vpt->LogHit(inode, mc, gw->getHitDistance(), 0, NULL); 
		return 1;
		}
	return 0;
}
void FilterOnePole::test() {
  float tau = 10;
  float updateInterval = 1;
  float nextupdateTime = millis()*1e-3;

  float inputValue = 0;
  FilterOnePole hp( HIGHPASS, tau, inputValue );
  FilterOnePole lp( LOWPASS, tau, inputValue );

  while( true ) {
    float now = millis()*1e-3;

    // switch input values on a 20 second cycle
    if( round(now/20.0)-(now/20.0) < 0 )
    inputValue = 0;
    else
    inputValue = 100;

    hp.input(inputValue);
    lp.input(inputValue);

    if( now > nextupdateTime ) {
      nextupdateTime += updateInterval;

      Serial.print("inputValue: "); Serial.print( inputValue );
      Serial.print("\t high-passed: "); Serial.print( hp.output() );
      Serial.print("\t low-passed: "); Serial.print( lp.output() );
      Serial.println();
    }
  }
}
예제 #6
0
int BombObject::Display(TimeValue t, INode* inode, ViewExp *vpt, int flags)
	{
	if ( ! vpt || ! vpt->IsAlive() )
	{
		// why are we here
		DbgAssert(!_T("Invalid viewport!"));
		return FALSE;
	}
	GraphicsWindow *gw = vpt->getGW();
	Material *mtl = &swMtl;
	Matrix3 mat = inode->GetObjectTM(t);
 	DWORD rlim = gw->getRndLimits();
	gw->setRndLimits(GW_WIREFRAME|GW_EDGES_ONLY|/*GW_BACKCULL|*/ (rlim&GW_Z_BUFFER?GW_Z_BUFFER:0) );//removed BC 2/16/99 DB

	gw->setTransform(mat);
	if (inode->Selected()) 
		gw->setColor( LINE_COLOR, GetSelColor());
	else if(!inode->IsFrozen())
		//gw->setColor( LINE_COLOR, swMtl.Kd[0], swMtl.Kd[1], swMtl.Kd[2]);
		gw->setColor(LINE_COLOR,GetUIColor(COLOR_SPACE_WARPS));
	mesh.render(gw, mtl, NULL, COMP_ALL);
		
	if (hParam && GetWindowLongPtr(hParam,GWLP_USERDATA)==(LONG_PTR)this &&
		GetFalloffOn(t)) {
		DrawLineProc lp(gw);
		DrawFalloffSphere(GetFalloff(t),lp);
		}

	gw->setRndLimits(rlim);
	return(0);
	}
예제 #7
0
파일: pbomb.cpp 프로젝트: DimondTheCat/xray
int PBombObject::Display(TimeValue t, INode* inode, ViewExp *vpt, int flags)
{	GraphicsWindow *gw = vpt->getGW();
	Material *mtl = &swMtl;
	Matrix3 mat = inode->GetObjectTM(t);
//	UpdateMesh(t);		
 	DWORD rlim = gw->getRndLimits();
	gw->setRndLimits(GW_WIREFRAME|GW_EDGES_ONLY|/*GW_BACKCULL|*/ (rlim&GW_Z_BUFFER?GW_Z_BUFFER:0) );//removed BC 2/16/99 DB
	gw->setTransform(mat);

	if (inode->Selected()) 
		gw->setColor( LINE_COLOR, GetSelColor());
	else if(!inode->IsFrozen())
		gw->setColor(LINE_COLOR,GetUIColor(COLOR_SPACE_WARPS));
	mesh.render(gw, mtl, NULL, COMP_ALL);
	int dorange,hoopson;
	pblock->GetValue(PB_RANGEON,0,hoopson,FOREVER);
	pblock->GetValue(PB_DECAYTYPE,0,dorange,FOREVER);
	float length;
	if (hoopson && dorange)
	{ pblock->GetValue(PB_DECAY,t,length,FOREVER);
	  float range;
	  range=length;
	  BombDrawLineProc lp(gw);
	  DrawFalloffSphere(range,lp);
	}
	gw->setRndLimits(rlim);
	return(0);
}
예제 #8
0
// HP-UX
void qt_parseEtcLpMember(QList<QPrinterDescription> *printers)
{
    QDir lp(QLatin1String("/etc/lp/member"));
    if (!lp.exists())
        return;
    QFileInfoList dirs = lp.entryInfoList();
    if (dirs.isEmpty())
        return;

#ifdef QT_NO_PRINTDIALOG
    Q_UNUSED(printers);
#else
    QString tmp;
    for (int i = 0; i < dirs.size(); ++i) {
        QFileInfo printer = dirs.at(i);
        // I haven't found any real documentation, so I'm guessing that
        // since lpstat uses /etc/lp/member rather than one of the
        // other directories, it's the one to use.  I did not find a
        // decent way to locate aliases and remote printers.
        if (printer.isFile())
            qt_perhapsAddPrinter(printers, printer.fileName(),
                                 QPrintDialog::tr("unknown"),
                                 QLatin1String(""));
    }
#endif
}
예제 #9
0
파일: fft.cpp 프로젝트: paulyc/asr
int main()
{
	//LPFilter filter(1024, 44100.0, 100.0);
	//filter.init();
	freopen("output.txt", "w", stdout);
	TestSource src;
	//KaiserWindowFilter window(512, 8.0);
	//window.init();
	//AllPassFilter ap(512);
	//ap.init();
	LPFilter lp(1024, 44100.0, 100.0);
	lp.init();
	STFTStream buffer(&src, lp, 1024, 512, 40);
	//buffer.transform();
	chunk_t *chk = buffer.next();
	for (SamplePairf *p = chk->_data; p < chk->_data + chunk_t::chunk_size; ++p)
	{
		printf("(%f,%f)\n", (*p)[0], (*p)[1]);
	}
/*	chk = buffer.next();
	for (SamplePairf *p = chk->_data; p < chk->_data + chunk_t::chunk_size; ++p)
	{
		printf("(%f,%f) ", (*p)[0], (*p)[1]);
	}
	chk = buffer.next();
	for (SamplePairf *p = chk->_data; p < chk->_data + chunk_t::chunk_size; ++p)
	{
		printf("(%f,%f) ", (*p)[0], (*p)[1]);
	}
*/	return 0;
}
예제 #10
0
파일: mirror.cpp 프로젝트: 2asoft/xray
int MirrorMod::Display(
		TimeValue t, INode* inode, ViewExp *vpt, 
		int flagst, ModContext *mc)
	{
	GraphicsWindow *gw = vpt->getGW();
	Point3 pt[4];
	Matrix3 tm = CompMatrix(t,inode,mc);
	int savedLimits;

	gw->setRndLimits((savedLimits = gw->getRndLimits()) & ~GW_ILLUM);
	gw->setTransform(tm);
	if (ip && ip->GetSubObjectLevel() == 1) {
		//gw->setColor(LINE_COLOR, (float)1.0, (float)1.0, (float)0.0);
		gw->setColor(LINE_COLOR,GetUIColor(COLOR_SEL_GIZMOS));
	} else {
		//gw->setColor(LINE_COLOR, (float).85, (float).5, (float)0.0);
		gw->setColor(LINE_COLOR,GetUIColor(COLOR_GIZMOS));
		}
	
	DrawLineProc lp(gw);
	DrawGizmo(
		vpt->GetScreenScaleFactor(tm.GetTrans())*SCREEN_SCALE,lp);
	
	gw->setRndLimits(savedLimits);
	return 0;
	}
예제 #11
0
void RunActionMarker(const char* cName)
{
	if (cName && cName[0] == '!' && !EnumProjects(0x40000000, NULL, 0)) // disabled while rendering (0x40000000 trick == rendered project, if any)
	{
		if (g_bIgnoreNext)
		{	// Ignore the entire marker action
			g_bIgnoreNext = false;
			return;
		}
		LineParser lp(false);
		lp.parse(&cName[1]);
		for (int i = 0; i < lp.getnumtokens(); i++)
		{
			int iCommand = lp.gettoken_int(i);
			if (!iCommand)
				iCommand = NamedCommandLookup(lp.gettoken_str(i));

			if (iCommand)
			{
				int iZero = 0;
				if (!kbd_RunCommandThroughHooks(NULL, &iCommand, &iZero, &iZero, &iZero, g_hwndParent))
				{
					KBD_OnMainActionEx(iCommand, 0, 0, 0, g_hwndParent, NULL);
				}
			}
		}
	}
}
 virtual LogPRowCol log_p_row_column(shared_ptr<arma::mat> z1,
                                     shared_ptr<arma::mat> z2,
                                     const ExampleIds& example_ids) {
   arma::mat w = (*z1) * (*z2);
   arma::mat y = def_data->get_mat()->cols(arma::uvec(example_ids));
   arma::mat lp(y.n_rows, y.n_cols, arma::fill::zeros);
   for(arma::uword j=0; j<y.n_cols; ++j) {
     for(arma::uword i=0; i<y.n_rows; ++i) {
       lp(i,j) = y(i,j) * (-softmax(-w(i,j))) + (1-y(i,j)) * (-softmax(w(i,j)));
     }
   }
   LogPRowCol res;
   res.log_p_row_train = shared_ptr<arma::rowvec>( new arma::rowvec(arma::sum(lp, 0)) );
   res.log_p_col_train = shared_ptr<arma::vec>( new arma::vec(arma::sum(lp, 1)) );
   return res;
 }
예제 #13
0
int FindFirstUnusedGroup()
{
	bool grp[SNM_MAX_TRACK_GROUPS];
	memset(grp, 0, sizeof(bool)*SNM_MAX_TRACK_GROUPS);

	for (int i=0; i <= GetNumTracks(); i++) // incl. master
	{
		//JFB TODO? exclude selected tracks?
		if (MediaTrack* tr = CSurf_TrackFromID(i, false))
		{
			SNM_ChunkParserPatcher p(tr);
			WDL_FastString grpLine;
			if (p.Parse(SNM_GET_SUBCHUNK_OR_LINE, 1, "TRACK", "GROUP_FLAGS", 0, 0, &grpLine, NULL, "TRACKHEIGHT"))
			{
				LineParser lp(false);
				if (!lp.parse(grpLine.Get())) {
					for (int j=1; j < lp.getnumtokens(); j++) { // skip 1st token GROUP_FLAGS
						int val = lp.gettoken_int(j);
						for (int k=0; k < SNM_MAX_TRACK_GROUPS; k++) {
							int grpMask = int(pow(2.0, k*1.0));
							grp[k] |= ((val & grpMask) == grpMask);
						}
					}
				}
			}
		}
	}

	for (int i=0; i < SNM_MAX_TRACK_GROUPS; i++) 
		if (!grp[i]) return i;

	return -1;
}
예제 #14
0
bool GetDefaultGroupFlags(WDL_FastString* _line, int _group)
{
	if (_line && _group >= 0 && _group < SNM_MAX_TRACK_GROUPS)
	{
		double grpMask = pow(2.0, _group*1.0);
		char grpDefault[SNM_MAX_CHUNK_LINE_LENGTH] = "";
		GetPrivateProfileString("REAPER", "tgrpdef", "", grpDefault, sizeof(grpDefault), get_ini_file());
		WDL_FastString defFlags(grpDefault);
		while (defFlags.GetLength() < 64) { // complete the line (64 is more than needed: future-proof)
			if (defFlags.Get()[defFlags.GetLength()-1] != ' ') defFlags.Append(" ");
			defFlags.Append("0");
		}

		_line->Set("GROUP_FLAGS ");
		LineParser lp(false);
		if (!lp.parse(defFlags.Get())) {
			for (int i=0; i < lp.getnumtokens(); i++) {
				int n = lp.gettoken_int(i);
				_line->AppendFormatted(32, "%d", !n ? 0 : (int)grpMask);
				_line->Append(i == (lp.getnumtokens()-1) ? "\n" : " ");
			}
			return true;
		}
	}
	if (_line) _line->Set("");
	return false;
}
예제 #15
0
 void LoopControl::updateWaveform(maxiSample *sample) {
     if (sample->length > 0) {
         ofClear(255);
 //        ofSetColor(255,255,255,255);
         waveFBO.begin();
         float wcx = fboWidth / 2.0;
         float wcy = fboHeight / 2.0;
         float waveRadius = ((maxCaretDist + minCaretDist) / 2);
         float numPoints = TWO_PI * waveRadius;
         float ang = TWO_PI/numPoints;
         float sampleInc = (sample->length - 1) / numPoints;
         ofSetColor(ofColor::magenta);
         float wavRange = caretDistRange / 2.0;
         ofVec2f lp(0,0);
         ofNoFill();
         for(int i=0; i < numPoints; i++) {
             float amp = sample->temp[static_cast<int>(floor(i * sampleInc))] / 32767.0;
             ofVec2f p(waveRadius + (amp * wavRange),0);
             p = p.rotateRad(i*ang);
             p.x += wcx;
             p.y += wcy;
             ofSetColor(ofColor::yellow, 200);
             ofCircle(p.x, p.y, 1 + fabs(amp * 7));
             if (i>0) {
                 ofSetColor(ofColor::magenta);
                 ofLine(p,lp);
             }
             lp = p;
         }
         waveFBO.end();
     }
     reset();
 }
int BB_Tight(int n) {
	calcPosNegAccumulative(n);
	priority_queue<state> queue;

	state st;
	lp(i, DIM) st.intervalStart[i] = 1;
	st.intervalEnd[Left] = st.intervalEnd[Right] = n;

	st.calcTightUpperBound();
	queue.push( st );

	int iters = 0;
	while ( ++iters ) {	// Best first search
		state st1 = queue.top(), st2 = st1;

		int bestSide = st1.largestInterval();

		if(st1.intervalEnd[bestSide] == st1.intervalStart[bestSide])
			break;

		st1.intervalEnd[bestSide] = (st1.intervalEnd[bestSide] + st1.intervalStart[bestSide])/2;
		st2.intervalStart[bestSide] = st1.intervalEnd[bestSide] + 1;

		queue.pop();

		st1.calcTightUpperBound(), st2.calcTightUpperBound();
		queue.push(st1), queue.push(st2);
	}

	return queue.top().upperbound;
}
예제 #17
0
파일: all_pairs.hpp 프로젝트: albertasd/ctl
void construct_graph( const Points& points, 
		      const double epsilon,
		      Graph& graph) {
    typedef typename boost::graph_traits<Graph> graph_traits;
    typedef typename graph_traits::vertex_iterator vertex_iterator;
    typedef typename boost::graph_traits< Graph>::vertex_descriptor vertex_descriptor; 
    typedef typename boost::property_map< Graph,
					  boost::vertex_name_t>::type name_map_t;
    typedef typename boost::property_traits< name_map_t>::value_type  vertex_name_t;
    typedef std::unordered_map< vertex_name_t, vertex_descriptor> Name_to_descriptor_map;

    name_map_t name_map = boost::get( boost::vertex_name, graph);
    Name_to_descriptor_map descriptor( points.size());

    // add vertices
    for( std::size_t i = 0; i < points.size(); ++i) {
	vertex_descriptor v_descriptor = boost::add_vertex( graph);
	name_map[ v_descriptor] = i;
	descriptor.emplace( i, v_descriptor);
    }

    // add edges
    vertex_iterator vi, vj, vlast;
    double epsilon_squared = epsilon*epsilon;
    for ( std::tie( vi, vlast) = boost::vertices( graph); vi != vlast; ++vi) {
      for ( std::tie( vj, vlast) = boost::vertices (graph); vj != vi; ++vj) {
       
	if( lp(points.begin(name_map[*vi]), 
	       points.end(name_map[*vi]), 
	       points.begin(name_map[*vj])) < epsilon_squared){
             boost::add_edge(*vi, *vj, graph);
       }
      } 
    }
} 
예제 #18
0
// Create new player instance, save it
// to logging in players list.
bool CLounge::addPlayer(SOCKET sd, struct in_addr* inaddr)
{   
    if (FindIPAddress(inaddr->s_addr))
    {
        CpduNotify pdu;
        char s[300];
        const char* saddr = inet_ntoa(*inaddr);
        if (saddr != NULL)
            sprintf(s, "Error: ip address %s is already logged in.", saddr);
        else
            sprintf(s, "Error: ip address %ld is already logged in.", inaddr->s_addr);
        pdu.sendNotifyMessage(sd, s);
        Sys_LogError(s);

        CPoller::Inst()->removePlayerSocket(sd);
        Sys_CloseSocket(sd);

        return false;
    }

    RegisterIPAddress(inaddr->s_addr);

    CLoginPlayer lp(sd, inaddr->s_addr);
    loggingIn_.push_back(lp);
    return true;
}
예제 #19
0
파일: Shape.cpp 프로젝트: adamh/gnash-fork
bool
Shape::pointInShape(boost::int32_t x, boost::int32_t y) const
{
    SWFMatrix wm = getWorldMatrix();
    wm.invert();
    point lp(x, y);
    wm.transform(lp);
    
    // FIXME: if the shape contains non-scaled strokes
    //        we can't rely on boundary itself for a quick
    //        way out. Bounds supposedly already include
    //        thickness, so we might keep a flag telling us
    //        whether *non_scaled* strokes are present
    //        and if not still use the boundary check.
    // NOTE: just skipping this test breaks a corner-case
    //       in DrawingApiTest (kind of a fill-leakage making
    //       the collision detection find you inside a self-crossing
    //       shape).
    if (_def) {
        if (!_def->bounds().point_test(lp.x, lp.y)) return false;
        return _def->pointTestLocal(lp.x, lp.y, wm);
    }
    assert(_shape.get());
    
    if (!_shape->getBounds().point_test(lp.x, lp.y)) return false;
    return _shape->pointTestLocal(lp.x, lp.y, wm);

}
예제 #20
0
파일: BlurTest.cpp 프로젝트: DXGL/skia
static void test_blurDrawLooper(skiatest::Reporter* reporter, SkScalar sigma,
                                SkBlurStyle style, uint32_t blurMaskFilterFlags) {
    if (kNormal_SkBlurStyle != style) {
        return; // blurdrawlooper only supports normal
    }

    const SkColor color = 0xFF335577;
    const SkScalar dx = 10;
    const SkScalar dy = -5;
    const SkBlurQuality quality = blurMaskFilterFlags_as_quality(blurMaskFilterFlags);
    uint32_t flags = blurMaskFilterFlags_to_blurDrawLooperFlags(blurMaskFilterFlags);

    SkAutoTUnref<SkDrawLooper> lp(SkBlurDrawLooper::Create(color, sigma, dx, dy, flags));

    const bool expectSuccess = sigma > 0 &&
                               0 == (flags & SkBlurDrawLooper::kIgnoreTransform_BlurFlag);

    if (NULL == lp.get()) {
        REPORTER_ASSERT(reporter, sigma <= 0);
    } else {
        SkDrawLooper::BlurShadowRec rec;
        bool success = lp->asABlurShadow(&rec);
        REPORTER_ASSERT(reporter, success == expectSuccess);
        if (success) {
            REPORTER_ASSERT(reporter, rec.fSigma == sigma);
            REPORTER_ASSERT(reporter, rec.fOffset.x() == dx);
            REPORTER_ASSERT(reporter, rec.fOffset.y() == dy);
            REPORTER_ASSERT(reporter, rec.fColor == color);
            REPORTER_ASSERT(reporter, rec.fStyle == style);
            REPORTER_ASSERT(reporter, rec.fQuality == quality);
        }
    }
}
예제 #21
0
/*==============================================================================
 * FUNCTION:		ProcTest::testName
 * OVERVIEW:		Test setting and reading name, constructor, native address
 *============================================================================*/
void ProcTest::testName ()
{
  Prog* prog = new Prog();
  BinaryFile *pBF = new BinaryFileStub();
  CPPUNIT_ASSERT(pBF != 0);
  std::string nm("default name");
  BinaryFileFactory bff;
  pBF = bff.Load(HELLO_PENTIUM);
  FrontEnd *pFE = new PentiumFrontEnd(pBF, prog, &bff);
  CPPUNIT_ASSERT(pFE != 0);
  prog->setFrontEnd(pFE);
  CPPUNIT_ASSERT(prog);
  pFE->readLibraryCatalog();				// Since we are not decoding
  m_proc = new UserProc(prog, nm, 20000); // Will print in decimal if error
  std::string actual(m_proc->getName());
  CPPUNIT_ASSERT_EQUAL(std::string("default name"), actual);

  std::string name("printf");
  LibProc lp(prog, name, 30000);
  actual =  lp.getName();
  CPPUNIT_ASSERT_EQUAL(name, actual);

  ADDRESS a = lp.getNativeAddress();
  ADDRESS expected = 30000;
  CPPUNIT_ASSERT_EQUAL(expected, a);
  a = m_proc->getNativeAddress();
  expected = 20000;
  CPPUNIT_ASSERT_EQUAL(expected, a);

  delete prog;
  delete m_proc;
  // delete pFE;		// No! Deleting the prog deletes the pFE already (which deletes the BinaryFileFactory)
}
예제 #22
0
파일: shell.c 프로젝트: cirline/ct
/**
 * split the input string to argument array
 * argc
 * argv
 */
int shell_split_cmdline(shell_t *sh, char *s)
{
	char *cur = s;
	sh->argc = 0;

	while('\0' != *s){
		cur = s;
		if(' ' == *cur || '\t' == *cur){
			s = ++cur;
			continue;
		}
		while(' ' != *cur && '\t' != *cur && '\0' != *cur)
			cur++;
		if('\0' == *cur)
			break;
		*cur = '\0';
		strcpy(sh->argv[sh->argc++], s);
		s = ++cur;
	}
	if(*s != '\0')
		strcpy(sh->argv[sh->argc++], s);
#ifdef DEBUG
	{
		int i;
		for(i = 0; i < sh->argc; i++){
			lp(DLI, "cmd[%d]: %s\n", i, sh->argv[i]);
		}
	}
#endif
	return 0;
}
예제 #23
0
void WorldPainter::paint(QPainter &p, World &world, int xt, int yt) {
	if (world.getDimensions() != 2)
		return;

	auto size = world.getZoneSize();
	int w = size.getValue(0);
	int h = size.getValue(1);

	// Draw the zones
	auto i = Size(world.getDimensions());
	for (i.setValue(0, 0) ;
	     i.getValue(0) < world.getWorldSize().getValue(0) ;
	     i.setValue(0, i.getValue(0) + 1))
	for (i.setValue(1, 0) ;
	     i.getValue(1) < world.getWorldSize().getValue(1) ;
	     i.setValue(1, i.getValue(1) + 1)) {
		int x = (int) i.getValue(0) * w + xt;
		int y = (int) i.getValue(1) * h + yt;

		p.fillRect(x, y, w, h, color(world.getZone(i)->getColor()));
	}

	// Draw the lines
	QPainter lp(&linesBuffer);
	for (auto& line : world.getLinesSince(linesSizes))
		paintWarped(lp, line, xt, yt);
	p.drawImage(0, 0, linesBuffer);

	// Draw the turtles
	for (auto& turtle : world.getTurtles())
		paint(p, *turtle, xt, yt);
}
예제 #24
0
int main(int argc, char** argv)
{
    Genome* g(new Genome());
    std::string fileName;
    if (argc > 1) {
      fileName = argv[1];
    }
    else {
      fileName = "out.sam";
    }
    g->read(fileName);
    
    QApplication app(argc, argv);
    LinearPlot lp();
    
    auto seed = g->getReadAt(1, 1);
    assume(seed != nullptr, "Error, no read found!");
    lp.setSceneRect(0, 0, 1200, 300);
    lp.fromRead(seed, g);
    
    QGraphicsView view(&lp);
    view.setWindowTitle("Chipboard demo v0.0.1");
    view.show();
    QPrinter printer;
    printer.setPaperSize(QSize(view.width(), view.height()), QPrinter::Point);
    printer.setFullPage(true);
    printer.setOutputFormat(QPrinter::PdfFormat);
    printer.setOutputFileName("plot.pdf");
    QPainter pdfPainter;
    pdfPainter.begin(&printer);
    view.render(&pdfPainter);
    return app.exec();
}
예제 #25
0
static void testlockpool1()
{
	lockpool_t lp(lockpool_t::create());

	lockentryptr alock1=lp->addLockSet("A", LIBCXX_NAMESPACE::eventfd::create());

	std::cout << "alock1: " << alock1->locked()
		  << ", " << std::flush
		  << alock1->getNotifyEvent()->event() << std::endl;

	lockentryptr alock2=lp->addLockSet("A", LIBCXX_NAMESPACE::eventfd::create());

	std::cout << "alock2: " << alock2->locked() << std::endl;

	lockentryptr alock3=lp->addLockSet("A", LIBCXX_NAMESPACE::eventfd::create());

	std::cout << "alock3: " << alock3->locked() << std::endl;

	alock3=lockentryptr();

	lockentryptr block1=lp->addLockSet("B", LIBCXX_NAMESPACE::eventfd::create());

	std::cout << "block1: " << block1->locked() << std::endl;

	std::cout << "alock2: " << alock2->locked() << std::endl;

	alock1=lockentryptr();
	std::cout << "alock2: " << alock2->locked()
		  << ", " << std::flush
		  << alock2->getNotifyEvent()->event() << std::endl;

}
예제 #26
0
void bs_signal::init(int signal_code) const {
	lpimpl lp(pimpl_);
	if(signal_code > 0)
		lp->signal_code_ = signal_code;
	else
		throw bs_kernel_exception ("bs_signal::init", no_error, "Wrong signal code given");
}
	//--------------------------------------------------------------------------------------
	void VolumeLightPost::_SetParameters ()
	{
		Engine& engine = Engine::Instance();
		Device* device = engine.GetDevice();
		device->SetShaderParameter( m_hTextureHandle, *m_pTexOrginial );

		const Matrix44f& mvp = engine.GetCamera()->GetViewProj();
		vector4f lp( engine.GetCamera()->GetPosition() + engine.GetEnvironment()->GetCurrentLight().GetWorldDirection() * engine.GetCamera()->GetMiddle()  );
		lp *= mvp ;//与摄像机的位置没有关系,所以始终只乘投影矩阵
		lp /= lp.m_w;
		float alpha = 1.0 - Math::Clamp0to1( ( lp.m_x*lp.m_x+lp.m_y*lp.m_y - 1.0 ) / 7.0 );//这个计算公式计算的是在看到太阳前的alpha衰减,假设太阳的曝光极致是在一个屏幕空间内,所以减去2.0,修改这里需要对应修改Environment的Unpdata
		vector2f lps = vector2f(lp.m_x * 0.5 + 0.5, lp.m_y * 0.5 + 0.5);
		device->SetShaderParameter( m_hLightPositionOnScreenHandle, lps );
#ifdef WIN32
		device->SetShaderParameter( m_hExposureHandle, 0.000016f );//最终曝光强度
		device->SetShaderParameter( m_hDecayHandle, 0.98f );//暗线衰减
		device->SetShaderParameter( m_hDensityHandle, 1.2f );//暗线的长度
		device->SetShaderParameter( m_hWeightHandle, 800.0f * alpha );//黑白色差权重
#else
#ifdef LOWVOLUMELIGHT
		device->SetShaderParameter( m_hExposureHandle, 0.0003f );//最终曝光强度
		device->SetShaderParameter( m_hDecayHandle, 0.87f );//暗线衰减
		device->SetShaderParameter( m_hDensityHandle, 0.6f );//暗线的长度
		device->SetShaderParameter( m_hWeightHandle, 550.0f * alpha );//黑白色差权重
#else
		device->SetShaderParameter( m_hExposureHandle, 0.00032f );//最终曝光强度
		device->SetShaderParameter( m_hDecayHandle, 0.88f );//暗线衰减
		device->SetShaderParameter( m_hDensityHandle, 0.8f );//暗线的长度
		device->SetShaderParameter( m_hWeightHandle, 320.0f * alpha );//黑白色差权重
#endif
#endif
	}
void log_IE_window_handles( ImmediateSession & session )
{
  session.Log( "log_IE_window_handles" ) ;
  const wchar_t * IE_names[] = { L"IExplore.exe", L"AdblockPlusEngine.exe" } ;
  ProcessSnapshot snapshot ;
  ProcessCloser iec(snapshot, IE_names) ;
  log_single_window_handle_only_if_IE lp( session, iec ) ;
  EnumerateWindows( lp ) ;
}
예제 #29
0
// Set the AUXRECV string using the second parameter in the string as the destination track GUID
TrackSend::TrackSend(const char* str)
{
	LineParser lp(false);
	lp.parse(str);
	stringToGuid(lp.gettoken_str(1), &m_destGuid);
	// Strip out the "AUXRECV X" header
	const char* p = strchr(str + 8, ' ') + 1;
	m_str.Set(p);
}
예제 #30
0
파일: BR_Update.cpp 프로젝트: Breeder/sws
void GetStartupSearchOptions (bool* official, bool* beta, unsigned int* lastTime)
{
	char tmp[256];
	GetPrivateProfileString("SWS", STARTUP_VERSION_KEY, "", tmp, sizeof(tmp), get_ini_file());

	LineParser lp(false);
	lp.parse(tmp);
	WritePtr(official, (lp.getnumtokens() > 0) ? !!lp.gettoken_int(0) : true);
	WritePtr(beta,     (lp.getnumtokens() > 1) ? !!lp.gettoken_int(1) : false);
	WritePtr(lastTime, lp.gettoken_uint(2));
}