Exemplo n.º 1
0
std::vector<std::vector<Point2> > createGrid( const OfxRectD& rod, const unsigned int nbTiles, const Point2& scale, const Point2& center, const unsigned int steps = 50 )
{
	//	Point2 rodCorner( rod.x1, rod.y1 );
	Point2 rodSize( rod.x2 - rod.x1, rod.y2 - rod.y1 );
	const unsigned int size = nbTiles + 1; // number of lines
	const double stepSize   = rodSize.x / (double) steps;
	const double tileSize   = rodSize.x / (double) nbTiles;
	const double halfSize   = rodSize.x / 2.0;
	const double yShift     = ( rodSize.x - rodSize.y ) / 2.0; // vertical shift (because it's a squared grid)
	const Point2 pixCenter  = ( center * rodSize.x ); // center in pixel coordinates

	std::vector<std::vector<Point2> > lines;
	lines.reserve( 2 * size );
	for( unsigned int i = 0; i < size; ++i )
	{
		std::vector<Point2> horizontal, vertical;
		horizontal.reserve( steps );
		vertical.reserve( steps );
		for( unsigned int j = 0; j <= steps; ++j )
		{
			double si = ( i * tileSize ) - halfSize;
			Point2 diagonal( si * scale.x + halfSize + pixCenter.x, si * scale.y + halfSize + pixCenter.y - yShift );
			double sj = ( j * stepSize ) - halfSize;
			horizontal.push_back( Point2( sj * scale.x + halfSize + pixCenter.x, diagonal.y ) );
			vertical.push_back( Point2( diagonal.x, sj * scale.y + halfSize + pixCenter.y - yShift ) );
		}
		lines.push_back( horizontal );
		lines.push_back( vertical );
	}
	return lines;
}
Exemplo n.º 2
0
    Point2 getPoint() const
    {
        OfxRectD rod = this->_frame.getFrame(this->getTime());
        Point2 rodSize(rod.x2 - rod.x1, rod.y2 - rod.y1);
        Point2 relativePoint = _relativePoint.getPoint();
        Point2 paramPoint = ofxToGil(this->_param.getValue());
        Point2 point = pointConvertCoordinateSystem<notCenteredCoord, eCoordinateSystemXY>(paramPoint, rodSize);
        Point2 res = relativePoint + point;

        return res;
    }
Exemplo n.º 3
0
 void setPoint(const Scalar x, const Scalar y)
 {
     if(_relativePoint.getSelected())
         return;
     if(this->_frame.isEnabled())
     {
         OfxRectD rod = this->_frame.getFrame(this->getTime());
         Point2 rodSize(rod.x2 - rod.x1, rod.y2 - rod.y1);
         Point2 point = pointConvertCoordinateSystem<eCoordinateSystemXY, notCenteredCoord>(Point2(x, y), rodSize);
         Point2 relativePoint =
             pointConvertCoordinateSystem<eCoordinateSystemXY, notCenteredCoord>(_relativePoint.getPoint(), rodSize);
         this->_param.setValue(point.x - relativePoint.x, point.y - relativePoint.y);
         return;
     }
     this->_param.setValue(0, 0);
 }