Exemple #1
0
bool InteractScene::penUp( const OFX::PenArgs& args )
{
	//TUTTLE_LOG_TRACE("penUp");
	bool result = false;

	if( _creatingSelection )
	{
		_selectionRect.x2 = args.penPosition.x;
		_selectionRect.y2 = args.penPosition.y;

		_selected.clear();
		//TUTTLE_LOG_VAR4( TUTTLE_TRACE, _selectionRect.x1, _selectionRect.y1, _selectionRect.x2, _selectionRect.y2 );
		IsActiveFunctorVector::iterator itActive = _isActive.begin();
		for( InteractObjectsVector::iterator it = _objects.begin(), itEnd = _objects.end();
			 it != itEnd;
			 ++it, ++itActive )
		{
			if( ! itActive->active() )
				continue;
			if( it->isIn( _selectionRect ) )
			{
				it->setSelected(true);
				_selected.push_back( SelectedObject( &(*it), it->getPosition() ) );
				_hasSelection = true;
				result = true;
			}
			else
			{
				it->setSelected(false);
			}
		}
		//TUTTLE_LOG_VAR( TUTTLE_TRACE, _selected.size() );
		_creatingSelection = false;
	}

	_mouseDown = false;
	_creatingSelection = false;
	
	_params.endEditBlock();

	return result;
}
Exemple #2
0
bool InteractScene::penMotion(const OFX::PenArgs& args)
{
    if(!_mouseDown)
        return false;

    if(_creatingSelection)
    {
        // create selection

        TUTTLE_LOG_TRACE("create a selection");
        _selectionRect.x2 = args.penPosition.x;
        _selectionRect.y2 = args.penPosition.y;
        _hasSelection = false;

        IsActiveFunctorVector::iterator itActive = _isActive.begin();
        for(InteractObjectsVector::iterator it = _objects.begin(), itEnd = _objects.end(); it != itEnd; ++it, ++itActive)
        {
            if(!itActive->active())
                continue;
            if(it->isIn(_selectionRect))
            {
                it->setSelected(true);
                _hasSelection = true;
            }
            else
            {
                it->setSelected(false);
            }
        }
        return true;
    }

    if(_selected.size() == 0)
    {
        TUTTLE_LOG_INFOS;
        return false;
    }

    const Point2 penPosition = ofxToGil(args.penPosition);
    switch(_motionType._mode)
    {
        case eMotionTranslate:
        {
            translate(penPosition - _beginPenPosition);
            break;
        }
        case eMotionRotate:
        {
            if(_manipulator)
            {
                rotate(_manipulator->getPosition(), penPosition, penPosition - _beginPenPosition);
            }
            break;
        }
        case eMotionScale:
        {
            if(_manipulator)
                scale(_manipulator->getPosition(), penPosition - _beginPenPosition);
            break;
        }
        case eMotionNone:
        {
            TUTTLE_LOG_INFOS;
            break;
        }
    }
    return true;
}