Example #1
0
MovementGraph::MovementGraph( ImageContainer& images ) : QWidget(nullptr), images(images) {
	//Create and add chart to widget
	auto plot = new QChart();
	auto view = new QChartView( plot );
	view->setRenderHint( QPainter::Antialiasing );
	setLayout( new QHBoxLayout( this ) );
	layout()->addWidget( view );
	layout()->setContentsMargins( 0, 0, 0, 0 );
	
	//Start adding lines
	auto moves = imagesMoves( images );
	for( auto frame : images.getFrames() ){
		auto line = new QLineSeries(); //TODO: is needed to be on the heap?
		
		FrameContainer container( images, frame );
		for( unsigned i=0; i<container.count(); ++i )
			addPoint( *line, container, i, moves );
		
		line->setColor( getColor( frame ) );
		plot->addSeries( line );
	}
	
	//Custimize chart visuals
	plot->setTitle( "Position of images" );
	plot->legend()->hide();
	plot->createDefaultAxes();
	//plot->setInteractions( QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables );
	//TOOD: replace this functionality?
	
	resize( 640, 480 );
	show();
}
Example #2
0
MovementGraph::MovementGraph( ImageContainer& images ) : QWidget(nullptr), images(images) {
	auto plot = new QCustomPlot( this );
	setLayout( new QHBoxLayout( this ) );
	layout()->addWidget( plot );
	layout()->setContentsMargins( 0, 0, 0, 0 );
	
	auto moves = imagesMoves( images );
	
	for( auto frame : images.getFrames() ){
		Line line;
		FrameContainer container( images, frame );
		for( unsigned i=0; i<container.count(); ++i )
			addPoint( line, container, i, moves );
		line.addToPlot( *plot, getColor( frame ) );
	}
	
	setLimit( *plot, images, moves );
	plot->setInteractions( QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables );
	
	resize( 640, 480 );
	show();
}