示例#1
0
void
EBSDAccessFunctorsTest::test()
{
  RealVectorValue reference_angle(0.1, 0.2, 0.3);
  Point reference_point1 = Point(9.0, 10.0, 11.0);
  Point reference_point2 = Point(6.0, 7.0, 8.0);

  // Test point data access
  {
    EBSDPointDataPhi1 phi1;
    CPPUNIT_ASSERT( phi1(_point) == _point._phi1 );
    EBSDPointDataPhi phi;
    CPPUNIT_ASSERT( phi(_point) == _point._Phi );
    EBSDPointDataPhi2 phi2;
    CPPUNIT_ASSERT( phi2(_point) == _point._phi2 );

    EBSDPointDataPhase phase;
    CPPUNIT_ASSERT( phase(_point) == _point._phase );
    EBSDPointDataSymmetry symmetry;
    CPPUNIT_ASSERT( symmetry(_point) == _point._symmetry );
    EBSDPointDataGrain grain;
    CPPUNIT_ASSERT( grain(_point) == _point._grain );
    EBSDPointDataOp op;
    CPPUNIT_ASSERT( op(_point) == _point._op );

    for (unsigned int i = 0; i < 3; ++i)
    {
      EBSDPointDataCustom custom(i);
      CPPUNIT_ASSERT( custom(_point) == _point._custom[i] );
    }
  }

  // Test average data access
  {
    RealVectorValue angle = *(_avg._angles);
    CPPUNIT_ASSERT( (angle - reference_angle).size() == 0 );

    EBSDAvgDataPhi1 phi1;
    CPPUNIT_ASSERT( phi1(_avg) == angle(0) );
    EBSDAvgDataPhi phi;
    CPPUNIT_ASSERT( phi(_avg) == angle(1) );
    EBSDAvgDataPhi2 phi2;
    CPPUNIT_ASSERT( phi2(_avg) == angle(2) );

    EBSDAvgDataPhase phase;
    CPPUNIT_ASSERT( phase(_avg) == _avg._phase );
    EBSDAvgDataSymmetry symmetry;
    CPPUNIT_ASSERT( symmetry(_avg) == _avg._symmetry );
    EBSDAvgDataGrain grain;
    CPPUNIT_ASSERT( grain(_avg) == _avg._grain );
    EBSDAvgDataLocalID local;
    CPPUNIT_ASSERT( local(_avg) == _avg._local );

    for (unsigned int i = 0; i < 3; ++i)
    {
      EBSDAvgDataCustom custom(i);
      CPPUNIT_ASSERT( custom(_avg) == _avg._custom[i] );
    }
  }
}
示例#2
0
void texture::display( const std::string &title ) const
{
    const texture &pic = *this;

    cimg_library::CImg<unsigned char> ctexture( pic.w, pic.h, 1, 4, 0 );

    for( size_t y = 0; y < pic.h; ++y )
        for( size_t x = 0; x < pic.w; ++x )
        {
            pixel pix = pic.at( x, y ).clamp();

            ctexture( x, y, 0 ) = (unsigned char)(pix.r * 255.f);
            ctexture( x, y, 1 ) = (unsigned char)(pix.g * 255.f);
            ctexture( x, y, 2 ) = (unsigned char)(pix.b * 255.f);
            ctexture( x, y, 3 ) = (unsigned char)(pix.a * 255.f);
        }

#if 1
    ctexture
//        .deriche(0.5)
    .display( title.size() ? title.c_str() : custom("[\1] moon9::texture", this).c_str() );
#else
    cimg_library::CImgDisplay disp;
    disp.resize( pic.w, pic.h );

    ctexture.display( disp );
    while(!disp.is_closed());
#endif
}
示例#3
0
int Mv_management::get_dir(int i)
{
    if (data->vcEvents[i].vcPage[0].Movement_type==0)//do not move
        return(5);
    if (data->vcEvents[i].vcPage[0].Movement_type==1)// random
    {
        return(random_move( i));
    }
    if (data->vcEvents[i].vcPage[0].Movement_type==2)// up down
    {
        return(up_down(i));
    }
    if (data->vcEvents[i].vcPage[0].Movement_type==3)// left right
    {
        return(left_right(i));
    }
    if (data->vcEvents[i].vcPage[0].Movement_type==4)// go to the hero
    {
        return(to_hero(i));
    }
    if (data->vcEvents[i].vcPage[0].Movement_type==5)// run frome the hero
    {
        return(escape_hero(i));
    }
    if (data->vcEvents[i].vcPage[0].Movement_type==6)// use the stack
    {
     return(custom(i));
    }

    return(5);
}
示例#4
0
// Make a prediction for conditional branch instruction at PC 'pc'
// Returning TAKEN indicates a prediction of taken; returning NOTTAKEN
// indicates a prediction of not taken
//
uint8_t
make_prediction(uint32_t pc)
{
    //
    //TODO: Implement prediction scheme
    //
    
    // Make a prediction based on the bpType
    switch (bpType) {
        case STATIC:
            return TAKEN;
            break;
        case GSHARE:
            return gshare(pc);
            break;
        case LOCAL:
        	return local(pc);
        	break;
        case TOURNAMENT:
        	return tournament(pc);
        	break;
        case CUSTOM:
        	return custom(pc);
        	break;
        default:
            break;
    }
    
    // If there is not a compatable bpType then return NOTTAKEN
    return NOTTAKEN;
}
示例#5
0
static void stopservice(struct svdir *s)
{
	if (s->pid && !custom(s, 't')) {
		kill(s->pid, SIGTERM);
		s->ctrl |= C_TERM;
		update_status(s);
	}
	if (s->sd_want == W_DOWN) {
		kill(s->pid, SIGCONT);
		custom(s, 'd');
		return;
	}
	if (s->sd_want == W_EXIT) {
		kill(s->pid, SIGCONT);
		custom(s, 'x');
	}
}
示例#6
0
CursorView::CursorView()			// construct view
{
    static struct {
	QCursorShape	shape;					
	const char*	name;			// cursor name
    } list[] = {
	{ ArrowCursor,		"arrowCursor" },
	{ UpArrowCursor,	"upArrowCursor" },
	{ CrossCursor,		"crossCursor" },
	{ WaitCursor,		"waitCursor" },
	{ IbeamCursor,		"ibeamCursor" },
	{ SizeVerCursor,	"sizeVerCursor" },
	{ SizeHorCursor,	"sizeHorCursor" },
	{ SizeBDiagCursor,	"sizeBDiagCursor" },
	{ SizeFDiagCursor,	"sizeFDiagCursor" },
	{ SizeAllCursor,	"sizeAllCursor" },
	{ BlankCursor,		"blankCursor" },
	{ SplitVCursor,		"splitVCursor" },
	{ SplitHCursor,		"splitHCursor" },
	{ PointingHandCursor,	"pointingHandCursor" },
	{ ForbiddenCursor,	"forbiddenCursor" },
	{ BitmapCursor,		"" }		// sentinel
    };

    setCaption( "CursorView" );			// set window caption

    QGridLayout* grid = new QGridLayout( this, 5, 4, 20 );
    QLabel *label;

    int i=0;
    for ( int y=0; y<4; y++ ) {			// create the small labels
	for ( int x=0; x<4; x++ ) {
	    if ( list[i].shape == BitmapCursor )
		break;

	    label = new QLabel( this );
	    label->setCursor( QCursor( list[i].shape ) );
	    label->setText( list[i].name );
	    label->setAlignment( AlignCenter );
	    label->setFrameStyle( QFrame::Box | QFrame::Raised );
	    grid->addWidget( label, x, y );
	    i++;
	}
    }

    QBitmap cb( cb_width, cb_height, cb_bits, TRUE );
    QBitmap cm( cm_width, cm_height, cm_bits, TRUE );
    QCursor custom( cb, cm );			// create bitmap cursor

    label = new QLabel( this );			// create the big label
    label->setCursor( custom );
    label->setText( "Custom bitmap cursor" );
    label->setAlignment( AlignCenter );
    label->setFrameStyle( QFrame::Box | QFrame::Sunken );
    grid->addMultiCellWidget( label, 4, 4, 0, 3 );

}
示例#7
0
 const HeaderStrategy * HeaderStrategy::create( const QString & type ) {
   QString lowerType = type.lower();
   if ( lowerType == "all" )  return all();
   if ( lowerType == "rich" )   return HeaderStrategy::rich();
   //if ( lowerType == "standard" ) return standard(); // not needed, see below
   if ( lowerType == "brief" ) return brief();
   if ( lowerType == "custom" )  return custom();
   // don't kdFatal here, b/c the strings are user-provided
   // (KConfig), so fail gracefully to the default:
   return standard();
 }
