-// Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2013-2015 CEA/DEN, EDF R&D, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include <QApplication>
#include <QTableWidget>
#include <QTime>
+#include <QSplitter>
//#define MEASURE_TIME
aSectLayout->setMargin( 5 );
aSectLayout->setSpacing( 5 );
aSectLayout->addWidget(aTB);
- aSectLayout->addWidget(mySectionView);
- aSectLayout->addWidget( myLocalPointView );
+
+ QSplitter* aSplitter = new QSplitter(aSectionGroup);
+ aSplitter->setOrientation(Qt::Vertical);
+
+ aSplitter->addWidget(mySectionView);
+ aSplitter->addWidget( myLocalPointView );
+
+ aSectLayout->addWidget(aSplitter);
aSectionGroup->setLayout(aSectLayout);
QVBoxLayout* aLay = new QVBoxLayout();
aLay->setMargin( 0 );
//=======================================================================
void CurveCreator_Widget::reset()
{
+ stopActionMode();
}
void CurveCreator_Widget::setCurve( CurveCreator_ICurve* theCurve )
mySectionView->sectionChanged(mySection);
updateUndoRedo();
onCancelSection();
-
- emit curveModified();
}
void CurveCreator_Widget::onJoin()
if( aNewSectSize != aMainSectSize )
mySectionView->pointsAdded( aMainSect, aMainSectSize, aNewSectSize-aMainSectSize );*/
updateUndoRedo();
-
- emit curveModified();
}
void CurveCreator_Widget::onRemove()
mySectionView->reset();
updateActionsStates();
updateUndoRedo();
-
- emit curveModified();
}
void CurveCreator_Widget::onJoinAll()
mySectionView->reset();
updateActionsStates();
updateUndoRedo();
-
- emit curveModified();
}
void CurveCreator_Widget::onUndoSettings()
mySectionView->sectionChanged(aSelSections[i]);
}
updateUndoRedo();
-
- emit curveModified();
}
void CurveCreator_Widget::onSetPolyline()
mySectionView->sectionChanged( aSelSections[i] );
}
updateUndoRedo();
-
- emit curveModified();
}
void CurveCreator_Widget::onCloseSections()
mySectionView->sectionChanged(aSelSections[i]);
}
updateUndoRedo();
-
- emit curveModified();
}
void CurveCreator_Widget::onUncloseSections()
mySectionView->sectionChanged(aSelSections[i]);
}
updateUndoRedo();
-
- emit curveModified();
}
void CurveCreator_Widget::onUndo()
myCurve->undo();
finishCurveModification();
mySectionView->reset();
-
- emit curveModified();
}
void CurveCreator_Widget::onRedo()
myCurve->redo();
finishCurveModification();
mySectionView->reset();
-
- emit curveModified();
}
void CurveCreator_Widget::updateUndoRedo()
return;
gp_Pnt aPnt;
+ OCCViewer_ViewPort3d* vp = getViewPort();
- ic->InitSelected();
- if ( pe->modifiers() == Qt::ShiftModifier )
- ic->ShiftSelect(); // Append selection
- else
- ic->Select(); // New selection
+ aPnt = CurveCreator_Utils::ConvertClickToPoint( pe->x(), pe->y(), vp->getView() );
- {
- OCCViewer_ViewPort3d* vp = getViewPort();
- aPnt = CurveCreator_Utils::ConvertClickToPoint( pe->x(), pe->y(), vp->getView() );
- }
// set the coordinates into dialog
CurveCreator::Coordinates aCoords;
aCoords.push_back( aPnt.X() );
if ( theEvent->button() != Qt::LeftButton )
return;
- myPressedX = theEvent->x();
- myPressedY = theEvent->y();
+ // Initialize the starting point
+ myStartPoint.setX( theEvent->x() );
+ myStartPoint.setY( theEvent->y() );
switch( getActionMode() ) {
case ModificationMode: {
* \param theWindow an owner of the signal
* \param theEvent a mouse event
*/
-void CurveCreator_Widget::onMouseRelease( SUIT_ViewWindow*, QMouseEvent* theEvent )
+void CurveCreator_Widget::onMouseRelease( SUIT_ViewWindow* theWindow, QMouseEvent* theEvent )
{
- if ( getActionMode() != ModificationMode )
+ ActionMode aMode = getActionMode();
+ if ( aMode != ModificationMode )
+ {
+ // Emit selectionChanged() signal
+ getOCCViewer()->performSelectionChanged();
+
+ if ( aMode == AdditionMode )
+ {
+ Handle(AIS_InteractiveContext) aCtx = getAISContext();
+ if ( !aCtx.IsNull() )
+ aCtx->ClearSelected();
+ }
return;
+ }
+ if (theEvent->button() != Qt::LeftButton) return;
+ if (!theWindow->inherits("OCCViewer_ViewWindow")) return;
+
+ // Initialize the ending point
+ myEndPoint.setX( theEvent->x() );
+ myEndPoint.setY( theEvent->y() );
+
+ bool aHasShift = ( theEvent->modifiers() & Qt::ShiftModifier );
+
+ // Highlight detected objects
+ Handle(AIS_InteractiveContext) aCtx = getAISContext();
+ if ( !aCtx.IsNull() )
+ {
+ OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*) theWindow;
+ if (!aView)
+ return;
+
+ if (!aHasShift)
+ aCtx->ClearCurrents( false );
+
+ Handle(V3d_View) aView3d = aView->getViewPort()->getView();
+ if ( !aView3d.IsNull() )
+ {
+ // Initialize the single selection if start and end points are equal,
+ // otherwise a rectangular selection.
+ if ( myStartPoint == myEndPoint )
+ {
+ aCtx->MoveTo( myEndPoint.x(), myEndPoint.y(), aView3d );
+ if ( aHasShift )
+ aCtx->ShiftSelect();
+ else
+ aCtx->Select();
+ }
+ else
+ {
+ if ( aHasShift )
+ aCtx->ShiftSelect( myStartPoint.x(), myStartPoint.y(), myEndPoint.x(), myEndPoint.y(),
+ aView3d, Standard_False );
+ else
+ aCtx->Select( myStartPoint.x(), myStartPoint.y(), myEndPoint.x(), myEndPoint.y(),
+ aView3d, Standard_False );
+ }
+ }
+ }
if ( myDragStarted ) {
bool isDragged = myDragged;
CurveCreator_ICurve::SectionToPointList aDraggedPoints;
- QMap<CurveCreator_ICurve::SectionToPoint, std::deque< float > > anInitialDragPointsCoords;
+ QMap<CurveCreator_ICurve::SectionToPoint, CurveCreator::Coordinates > anInitialDragPointsCoords;
if ( myDragged ) {
aDraggedPoints = myDragPoints;
anInitialDragPointsCoords = myInitialDragPointsCoords;
for ( ; anIt != aLast; anIt++ ) {
int aSectionId = anIt->first;
int aPointId = anIt->second;
- std::deque<float> aPos = myCurve->getPoint( aSectionId, aPointId );
+ CurveCreator::Coordinates aPos = myCurve->getPoint( aSectionId, aPointId );
aCoordList.push_back(
std::make_pair( std::make_pair( aSectionId, aPointId ), aPos ) );
}
else // check whether the segment is clicked an a new point should be added to the segment
{
- int aReleasedX = theEvent->x();
- int aReleasedY = theEvent->y();
- if ( myPressedX == aReleasedX && myPressedY == aReleasedY )
- insertPointToSelectedSegment( aReleasedX, aReleasedY );
+ if ( myStartPoint.x() == myEndPoint.x() && myStartPoint.y() == myEndPoint.y() )
+ insertPointToSelectedSegment( myEndPoint.x(), myStartPoint.y() );
}
// updates the input panel table to show the selected point coordinates
updateLocalPointView();
updateUndoRedo();
-
- emit curveModified();
}
/**
double aX = myLocalPointView->item( theRow, 2 )->data( Qt::UserRole ).toDouble();
double anY = myLocalPointView->item( theRow, 3 )->data( Qt::UserRole ).toDouble();
- std::deque<float> aChangedPos;
+ CurveCreator::Coordinates aChangedPos;
aChangedPos.push_back( aX );
aChangedPos.push_back( anY );
myCurve->setPoint( aCurrSect, aPntIndex, aChangedPos );
finishCurveModification( aSelPoints );
-
- emit curveModified();
}
/**
}
mySectionView->clearSelection();
updateUndoRedo();
-
- emit curveModified();
}
/**
myCurve->removeSeveralPoints( aPoints );
finishCurveModification( CurveCreator_ICurve::SectionToPointList() );
mySectionView->reset();
-
- emit curveModified();
}
void CurveCreator_Widget::addNewPoint(const CurveCreator::Coordinates& theCoords)
mySectionView->pointsAdded( aSection, myCurve->getNbPoints( aSection ) );
updateActionsStates();
updateUndoRedo();
-
- emit curveModified();
}
void CurveCreator_Widget::insertPointToSelectedSegment( const int theX,
finishCurveModification( aSelPoints );
setSelectedPoints();
-
- emit curveModified();
}
void CurveCreator_Widget::moveSelectedPoints( const int theXPosition,
double anYDelta = aStartPnt.Y() - anEndPnt.Y();
CurveCreator_ICurve::SectionToPointCoordsList aCoordList;
- std::deque<float> aChangedPos;
+ CurveCreator::Coordinates aChangedPos;
CurveCreator_ICurve::SectionToPointList::const_iterator anIt = myDragPoints.begin(),
aLast = myDragPoints.end();
for ( ; anIt != aLast; anIt++ ) {
myDragged = true;
finishCurveModification( myDragPoints );
-
- emit curveModified();
}
void CurveCreator_Widget::updateLocalPointView()
* \param theX the X coordinate of the point
* \param theY the Y coordinate of the point
*/
-int CurveCreator_Widget::findLocalPointIndex( int theSectionId, float theX, float theY )
+int CurveCreator_Widget::findLocalPointIndex( int theSectionId, double theX, double theY )
{
return CurveCreator_UtilsICurve::findLocalPointIndex( myCurve, theSectionId, theX, theY );
}