#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <AIS_Shape.hxx>
#include <AIS_Point.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-//#include <StdSelect_BRepOwner.hxx>
+#include <StdSelect_BRepOwner.hxx>
#include <QHBoxLayout>
#include <QVBoxLayout>
void CurveCreator_Widget::onLocalPointChanged( int theRow, int theColumn )
{
- setLocalPointContext( false );
-
QList<int> aSelSections = mySectionView->getSelectedSections();
+ if ( aSelSections.size() < 0 )
+ return;
+
+ int aSection = aSelSections[0];
+
+ QList<int> aSelPoints;
+ getSelectedPonts( aSection, aSelPoints );
+ setLocalPointContext( false );
int aPntIndex = -1;
int aCurrSect=-1;
std::deque<float> aChangedPos;
float aPrevX, aPrevY, aX, anY;
- for( int i = 0 ; i < aSelSections.size() ; i++ ){
- aCurrSect = aSelSections[i];
+ //for( int i = 0 ; i < aSelSections.size() ; i++ ){
+ aCurrSect = aSection;//aSelSections[i];
aPrevX = myLocalPointView->item( theRow, 1 )->data( Qt::UserRole ).toDouble();
aPrevY = myLocalPointView->item( theRow, 2 )->data( Qt::UserRole ).toDouble();
aPntIndex = findLocalPointIndex( aCurrSect, aPrevX, aPrevY );
- if ( aPntIndex < 0 )
- continue;
-
- aX = myLocalPointView->item( theRow, 1 )->text().toDouble();
- anY = myLocalPointView->item( theRow, 2 )->text().toDouble();
- aChangedPos.clear();
- aChangedPos.push_back( aX );
- aChangedPos.push_back( anY );
- myCurve->setPoint( aCurrSect, aPntIndex, aChangedPos );
- }
- updateLocalPointView();
-
+ if ( aPntIndex >= 0 ) {
+ aX = myLocalPointView->item( theRow, 1 )->text().toDouble();
+ anY = myLocalPointView->item( theRow, 2 )->text().toDouble();
+ aChangedPos.clear();
+ aChangedPos.push_back( aX );
+ aChangedPos.push_back( anY );
+ myCurve->setPoint( aCurrSect, aPntIndex, aChangedPos );
+ }
+ //}
setLocalPointContext( true );
+ setSelectedPonts( aSection, aSelPoints );
}
int CurveCreator_Widget::findLocalPointIndex( int theSectionId, float theX, float theY )
QTableWidgetItem* anItem;
myLocalPointView->setRowCount( aRowId+1 );
- myLocalPointView->setItem( aRowId, 0, new QTableWidgetItem( QString::number( aRowId + 1 ) ) );
+ anItem = new QTableWidgetItem( QString::number( aRowId + 1 ) );
+ anItem->setFlags( anItem->flags() & ~Qt::ItemIsEnabled );
+ myLocalPointView->setItem( aRowId, 0, anItem );
anItem = new QTableWidgetItem( QString::number( theX ) );
anItem->setData( Qt::UserRole, theX );
anItem = new QTableWidgetItem( QString::number( theY ) );
anItem->setData( Qt::UserRole, theY );
myLocalPointView->setItem( aRowId, 2, anItem );
-}
\ No newline at end of file
+}
+
+void CurveCreator_Widget::getSelectedPonts( int theSectionId, QList<int>& thePoints )
+{
+ float aPrevX, aPrevY;
+ int aPntIndex;
+ for ( int i = 0, aNb = myLocalPointView->rowCount(); i < aNb; i++ ) {
+ aPrevX = myLocalPointView->item( i, 1 )->data( Qt::UserRole ).toDouble();
+ aPrevY = myLocalPointView->item( i, 2 )->data( Qt::UserRole ).toDouble();
+
+ aPntIndex = findLocalPointIndex( theSectionId, aPrevX, aPrevY );
+ if ( aPntIndex >= 0 )
+ thePoints.append( aPntIndex );
+ }
+}
+
+void CurveCreator_Widget::setSelectedPonts( const int theSectionId, const QList<int>& thePoints )
+{
+ OCCViewer_Viewer* anOCCViewer = getOCCViewer();
+ if ( !anOCCViewer )
+ return;
+
+ AIS_ListOfInteractive aListToSelect;
+
+ Handle(AIS_InteractiveContext) ic = anOCCViewer->getAISContext();
+ if ( !ic->HasOpenedContext() )
+ return;
+
+ AIS_ListOfInteractive aDisplayedList;
+ ic->DisplayedObjects( aDisplayedList );
+ for ( AIS_ListIteratorOfListOfInteractive it( aDisplayedList ); it.More(); it.Next() )
+ {
+ Handle(AIS_InteractiveObject) anAIS = it.Value();
+ if ( anAIS.IsNull() )
+ continue;
+ Handle(AIS_Point) aPoint = Handle(AIS_Point)::DownCast( anAIS );
+ if ( aPoint.IsNull() )
+ continue;
+
+ TopoDS_Vertex aVertex = TopoDS::Vertex( aPoint->Vertex() );
+
+ if ( aVertex.IsNull() )
+ continue;
+
+ gp_Pnt aPnt = BRep_Tool::Pnt( aVertex );
+ int aPointIndex = findLocalPointIndex( theSectionId, aPnt.X(), aPnt.Y() );
+ if ( thePoints.contains( aPointIndex ) )
+ aListToSelect.Append( anAIS );
+ }
+
+ anOCCViewer->setObjectsSelected( aListToSelect );
+ updateLocalPointView();
+}