示例#8
0
  const HeaderStrategy * HeaderStrategy::create( Type type ) {
    switch ( type ) {
    case All:  return all();
    case Rich:   return rich();
    case Standard: return standard();
    case Brief:  return brief();
    case Custom:  return custom();
    }
    kdFatal( 5006 ) << "HeaderStrategy::create(): Unknown header strategy ( type == "
		    << (int)type << " ) requested!" << endl;
    return 0; // make compiler happy
  }
示例#9
0
static void startservice(struct svdir *s)
{
	int p;
	char *run[2];

	if (s->state == S_FINISH)
		run[0] = (char*)"./finish";
	else {
		run[0] = (char*)"./run";
		custom(s, 'u');
	}
	run[1] = NULL;

	if (s->pid != 0)
		stopservice(s); /* should never happen */
	while ((p = vfork()) == -1) {
		warn_cannot("vfork, sleeping");
		sleep(5);
	}
	if (p == 0) {
		/* child */
		if (haslog) {
			/* NB: bug alert! right order is close, then dup2 */
			if (s->islog) {
				xchdir("./log");
				close(logpipe.wr);
				xdup2(logpipe.rd, 0);
			} else {
				close(logpipe.rd);
				xdup2(logpipe.wr, 1);
			}
		}
		bb_signals(0
			+ (1 << SIGCHLD)
			+ (1 << SIGTERM)
			, SIG_DFL);
		sig_unblock(SIGCHLD);
		sig_unblock(SIGTERM);
		execvp(*run, run);
		fatal2_cannot(s->islog ? "start log/" : "start ", *run);
	}
	/* parent */
	if (s->state != S_FINISH) {
		gettimeofday_ns(&s->start);
		s->state = S_RUN;
	}
	s->pid = p;
	pidchanged = 1;
	s->ctrl = C_NOOP;
	update_status(s);
}
int main()
{
    sf::RenderWindow window(sf::VideoMode(800,600,32), "Starfield Example", sf::Style::Default);

    sf::Font myfont;
    if(!myfont.loadFromFile("fonts/contb.ttf"))//http://www.dafont.com/continuum.font
    {
        std::cerr<<"Could not find contb.ttf font."<<std::endl;
    }

    gui::button yeah("Yeah!", myfont, sf::Vector2f(100.f,100.f), gui::style::save);
    gui::button nope("Nope", myfont, sf::Vector2f(100.f, 200.f), gui::style::cancel);
    gui::button nice("Nice...", myfont, sf::Vector2f(300.f, 100.f), gui::style::clean);
    gui::button custom("Sweet", myfont, sf::Vector2f(300.f, 200.f), gui::style::none);
    custom.setBorderThickness(2.f);
    custom.setBorderRadius(20.f);
    custom.setBorderColor(sf::Color(255,255,255,255));
    custom.setColorNormal(sf::Color(200,0,200,255));
    custom.setColorHover(sf::Color(255,0,255,100));
    custom.setColorClicked(sf::Color(150,0,150,255));
    custom.setColorTextNormal(sf::Color(255,255,255,255));
    custom.setColorTextHover(sf::Color(255,255,0,255));
    custom.setColorTextClicked(sf::Color(255,0,0,255));

    sf::Event e;
    bool running = true;
    while(running)
    {
        while(window.pollEvent(e))
        {
            if(e.type == sf::Event::Closed)
            {
                window.close();
                return 0;
            }
        }
            yeah.update(e,window);
            nope.update(e,window);
            nice.update(e,window);
            custom.update(e,window);

            window.clear();
            window.draw(yeah);
            window.draw(nope);
            window.draw(nice);
            window.draw(custom);
            window.display();
    }
    return 0;
}
示例#11
0
void MTLmarks::DmatScalarRun(std::string benchmark) {
    
    if(benchmark == "dmatscalarmult"){
        mtl_result = dmatscalarmult(size, steps);
    }
    else if(benchmark == "custom"){
        mtl_result = custom(size, steps);
    }
    else{
        std::cerr << "MTLmarks benchmark does not exist." << std::endl;
        exit(1);
    }
    
}
示例#12
0
void MTLmarks::SmatVecRun(std::string benchmark) {
    
    if(benchmark == "smatvecmult"){
        mtl_result = smatvecmult(size, steps);
    }
    else if(benchmark == "custom"){
        mtl_result = custom(size, steps);
    }
    else{
        std::cerr << "MTLmarks benchmark does not exist." << std::endl;
        exit(1);
    }
    
}
示例#13
0
void Eigenmarks::SmatSvecRun(std::string benchmark) {
    
    if(benchmark == "smatsvecmult"){
        eigen_result = smatsvecmult(size, steps);
    }
    else if(benchmark == "custom"){
        eigen_result = custom(size, steps);
    }
    else{
        std::cerr << "Eigenmarks benchmark does not exist." << std::endl;
        exit(1);
    }
    
}
示例#14
0
文件: key.cpp 项目: Skyh13/MuseScore
void KeySigEvent::print() const
      {
      qDebug("<KeySigEvent: ");
      if (!isValid())
            qDebug("invalid>");
      else {
            if (isAtonal())
                  qDebug("atonal>");
            else if (custom())
                  qDebug("custom>");
            else
                  qDebug("accidental %d>", int(_key));
            }
      }
