QGroupBox* aSectionGroup = new QGroupBox(tr("Sections"),this);
mySectionView = new CurveCreator_TreeView(myCurve, aSectionGroup);
+ mySectionView->setSelectionMode( QTreeView::ExtendedSelection );
connect( mySectionView, SIGNAL(selectionChanged()), this, SLOT( onSelectionChanged() ) );
connect( mySectionView, SIGNAL(sectionEntered(int)), this, SLOT(onEditSection(int)) );
connect( mySectionView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onContextMenu(QPoint)) );
connect(anAct, SIGNAL(triggered()), this, SLOT(onRemove()) );
aTB->addAction(anAct);
- // TODO join
- //aTB->addSeparator();
+ aTB->addSeparator();
- //anAct = createAction( JOIN_ID, tr("JOIN"), aJoinPixmap, tr("JOIN_TLT"),
- // QKeySequence(Qt::ControlModifier|Qt::Key_Plus ) );
- //connect( anAct, SIGNAL(triggered()), this, SLOT(onJoin()) );
- //aTB->addAction(anAct);
+ anAct = createAction( JOIN_ID, tr("JOIN"), aJoinPixmap, tr("JOIN_TLT"),
+ QKeySequence(Qt::ControlModifier|Qt::Key_Plus ) );
+ connect( anAct, SIGNAL(triggered()), this, SLOT(onJoin()) );
+ aTB->addAction(anAct);
anAct = createAction( CLEAR_ALL_ID, tr("CLEAR_ALL"), QPixmap(), tr("CLEAR_ALL_TLT"),
QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Delete ) );
connect( anAct, SIGNAL(triggered()), this, SLOT( onClearAll()) );
- // TODO join
- //anAct = createAction( JOIN_ALL_ID, tr("JOIN_ALL"), QPixmap(), tr("JOIN_ALL_TLT"),
- // QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Plus ) );
- //connect( anAct, SIGNAL(triggered()), this, SLOT(onJoinAll()) );
+ anAct = createAction( JOIN_ALL_ID, tr("JOIN_ALL"), QPixmap(), tr("JOIN_ALL_TLT"),
+ QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Plus ) );
+ connect( anAct, SIGNAL(triggered()), this, SLOT(onJoinAll()) );
QVBoxLayout* aSectLayout = new QVBoxLayout();
aSectLayout->setMargin( 5 );
int aSectCnt = myCurve->getNbSections();
if( aSectCnt > 0 )
anEnabledAct << CLEAR_ALL_ID;
- // TODO
- //if( aSectCnt > 1 )
- // anEnabledAct << JOIN_ALL_ID;
- //if( aSelSections.size() > 1 ){
- // anEnabledAct << JOIN_ID;
- //}
+ if( aSectCnt > 1 )
+ anEnabledAct << JOIN_ALL_ID;
+ if( aSelSections.size() > 1 ){
+ anEnabledAct << JOIN_ID;
+ }
}
break;
case DetectionMode: {
}
break;
case NoneMode:
+ {
+ int aSectCnt = myCurve->getNbSections();
+ if( aSectCnt > 1 )
+ anEnabledAct << JOIN_ALL_ID;
+ if( aSelSections.size() > 1 )
+ anEnabledAct << JOIN_ID;
+ }
+ break;
default:
break;
}
if( (myCurve->getNbSections() + myCurve->getNbPoints()) > 0 ){
anEnabledAct << REMOVE_ALL_ID;
}*/
- // TODO
- //if( myCurve->getNbSections() > 1 ){
- // anEnabledAct << JOIN_ALL_ID;
- //}
+ if( myCurve->getNbSections() > 1 ){
+ anEnabledAct << JOIN_ALL_ID;
+ }
}
QList<ActionId> anIds = myActionMap.keys();
for( int i = 0 ; i < anIds.size() ; i++ ){
myNewSectionEditor->setEditMode(false);
QString aSectName = QString( CurveCreator_UtilsICurve::getUniqSectionName( myCurve ).c_str() );
myNewSectionEditor->setSectionParameters(aSectName, true, CurveCreator::Polyline );
- emit subOperationStarted( myNewSectionEditor );
+ emit subOperationStarted( myNewSectionEditor, false );
}
void CurveCreator_Widget::onAddNewSection()
myNewSectionEditor->setEditMode(true);
myNewSectionEditor->setSectionParameters( aSectName, isClosed, aType );
- emit subOperationStarted( myNewSectionEditor );
+ emit subOperationStarted( myNewSectionEditor, true );
}
void CurveCreator_Widget::onModifySection()
if( !myCurve )
return;
stopActionMode();
- myCurve->join();
+ myCurve->join( 0, myCurve->getNbSections() );
mySectionView->reset();
updateActionsStates();
updateUndoRedo();
void CurveCreator_Widget::onContextMenu( QPoint thePoint )
{
QList<ActionId> aContextActions;
- aContextActions << CLEAR_ALL_ID << JOIN_ALL_ID << SEPARATOR_ID <<
+ aContextActions << CLEAR_ALL_ID << JOIN_ID << JOIN_ALL_ID << SEPARATOR_ID <<
CLOSE_SECTIONS_ID << UNCLOSE_SECTIONS_ID << SET_SECTIONS_POLYLINE_ID <<
SET_SECTIONS_SPLINE_ID;
QPoint aGlPoint = mySectionView->mapToGlobal(thePoint);
if ( myDragStarted ) {
bool isDragged = myDragged;
CurveCreator_ICurve::SectionToPointList aDraggedPoints;
- if ( myDragged )
+ QMap<CurveCreator_ICurve::SectionToPoint, std::deque< float >> anInitialDragPointsCoords;
+ if ( myDragged ) {
aDraggedPoints = myDragPoints;
+ anInitialDragPointsCoords = myInitialDragPointsCoords;
+ }
setDragStarted( false );
if ( aDraggedPoints.size() > 0 ) {
+ // Collect old coordinates of the dragged points
+ CurveCreator_ICurve::SectionToPointCoordsList anOldPoints;
+ foreach ( const CurveCreator_ICurve::SectionToPoint aSectionToPoint, anInitialDragPointsCoords.keys() ) {
+ CurveCreator::Coordinates aCoords = anInitialDragPointsCoords.value( aSectionToPoint );
+ anOldPoints.push_back( std::make_pair( aSectionToPoint, aCoords ) );
+ }
+
if ( myCurve->canPointsBeSorted() ) {
+ // Add old coordinates of the curve points (except the dragged points) to the list
+ for( int aSectionId = 0 ; aSectionId < myCurve->getNbSections() ; aSectionId++ ) {
+ CurveCreator::Coordinates aCoords;
+ for ( int aPointId = 0, aNb = myCurve->getNbPoints( aSectionId ); aPointId < aNb; aPointId++ ) {
+ aCoords = myCurve->getPoint( aSectionId, aPointId );
+ if ( aCoords.size() < 2 ) {
+ continue;
+ }
+
+ CurveCreator_ICurve::SectionToPoint aSectionToPoint = std::make_pair( aSectionId, aPointId );
+
+ if ( !anInitialDragPointsCoords.contains( aSectionToPoint ) ) {
+ anOldPoints.push_back( std::make_pair( aSectionToPoint, aCoords ) );
+ }
+ }
+ }
+
// Apply points sorting
CurveCreator_ICurve::SectionToPointList aPoints;
startCurveModification( aPoints, false );
int aSectionId = anIt->first;
int aPointId = anIt->second;
std::deque<float> aPos = myCurve->getPoint( aSectionId, aPointId );
-
+
aCoordList.push_back(
std::make_pair( std::make_pair( aSectionId, aPointId ), aPos ) );
}
- myCurve->setSeveralPoints( aCoordList );
+ myCurve->setSeveralPoints( aCoordList, false );
finishCurveModification( aDraggedPoints );
} else {
// if the drag of some points has happened, restore the drag selection
- if ( aDraggedPoints.size() > 0 ) {
- START_MEASURE_TIME;
- setSelectedPoints( aDraggedPoints );
- END_MEASURE_TIME( "drop" );
- }
+ START_MEASURE_TIME;
+ setSelectedPoints( aDraggedPoints );
+ END_MEASURE_TIME( "drop" );
}
+
+ // Save drag difference
+ myCurve->saveCoordDiff( anOldPoints );
}
}
else // check whether the segment is clicked an a new point should be added to the segment
aChangedPos = myCurve->getPoint( aSectionId, aPointId );
if ( aChangedPos.size() < 2 )
continue;
+
+ // Remember drag points coordinates
+ if ( !myDragged ) {
+ myInitialDragPointsCoords.insert( std::make_pair( aSectionId, aPointId ), aChangedPos );
+ }
+
aChangedPos[0] = aChangedPos[0] - aXDelta;
aChangedPos[1] = aChangedPos[1] - anYDelta;
std::make_pair(std::make_pair( aSectionId, aPointId ),
aChangedPos ));
}
- myCurve->setSeveralPoints( aCoordList );
+ myCurve->setSeveralPoints( aCoordList, false );
myDragged = true;
finishCurveModification( myDragPoints );
changeInteractionStyle( myDragInteractionStyle );
myDragStarted = false;
myDragPoints.clear();
+ myInitialDragPointsCoords.clear();
}
myDragged = false;
}