SplinePoint& SplineEditorWidget::getSelectedPoint() { if( isPointSelected() ) { return *_selectedPoint; } else { throw new std::exception(); } }
/* ================ idPointListInterface::selectPoint ================ */ int idPointListInterface::selectPoint(int index, bool single) { if (index >= 0 && index < numPoints()) { if (single) { deselectAll(); } else { if (isPointSelected(index) >= 0) { selectedPoints.Remove(index); } } return selectedPoints.Append(index); } return -1; }
void SplineEditorWidget::mousePressEvent(QMouseEvent *event) { QGraphicsView::mousePressEvent(event); QList<QGraphicsItem *> items = _scene->selectedItems(); if(items.size() > 0) { SplinePointWidget *splinePoint = dynamic_cast<SplinePointWidget*>( items.at(0) ); emit pressedPoint( _spline->pointAt( splinePoint->pointIndex ) ); } if(_is_shift_pressed) { std::cout << mapToScene(event->pos()).x() << "|" << mapToScene(event->pos()).y() << std::endl; if(event->buttons() == Qt::LeftButton) { if( isSplineExist() ) { Spline &spline = getSpline(); spline.push_back( QVector2D( mapToScene(event->pos()).x(), mapToScene(event->pos()).y() ) ); setSpline( spline ); } } if(event->buttons() == Qt::RightButton) { if( isSplineExist() ) { if( isPointSelected() ) { Spline &spline = getSpline(); SplinePoint& selectedPoint = getSelectedPoint(); spline.remove( selectedPoint ); setSpline( spline ); } } } } }
void ofxTLCameraTrack::mousePressed(ofMouseEventArgs& args) { if(bounds.inside(args.x, args.y)) { int selectedTrack = trackIndexForScreenX(args.x); if(selectedTrack == -1) { timeline->unselectAll(); return; } bool alreadySelected = isPointSelected(selectedTrack); if(!alreadySelected) { if(!ofGetModifierKeyShift()) { timeline->unselectAll(); } selectedTrackPoints.push_back( selectedTrack ); } mostRecentlySelected = selectedTrack; easeInSelected = args.x < screenXForIndex(track.getSamples()[selectedTrack].frame); canDrag = !ofGetModifierKeyShift(); updateDragOffsets(args.x); } }