示例#15
0
void MTLmarks::DmatDmatRun(std::string benchmark) {
    
    if(benchmark == "dmatdmatadd"){
        mtl_result = dmatdmatadd(size, steps);
    }
    else if(benchmark == "dmatdmatmult"){
        mtl_result = dmatdmatmult(size, steps);
    }
    else if(benchmark == "cmajordmdmmult"){
        mtl_result = cmajordmdmmult(size, steps);
    }
    else if(benchmark == "rmajordmdmmult"){
        mtl_result = rmajordmdmmult(size, steps);
    }
    else if(benchmark == "nestedprod"){
        mtl_result = nestedprod(size, steps);
    }
    else if(benchmark == "symm1"){
        mtl_result = symm1(size, steps);
    }
    else if(benchmark == "symm1rect"){
        mtl_result = symm1rect(size, steps);
    }
    else if(benchmark == "symm2"){
        mtl_result = symm2(size, steps);
    }
    else if(benchmark == "syr2k"){
        mtl_result = syr2k(size, steps);
    }
    else if(benchmark == "syr2krect"){
        mtl_result = syr2krect(size, steps);
    }
    else if(benchmark == "syrk"){
        mtl_result = syrk(size, steps);
    }
    else if(benchmark == "syrkrect"){
        mtl_result = syrkrect(size, steps);
    }
    else if(benchmark == "custom"){
        mtl_result = custom(size, steps);
    }
    else{
        std::cerr << "MTLmarks benchmark does not exist." << std::endl;
        exit(1);
    }
    
}
示例#16
0
void Eigenmarks::VecScalarRun(std::string benchmark) {
    
    if(benchmark == "vecscalarmult"){
        eigen_result = vecscalarmult(size, steps);
    }
    else if(benchmark == "scale"){
        eigen_result = scale(size, steps);
    }
    else if(benchmark == "custom"){
        eigen_result = custom(size, steps);
    }
    else{
        std::cerr << "Eigenmarks benchmark does not exist." << std::endl;
        exit(1);
    }
    
}
示例#17
0
文件: actions.c 项目: thamnos/Slider
static void pens(const char *cmd) {
	cairo_surface_t *buf, *cbuf, *t;
	cairo_t *ctx;
	char str[CURSOR_STRING_MAX];
	Theme q;
	sscanf(cmd, "%*s %lf %lf %lf %lf %lf %s\n",
			&q.R, &q.G, &q.B, &q.A, &q.e, str);
	XWarpPointer(dpy, None, wshow, 0, 0, 0, 0, sw/2, sh/2);
	/* create duplicate buffers */
	t = cairo_xlib_surface_create(dpy, wshow, vis, sw, sh);
	buf = cairo_surface_create_similar(t, CAIRO_CONTENT_COLOR, sw, sh);
	cbuf = cairo_surface_create_similar(t, CAIRO_CONTENT_COLOR, sw, sh);
	ctx = cairo_create(cbuf);
	cairo_set_source_surface(ctx, t, 0, 0);
	cairo_paint(ctx);
	cairo_destroy(ctx);
	ctx = cairo_create(buf);
	cairo_set_source_surface(ctx, t, 0, 0);
	cairo_paint(ctx);
	cairo_surface_destroy(t);
	/* set drawing parameters */
	cairo_set_line_join(ctx, CAIRO_LINE_JOIN_ROUND);
	cairo_set_line_cap(ctx, CAIRO_LINE_CAP_ROUND);
	cairo_set_source_rgba(ctx, q.R, q.G, q.B, q.A);
	cairo_set_line_width(ctx, q.e);
	// set font
	cairo_set_font_size(ctx, q.e);
	grab_mouse();
	/* call appropriate sub function */
	cairo_move_to(ctx, sw/2, sh/2);
	if (strncasecmp(cmd,"pen",3)==0) pen(ctx, buf, cbuf, &q);
	else if (strncasecmp(cmd,"dot",3)==0) dot(ctx, buf, cbuf, &q);
	else if (strncasecmp(cmd,"cust",4)==0) custom(ctx, buf, cbuf, &q, str);
	else if (strncasecmp(cmd,"zoom",4)==0) zoom(ctx, buf, cbuf, &q);
	/* clean up */
	XUngrabPointer(dpy, CurrentTime);
	cairo_surface_destroy(buf);
	cairo_surface_destroy(cbuf);
	cairo_destroy(ctx);
	XDefineCursor(dpy, wshow, invisible_cursor);
}
示例#18
0
void MTLmarks::DmatVecRun(std::string benchmark) {
    
    if(benchmark == "dmatvecmult"){
        mtl_result = dmatvecmult(size, steps);
    }
    else if(benchmark == "gemv1"){
        mtl_result = gemv1(size, steps);
    }
    else if(benchmark == "gemv2"){
        mtl_result = gemv2(size, steps);
    }
    else if(benchmark == "ger1"){
        mtl_result = ger1(size, steps);
    }
    else if(benchmark == "syr"){
        mtl_result = syr(size, steps);
    }
    else if(benchmark == "trmv1"){
        mtl_result = trmv1(size, steps);
    }
    else if(benchmark == "trmv2"){
        mtl_result = trmv2(size, steps);
    }
    else if(benchmark == "cmajordmvmult"){
        mtl_result = cmajordmvmult(size, steps);
    }
    else if(benchmark == "rmajordmvmult"){
        mtl_result = rmajordmvmult(size, steps);
    }
    else if(benchmark == "custom"){
        mtl_result = custom(size, steps);
    }
    else{
        std::cerr << "Ublasmarks benchmark does not exist." << std::endl;
        exit(1);
    }
    
}
示例#19
0
void MTLmarks::VecVecRun(std::string benchmark) {
    
    if(benchmark == "daxpy"){
        mtl_result = daxpy(size, steps);
    }
    else if(benchmark == "vecvecadd"){
        mtl_result = vecvecadd(size, steps);
    }
    else if(benchmark == "vecvecmult"){
        mtl_result = vecvecmult(size, steps);
    }
    else if(benchmark == "dotproduct"){
        mtl_result = dotproduct(size, steps);
    }
    else if(benchmark == "custom"){
        mtl_result = custom(size, steps);
    }
    else{
        std::cerr << "MTLmarks benchmark does not exist." << std::endl;
        exit(1);
    }
    
}
Unit* UnitFactory::parseUnitBuffer( NetBuffer &netbuf )
{
    ObjSerial serial = netbuf.getSerial();
    string    file( netbuf.getString() );
    string    name( netbuf.getString() );
    string    fullname( netbuf.getString() );
    bool sub    = netbuf.getChar();
    int faction = netbuf.getInt32();
    string    fname( netbuf.getString() );
    string    custom( netbuf.getString() );
    int fg_num  = netbuf.getInt32();

    cerr<<"NETCREATE UNIT : "<<file<<" ("<<serial<<")"<<endl;

    string facname = FactionUtil::GetFactionName( faction );
    if ( facname.empty() ) {
        //Got an invalid faction number...
        cerr<<"    Unit has an invalid faction "<<faction<<endl;
        faction = 0;
    }
    Flightgroup *fg = NULL;
    if ( !fname.empty() ) {
        fg = mission[0].findFlightgroup( fname, facname );
        if (!fg)
            fg = Flightgroup::newFlightgroup( fname, file, facname,
                                              "default", 1, 1, "", "", mission );
    }
    Unit *un = createUnit( file.c_str(), sub, faction, custom, fg, fg_num, NULL, serial );
    if (netbuf.version() <= 4951)
        un->curr_physical_state = netbuf.getTransformation();
    else
        netbuf.getClientState().setUnitState( un );
    un->name     = name;
    un->fullname = fullname;
    return un;
}
示例#21
0
文件: mvcli.cpp 项目: intrig/ict
int main(int argc, char **argv) {

    try {
        ict::command line("multivectorcli", "ict::multivector exerciser", "mvcli [options]");
        line.add(ict::option("basics", 'b', "Display basic multivector calls",      []{ basics(); } ));
        line.add(ict::option("iterate", 'i', "Display iterator calls",       []{ iterate(); } ));
        line.add(ict::option("strings", 's', "Display string multivector calls",    []{ strings(); } ));
        line.add(ict::option("custom", 'c', "Display custom multivector calls",     []{ custom(); } ));
        line.add(ict::option("generate", 'g', "generate advanced multivector",      []{ generate(); } ));
        line.add(ict::option("constness", 'C', "const iterators/cursors",      []{ constness(); } ));
        line.add(ict::option("All", 'A', "run all", []{ 
            basics();
            iterate();
            strings(); 
            custom();
            generate();
            constness();
        } ));

        line.parse(argc, argv);
    } catch (std::exception & e) {
        std::cerr << e.what() << std::endl;
    }
}
示例#22
0
/* Serves as a switchboard to the chosen rating prediction algorithm */
void calculate (void)
{
	/* Declare variables for use in functions */
    // Counters
	int i, j;
    // Variable to hold calculated rating
    int rating;
    // Variable to hold which algorithm the user chooses for use in the switch loop
    int algorithm;

	/* Ask user which algorithm to use */
	printf ("\nWhich algorithm would you like to use to predict ratings?\n");
	printf ("1 - Pearson Correlation\n");
	printf ("2 - Vector Similarity\n");
	printf ("3 - Pearson Correlation - Inverse User Frequency\n");
	printf ("4 - Pearson Correlation - Case Modification\n");
	printf ("5 - Cosine Similarity\n");
	printf ("6 - Custom Algorithm\n");
    // Scan user answer
	scanf ("%d", &algorithm);

	/* Iterate through array to find ratings that need to be calculated */
    // Start user counter at userOffset (starting user ID - 1)
	for (i=userOffset; i<userOffset+100; i++)
	{
        // Start movie counter at 0 (movie ID - 1)
		for (j=0; j<1000; j++)
		{
            // If the value stored for that user and ID is 0 (meaning a non-null 0, "null" being defined as 9)
			if (ratings[i][j] == 0)
			{
                // Extract the user ID and movie ID for use in the selected algorithm
				int user = i;
				int movie = j;
				/* Call the appropriate calculation function */
				switch (algorithm)
				{
                        // Input 1 means Pearson Correlation
					case 1:
						rating = pearsonStandard (user, movie);
						break;
						
                        // Input 2 means Vector Similarity
					case 2:
						rating = vector (user, movie);
						break;
						
                        // Input 3 means Inverse User Frequency using Pearson Correlation
					case 3:
						rating = pearsonInverse (user, movie);
						break;
						
                        // Input 4 means Case Modification using Pearson Correlation
					case 4:
						rating = pearsonCase (user, movie);
						break;
						
                        // Input 5 means Adjusted Cosine Similarity
					case 5:
						rating = cosineSimilarity (user, movie);
						break;
						
                        // Input 6 means my custom algorithm
					case 6:
						rating = custom (user, movie);
						break;
					
                        // If value is not within defined range, default to case 1
					default:
						rating = pearsonStandard (user, movie);
						break;
				}
                // Conver user ID to user index and set that corresponding user/movie value to the calculated rating
				ratingResults[user-userOffset][movie] = rating;
			}
		}
	}
}
示例#23
0
BilderCW::BilderCW( QWidget *parent, const char *name, prefs *pr_, VString pat, double *ca, double *cp, double *extent, double *fixpoint, const char *version, int *scalingfaktor )
  : QWidget( parent, name ), pr(pr_), pat_m(pat), version_m(version), ca_m(ca), cp_m(cp), extent_m(extent), fixpoint_m(fixpoint), scalingfaktor_m(scalingfaktor)
{
  if (pr->verbose) fprintf(stderr,"Starting bilderCW...\n");

    
  rows=VImageNRows(src[0]);
  columns=VImageNColumns(src[0]);
  bands=VImageNFrames(src[0]);
  
  if (fnc[0]) {
    fnc_rows=VImageNRows(fnc[pr->active]);
    fnc_columns=VImageNColumns(fnc[pr->active]);
    fnc_bands=VImageNFrames(fnc[pr->active]);
  } else {
    fnc_rows=0;
    fnc_columns=0;
    fnc_bands=0;
  }
  

  if (pr->hgfarbe[0]==1) {
    setPalette( QPalette( QColor( 255, 255, 255 ) ) );
  } else {
    setPalette( QPalette( QColor( 0,0,0) ) );
  }
  hlayout = new QHBoxLayout( this, 0 );
  layout = new QGridLayout( hlayout, 0, (int)pr->infilenum/4, 0);

  pr->ogl=0;
  if ( QGLFormat::hasOpenGL() && pr->graph[0] ) pr->ogl=1;
  
  QBitmap cb( cb_width, cb_height, cb_bits, TRUE );
  QBitmap cm( cm_width, cm_height, cm_bits, TRUE );
  QCursor custom( cb, cm );                   // create bitmap cursor
  if (pr->verbose) qDebug("GL-Support %d\n", pr->ogl);

  files=pr->infilenum;
  if (pr->infilenum>=pr->zmapfilenum) {
    if (pr->infilenum>pr->zmapfilenum && pr->zmapfilenum>1) {
      QMessageBox::warning( this, "error",
			  "error\n" );
    }
    files=pr->infilenum;
  } else {
    if (pr->infilenum<pr->zmapfilenum && pr->infilenum>1) {
      QMessageBox::warning( this, "error",
			  "error\n" );
    }
    else
      files=pr->zmapfilenum;
  }

  bild1 = (pictureView **) VMalloc(sizeof(pictureView *) * (files+1) );
  bild2 = (pictureView **) VMalloc(sizeof(pictureView *) * (files+1) );
  bild3 = (pictureView **) VMalloc(sizeof(pictureView *) * (files+1) );
  ogl = (MyGLDrawer **) VMalloc(sizeof(MyGLDrawer *) * (files+1) );

  if (fnc[0]) {
    pr->slidefaktor[0] = 1000.0/(pr->pmax-pr->zeropoint);
    pr->slidefaktor[1] = 1000.0/(pr->nmax+pr->zeropoint);

    posslide = new QSlider( QSlider::Vertical, this,
			    "positive" );
    posslide->setPalette( parent->palette() );
    posslide->setCursor( pointingHandCursor );
    QToolTip::add( posslide, QRect( 0, 0, 2, 2 ), "positive slider" );
    QWhatsThis::add( posslide, "This is a Slider.\n"
		     "Here you can change the positive threshold for the z-value.");
    negslide = new QSlider( QSlider::Vertical, this,
			    "negative" );
    negslide->setPalette( parent->palette() );
    negslide->setCursor( pointingHandCursor );
    QToolTip::add( negslide, QRect( 0, 0, 2, 2 ), "negative slider" );
    QWhatsThis::add( negslide, "This is a Slider.\n"
		     "Here you can change the negative threshold for the z-value.");
    posslide->setGeometry( 10, 80, 100, 15 );
    posslide->setRange( int(pr->zeropoint*pr->slidefaktor[0]), int(pr->pmax*pr->slidefaktor[0]) );
    posslide->setValue( int(pr->thresh*pr->slidefaktor[0]) );
    posslide->setTickmarks(QSlider::TickSetting( 2 ));
    posslide->setTickInterval((int)100);
    posslide->setFocusPolicy ( QWidget::NoFocus);
    negslide->setGeometry( 10, 80, 100, 15 );
    negslide->setRange( int(-pr->zeropoint*pr->slidefaktor[1]), int(pr->nmax*pr->slidefaktor[1]) );
    if ( pr->thresh )
      negslide->setValue( int(pr->nmax*pr->slidefaktor[1]) );
    else
      negslide->setValue( int(pr->zeropoint*pr->slidefaktor[1]) );
    negslide->setTickmarks(QSlider::TickSetting( 2 ));
    negslide->setTickInterval((int)100);
    negslide->setFocusPolicy ( QWidget::NoFocus);
  }

	     

  gLayout(this);
  if (pr->verbose) fprintf(stderr,"end of bilderCW.C\n");
}
示例#24
0
void test_custom()
{

//  Inside the range, equal to the endpoints, and outside the endpoints.
    BOOST_CHECK_EQUAL ( custom( 3), ba::clamp ( custom( 3), custom(1), custom(10)));
    BOOST_CHECK_EQUAL ( custom( 1), ba::clamp ( custom( 1), custom(1), custom(10)));
    BOOST_CHECK_EQUAL ( custom( 1), ba::clamp ( custom( 0), custom(1), custom(10)));
    BOOST_CHECK_EQUAL ( custom(10), ba::clamp ( custom(10), custom(1), custom(10)));
    BOOST_CHECK_EQUAL ( custom(10), ba::clamp ( custom(11), custom(1), custom(10)));

    BOOST_CHECK_EQUAL ( custom( 3), ba::clamp ( custom( 3), custom(1), custom(10), customLess ));
    BOOST_CHECK_EQUAL ( custom( 1), ba::clamp ( custom( 1), custom(1), custom(10), customLess ));
    BOOST_CHECK_EQUAL ( custom( 1), ba::clamp ( custom( 0), custom(1), custom(10), customLess ));
    BOOST_CHECK_EQUAL ( custom(10), ba::clamp ( custom(10), custom(1), custom(10), customLess ));
    BOOST_CHECK_EQUAL ( custom(10), ba::clamp ( custom(11), custom(1), custom(10), customLess ));

//  Fail!!
//  BOOST_CHECK_EQUAL ( custom(1), ba::clamp ( custom(11), custom(1), custom(10)));
}
示例#25
0
int main(int argc, char **argv)
{
#ifdef CONSOLE_APPLICATION
    QApplication app(argc, argv, QApplication::Tty);
#else
    QApplication app(argc, argv);
#endif
#ifdef DO_QWS_DEBUGGING
    qt_show_painter_debug_output = false;
#endif

    DeviceType type = WidgetType;
    bool checkers_background = true;

    QImage::Format imageFormat = QImage::Format_ARGB32_Premultiplied;

    QLocale::setDefault(QLocale::c());

    QStringList files;

    bool interactive = false;
    bool printdlg = false;
    bool highres = false;
    bool show_cmp = false;
    int width = 800, height = 800;
    bool verboseMode = false;

#ifndef QT_NO_OPENGL
    QGLFormat f = QGLFormat::defaultFormat();
    f.setSampleBuffers(true);
    f.setStencil(true);
    f.setAlpha(true);
    f.setAlphaBufferSize(8);
    QGLFormat::setDefaultFormat(f);
#endif

    char *arg;
    for (int i=1; i<argc; ++i) {
        arg = argv[i];
        if (*arg == '-') {
            QString option = QString(arg + 1).toLower();
            if (option == "widget")
                type = WidgetType;
            else if (option == "bitmap")
                type = BitmapType;
            else if (option == "pixmap")
                type = PixmapType;
            else if (option == "image")
                type = ImageType;
            else if (option == "imageformat") {
                Q_ASSERT_X(i + 1 < argc, "main", "-imageformat must be followed by a value");
                QString format = QString(argv[++i]).toLower();

                imageFormat = QImage::Format_Invalid;
                static const unsigned int formatCount =
                    sizeof(imageFormats) / sizeof(imageFormats[0]);
                for (int ff = 0; ff < formatCount; ++ff) {
                    if (QLatin1String(imageFormats[ff].name) == format) {
                        imageFormat = imageFormats[ff].format;
                        break;
                    }
                }

                if (imageFormat == QImage::Format_Invalid) {
                    printf("Invalid image format.  Available formats are:\n");
                    for (int ff = 0; ff < formatCount; ++ff) 
                        printf("\t%s\n", imageFormats[ff].name);
                    return -1;
                }
            } else if (option == "imagemono")
                type = ImageMonoType;
            else if (option == "imagewidget")
                type = ImageWidgetType;
#ifndef QT_NO_OPENGL
            else if (option == "opengl")
                type = OpenGLType;
            else if (option == "pbuffer")
                type = OpenGLPBufferType;
#endif
#ifdef USE_CUSTOM_DEVICE
            else if (option == "customdevice")
                type = CustomDeviceType;
            else if (option == "customwidget")
                type = CustomWidgetType;
#endif
            else if (option == "pdf")
                type = PdfType;
            else if (option == "ps")
                type = PsType;
            else if (option == "picture")
                type = PictureType;
            else if (option == "printer")
                type = PrinterType;
            else if (option == "highres") {
                type = PrinterType;
                highres = true;
            } else if (option == "printdialog") {
                type = PrinterType;
                printdlg = true;
            }
            else if (option == "grab")
                type = GrabType;
            else if (option == "i")
                interactive = true;
            else if (option == "v")
                verboseMode = true;
            else if (option == "commands") {
                displayCommands();
                return 0;
            } else if (option == "w") {
                Q_ASSERT_X(i + 1 < argc, "main", "-w must be followed by a value");
                width = atoi(argv[++i]);
            } else if (option == "h") {
                Q_ASSERT_X(i + 1 < argc, "main", "-h must be followed by a value");
                height = atoi(argv[++i]);
            } else if (option == "cmp") {
                show_cmp = true;
            } else if (option == "bg-white") {
                checkers_background = false;
            }
        } else {
#if defined (Q_WS_WIN)
            QString input = QString::fromLocal8Bit(argv[i]);
            if (input.indexOf('*') >= 0) {
                QFileInfo info(input);
                QDir dir = info.dir();
                QFileInfoList infos = dir.entryInfoList(QStringList(info.fileName()));
                for (int ii=0; ii<infos.size(); ++ii)
                    files.append(infos.at(ii).absoluteFilePath());
            } else {
                files.append(input);
            }
#else
            files.append(QString(argv[i]));
#endif
        }
    }

    PaintCommands pcmd(QStringList(), 800, 800);
    pcmd.setVerboseMode(verboseMode);
    pcmd.setType(type);
    pcmd.setCheckersBackground(checkers_background);

    QWidget *activeWidget = 0;

    if (interactive) {
        runInteractive();
        if (!files.isEmpty())
            interactive_widget->load(files.at(0));
    } else if (files.isEmpty()) {
        printHelp();
        return 0;
    } else {
        for (int j=0; j<files.size(); ++j) {
            const QString &fileName = files.at(j);
            QStringList content;

            QFile file(fileName);
            QFileInfo fileinfo(file);
            if (file.open(QIODevice::ReadOnly)) {
                QTextStream textFile(&file);
                QString script = textFile.readAll();
                content = script.split("\n", QString::SkipEmptyParts);
            } else {
                printf("failed to read file: '%s'\n", qPrintable(fileName));
                continue;
            }
            pcmd.setContents(content);

            if (show_cmp) {
                QString pmFile = QString(files.at(j)).replace(".qps", "_qps") + ".png";
                qDebug() << pmFile << QFileInfo(pmFile).exists();
                QPixmap pixmap(pmFile);
                if (!pixmap.isNull()) {
                    QLabel *label = createLabel();
                    label->setWindowTitle("VERIFY: " + pmFile);
                    label->setPixmap(pixmap);
                    label->show();
                }
            }

            switch (type) {

            case WidgetType:
            {
                OnScreenWidget<QWidget> *qWidget =
                    new OnScreenWidget<QWidget>;
                qWidget->setVerboseMode(verboseMode);
                qWidget->setType(type);
                qWidget->setCheckersBackground(checkers_background);
                qWidget->m_filename = files.at(j);
                qWidget->setWindowTitle(fileinfo.filePath());
                qWidget->m_commands = content;
                qWidget->resize(width, height);
                qWidget->show();
                activeWidget = qWidget;
                break;
            }

            case ImageWidgetType:
            {
                OnScreenWidget<QWidget> *qWidget = new OnScreenWidget<QWidget>;
                qWidget->setVerboseMode(verboseMode);
                qWidget->setType(type);
                qWidget->setCheckersBackground(checkers_background);
                qWidget->m_filename = files.at(j);
                qWidget->setWindowTitle(fileinfo.filePath());
                qWidget->m_commands = content;
                qWidget->resize(width, height);
                qWidget->show();
                activeWidget = qWidget;
                break;

            }
#ifndef QT_NO_OPENGL
            case OpenGLPBufferType:
            {
                QGLPixelBuffer pbuffer(QSize(width, height));
                QPainter pt(&pbuffer);
                pcmd.setPainter(&pt);
                pcmd.setFilePath(fileinfo.absolutePath());
                pcmd.runCommands();
                pt.end();

                QImage image = pbuffer.toImage();

                QLabel *label = createLabel();
                label->setPixmap(QPixmap::fromImage(image));
                label->resize(label->sizeHint());
                label->show();
                activeWidget = label;
                break;
            }
            case OpenGLType:
            {
                OnScreenWidget<QGLWidget> *qGLWidget = new OnScreenWidget<QGLWidget>;
                qGLWidget->setVerboseMode(verboseMode);
                qGLWidget->setType(type);
                qGLWidget->setCheckersBackground(checkers_background);
                qGLWidget->m_filename = files.at(j);
                qGLWidget->setWindowTitle(fileinfo.filePath());
                qGLWidget->m_commands = content;
                qGLWidget->resize(width, height);
                qGLWidget->show();
                activeWidget = qGLWidget;
                break;
            }
#else
            case OpenGLType:
                printf("OpenGL type not supported in this Qt build\n");
                break;
#endif
#ifdef USE_CUSTOM_DEVICE
            case CustomDeviceType:
            {
                CustomPaintDevice custom(width, height);
                QPainter pt;
                pt.begin(&custom);
                pcmd.setPainter(&pt);
                pcmd.setFilePath(fileinfo.absolutePath());
                pcmd.runCommands();
                pt.end();
                QImage *img = custom.image();
                if (img) {
                    QLabel *label = createLabel();
                    label->setPixmap(QPixmap::fromImage(*img));
                    label->resize(label->sizeHint());
                    label->show();
                    activeWidget = label;
                    img->save("custom_output_pixmap.png", "PNG");
                } else {
                    custom.save("custom_output_pixmap.png", "PNG");
                }
                break;
            }
            case CustomWidgetType:
            {
                OnScreenWidget<CustomWidget> *cWidget = new OnScreenWidget<CustomWidget>;
                cWidget->setVerboseMode(verboseMode);
                cWidget->setType(type);
                cWidget->setCheckersBackground(checkers_background);
                cWidget->m_filename = files.at(j);
                cWidget->setWindowTitle(fileinfo.filePath());
                cWidget->m_commands = content;
                cWidget->resize(width, height);
                cWidget->show();
                activeWidget = cWidget;
                break;
            }
#endif
            case PixmapType:
            {
                QPixmap pixmap(width, height);
                pixmap.fill(Qt::white);
                QPainter pt(&pixmap);
                pcmd.setPainter(&pt);
                pcmd.setFilePath(fileinfo.absolutePath());
                pcmd.runCommands();
                pt.end();
                pixmap.save("output_pixmap.png", "PNG");
                break;
            }

            case BitmapType:
            {
                QBitmap bitmap(width, height);
                QPainter pt(&bitmap);
                pcmd.setPainter(&pt);
                pcmd.setFilePath(fileinfo.absolutePath());
                pcmd.runCommands();
                pt.end();
                bitmap.save("output_bitmap.png", "PNG");

                QLabel *label = createLabel();
                label->setPixmap(bitmap);
                label->resize(label->sizeHint());
                label->show();
                activeWidget = label;
                break;
            }

            case ImageMonoType:
            case ImageType:
            {
                qDebug() << "Creating image";
                QImage image(width, height, type == ImageMonoType
                             ? QImage::Format_MonoLSB
                             : imageFormat);
                image.fill(0);
                QPainter pt(&image);
                pcmd.setPainter(&pt);
                pcmd.setFilePath(fileinfo.absolutePath());
                pcmd.runCommands();
                pt.end();
                image.convertToFormat(QImage::Format_ARGB32).save("output_image.png", "PNG");
#ifndef CONSOLE_APPLICATION
                QLabel *label = createLabel();
                label->setPixmap(QPixmap::fromImage(image));
                label->resize(label->sizeHint());
                label->show();
                activeWidget = label;
#endif
                break;
            }

            case PictureType:
            {
                QPicture pic;
                QPainter pt(&pic);
                pcmd.setPainter(&pt);
                pcmd.setFilePath(fileinfo.absolutePath());
                pcmd.runCommands();
                pt.end();

                QImage image(width, height, QImage::Format_ARGB32_Premultiplied);
                image.fill(0);
                pt.begin(&image);
                pt.drawPicture(0, 0, pic);
                pt.end();
                QLabel *label = createLabel();
                label->setWindowTitle(fileinfo.absolutePath());
                label->setPixmap(QPixmap::fromImage(image));
                label->resize(label->sizeHint());
                label->show();
                activeWidget = label;
                break;
            }

            case PrinterType:
            {
                PaintCommands pcmd(QStringList(), 800, 800);
                pcmd.setVerboseMode(verboseMode);
                pcmd.setType(type);
                pcmd.setCheckersBackground(checkers_background);
                pcmd.setContents(content);
                QString file = QString(files.at(j)).replace(".", "_") + ".ps";

                QPrinter p(highres ? QPrinter::HighResolution : QPrinter::ScreenResolution);
                if (printdlg) {
                    QPrintDialog printDialog(&p, 0);
                    if (printDialog.exec() != QDialog::Accepted)
                        break;
                } else {
                    p.setOutputFileName(file);
                }

                QPainter pt(&p);
                pcmd.setPainter(&pt);
                pcmd.setFilePath(fileinfo.absolutePath());
                pcmd.runCommands();
                pt.end();

                if (!printdlg) {
                    printf("wrote file: %s\n", qPrintable(file));
                }

                Q_ASSERT(!p.paintingActive());
                break;
            }
            case PsType:
            case PdfType:
            {
                PaintCommands pcmd(QStringList(), 800, 800);
                pcmd.setVerboseMode(verboseMode);
                pcmd.setType(type);
                pcmd.setCheckersBackground(checkers_background);
                pcmd.setContents(content);
                bool ps = type == PsType;
                QPrinter p(highres ? QPrinter::HighResolution : QPrinter::ScreenResolution);
                QFileInfo input(files.at(j));
                QString file = QString("%1_%2.%3")
                               .arg(input.baseName())
                               .arg(input.suffix())
                               .arg(ps ? "ps" : "pdf");
                p.setOutputFormat(ps ? QPrinter::PdfFormat : QPrinter::PostScriptFormat);
                p.setOutputFileName(file);
                p.setPageSize(QPrinter::A4);
                QPainter pt(&p);
                pcmd.setPainter(&pt);
                pcmd.setFilePath(fileinfo.absolutePath());
                pcmd.runCommands();
                pt.end();

                printf("write file: %s\n", qPrintable(file));
                break;
            }
            case GrabType:
            {
                QImage image(width, height, QImage::Format_ARGB32_Premultiplied);
                image.fill(QColor(Qt::white).rgb());
                QPainter pt(&image);
                pcmd.setPainter(&pt);
                pcmd.setFilePath(fileinfo.absolutePath());
                pcmd.runCommands();
                pt.end();
                QImage image1(width, height, QImage::Format_RGB32);
                image1.fill(QColor(Qt::white).rgb());
                QPainter pt1(&image1);
                pt1.drawImage(QPointF(0, 0), image);
                pt1.end();

                QString filename = QString(files.at(j)).replace(".qps", "_qps") + ".png";
                image1.save(filename, "PNG");
                printf("%s grabbed to %s\n", qPrintable(files.at(j)), qPrintable(filename));
                break;
            }

            default:
                break;
            }
        }
    }
#ifndef CONSOLE_APPLICATION
    if (activeWidget || interactive) {
        QObject::connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
        app.exec();
    }

    delete activeWidget;
#endif
    return 0;
}
示例#26
0
static int ctrl(struct svdir *s, char c)
{
	int sig;

	switch (c) {
	case 'd': /* down */
		s->sd_want = W_DOWN;
		update_status(s);
		if (s->pid && s->state != S_FINISH)
			stopservice(s);
		break;
	case 'u': /* up */
		s->sd_want = W_UP;
		update_status(s);
		if (s->pid == 0)
			startservice(s);
		break;
	case 'x': /* exit */
		if (s->islog)
			break;
		s->sd_want = W_EXIT;
		update_status(s);
		/* FALLTHROUGH */
	case 't': /* sig term */
		if (s->pid && s->state != S_FINISH)
			stopservice(s);
		break;
	case 'k': /* sig kill */
		if (s->pid && !custom(s, c))
			kill(s->pid, SIGKILL);
		s->state = S_DOWN;
		break;
	case 'p': /* sig pause */
		if (s->pid && !custom(s, c))
			kill(s->pid, SIGSTOP);
		s->ctrl |= C_PAUSE;
		update_status(s);
		break;
	case 'c': /* sig cont */
		if (s->pid && !custom(s, c))
			kill(s->pid, SIGCONT);
		s->ctrl &= ~C_PAUSE;
		update_status(s);
		break;
	case 'o': /* once */
		s->sd_want = W_DOWN;
		update_status(s);
		if (!s->pid)
			startservice(s);
		break;
	case 'a': /* sig alarm */
		sig = SIGALRM;
		goto sendsig;
	case 'h': /* sig hup */
		sig = SIGHUP;
		goto sendsig;
	case 'i': /* sig int */
		sig = SIGINT;
		goto sendsig;
	case 'q': /* sig quit */
		sig = SIGQUIT;
		goto sendsig;
	case '1': /* sig usr1 */
		sig = SIGUSR1;
		goto sendsig;
	case '2': /* sig usr2 */
		sig = SIGUSR2;
		goto sendsig;
	}
	return 1;
 sendsig:
	if (s->pid && !custom(s, c))
		kill(s->pid, sig);
	return 1;
}
示例#27
0
static void startservice(struct svdir *s)
{
	int p;
	const char *arg[4];
	char exitcode[sizeof(int)*3 + 2];

	if (s->state == S_FINISH) {
/* Two arguments are given to ./finish. The first one is ./run exit code,
 * or -1 if ./run didnt exit normally. The second one is
 * the least significant byte of the exit status as determined by waitpid;
 * for instance it is 0 if ./run exited normally, and the signal number
 * if ./run was terminated by a signal. If runsv cannot start ./run
 * for some reason, the exit code is 111 and the status is 0.
 */
		arg[0] = "./finish";
		arg[1] = "-1";
		if (WIFEXITED(s->wstat)) {
			*utoa_to_buf(WEXITSTATUS(s->wstat), exitcode, sizeof(exitcode)) = '\0';
			arg[1] = exitcode;
		}
		//arg[2] = "0";
		//if (WIFSIGNALED(s->wstat)) {
			arg[2] = utoa(WTERMSIG(s->wstat));
		//}
		arg[3] = NULL;
	} else {
		arg[0] = "./run";
		arg[1] = NULL;
		custom(s, 'u');
	}

	if (s->pid != 0)
		stopservice(s); /* should never happen */
	while ((p = vfork()) == -1) {
		warn_cannot("vfork, sleeping");
		sleep(5);
	}
	if (p == 0) {
		/* child */
		if (haslog) {
			/* NB: bug alert! right order is close, then dup2 */
			if (s->islog) {
				xchdir("./log");
				close(logpipe.wr);
				xdup2(logpipe.rd, 0);
			} else {
				close(logpipe.rd);
				xdup2(logpipe.wr, 1);
			}
		}
		/* Non-ignored signals revert to SIG_DFL on exec anyway */
		/*bb_signals(0
			+ (1 << SIGCHLD)
			+ (1 << SIGTERM)
			, SIG_DFL);*/
		sig_unblock(SIGCHLD);
		sig_unblock(SIGTERM);
		execv(arg[0], (char**) arg);
		fatal2_cannot(s->islog ? "start log/" : "start ", arg[0]);
	}
	/* parent */
	if (s->state != S_FINISH) {
		gettimeofday_ns(&s->start);
		s->state = S_RUN;
	}
	s->pid = p;
	pidchanged = 1;
	s->ctrl = C_NOOP;
	update_status(s);
}
示例#28
0
string Color::ipAddrText(int in)
{
    return custom(in, FG_PURPLE, 0);
}
示例#29
0
string Color::intText(int in)
{
    return custom(in, FG_RED, 0);
}
示例#30
0
string Color::errorText(int in)
{
    return custom(in, BG_RED, 0);
}