From: mzn Date: Mon, 1 Jun 2015 06:23:20 +0000 (+0300) Subject: refs #524: fix preview selection problem X-Git-Tag: v1.4.1~7^2~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2fe8190c31b4be5a6b7b9ba2e7195dc4ab64c87f;p=modules%2Fhydro.git refs #524: fix preview selection problem --- diff --git a/src/HYDROData/HYDROData_PolylineXY.cxx b/src/HYDROData/HYDROData_PolylineXY.cxx index 44076c82..32f2ddab 100755 --- a/src/HYDROData/HYDROData_PolylineXY.cxx +++ b/src/HYDROData/HYDROData_PolylineXY.cxx @@ -1162,6 +1162,6 @@ void HYDROData_PolylineXY::Transform( const QTransform& theTrsf ) SetPoints( i, aPoints ); } - SetToUpdate( true ); + Update(); } diff --git a/src/HYDROGUI/HYDROGUI_OCCSelector.cxx b/src/HYDROGUI/HYDROGUI_OCCSelector.cxx index eebfdf35..75059329 100644 --- a/src/HYDROGUI/HYDROGUI_OCCSelector.cxx +++ b/src/HYDROGUI/HYDROGUI_OCCSelector.cxx @@ -70,11 +70,36 @@ void HYDROGUI_OCCSelector::setSelection( const SUIT_DataOwnerPtrList& aList ) return; Handle(AIS_InteractiveContext) aContext = aViewer->getAISContext(); - if ( aContext->HasOpenedContext() ) { + if ( aContext.IsNull() || aContext->HasOpenedContext() ) { return; } - LightApp_OCCSelector::setSelection( aList ); + //@MZN LightApp_OCCSelector::setSelection( aList ); + QMap aDisplayed; + + AIS_ListOfInteractive aDispList, aSelList; + aContext->DisplayedObjects( aDispList ); + + for ( AIS_ListIteratorOfListOfInteractive it( aDispList ); it.More(); it.Next() ) + { + QString entryStr = entry( it.Value() ); + if ( !entryStr.isEmpty() ) + aDisplayed.insert( entryStr, it.Value() ); + } + + mySelectedExternals.clear(); + + for ( SUIT_DataOwnerPtrList::const_iterator itr = aList.begin(); itr != aList.end(); ++itr ) + { + const LightApp_DataOwner* owner = dynamic_cast( (*itr).operator->() ); + if ( owner && aDisplayed.contains( owner->entry() ) ) + aSelList.Append( aDisplayed[owner->entry()] ); + else + mySelectedExternals.append(*itr); + } + + //@MZNmyViewer->unHighlightAll( false ); + aViewer->setObjectsSelected( aSelList ); } QString HYDROGUI_OCCSelector::entry( const Handle(AIS_InteractiveObject)& anAIS ) const diff --git a/src/HYDROGUI/HYDROGUI_RecognizeContoursOp.cxx b/src/HYDROGUI/HYDROGUI_RecognizeContoursOp.cxx index 8dd8cbf6..a3166c19 100644 --- a/src/HYDROGUI/HYDROGUI_RecognizeContoursOp.cxx +++ b/src/HYDROGUI/HYDROGUI_RecognizeContoursOp.cxx @@ -24,6 +24,7 @@ #include "HYDROGUI_Tool.h" #include "HYDROGUI_UpdateFlags.h" #include "HYDROGUI_OCCSelector.h" +#include "HYDROGUI_ZLayers.h" //@MZN #include #include @@ -348,6 +349,15 @@ void HYDROGUI_RecognizeContoursOp::updateRecognizedPolylines() } } + QTransform aTrsf = myImage->Trsf(); + QImage anImage = myImage->Image(); + QRectF aRect( QPointF( 0, 0 ), QPointF( anImage.width(), anImage.height() ) ); + aRect = aTrsf.mapRect( aRect ); + aTrsf.setMatrix( aTrsf.m11(), aTrsf.m12(), aTrsf.m13(), + aTrsf.m21(), -aTrsf.m22(), aTrsf.m23(), + aTrsf.m31() + aRect.width() * 0.5, aTrsf.m32 () - aRect.height() * 0.5, aTrsf.m33() ); + + /* @MZN QTransform aTrsf = myImage->Trsf(); gp_Mat aMat( aTrsf.m11(), aTrsf.m21(), 0, aTrsf.m12(), -aTrsf.m22(), 0, @@ -359,28 +369,37 @@ void HYDROGUI_RecognizeContoursOp::updateRecognizedPolylines() aTrsf.m32() - aRect.height() * 0.5, 0 ); BRepBuilderAPI_GTransform aBuilder( gp_GTrsf( aMat, aVec ) ); + */ + Handle(HYDROData_PolylineXY) aPolylineObj = Handle(HYDROData_PolylineXY)::DownCast( doc()->CreateObject( KIND_POLYLINEXY ) ); QStringList aNamesList; for ( int i = 1; i <= aSubShapes.Length(); i++ ) { TopoDS_Shape aSubShape = aSubShapes.Value( i ); // Transform the sub-shape + aPolylineObj->ImportShape( aSubShape ); + aPolylineObj->Transform( aTrsf ); + + /* aBuilder.Perform( aSubShape, Standard_True ); if ( aBuilder.IsDone() ) { aSubShape = aBuilder.Shape(); - } + }*/ HYDROGUI_Shape* aShape = new HYDROGUI_Shape( aCtx, NULL, getPreviewZLayer() ); - aShape->setShape( aSubShape, true, false ); + aShape->setShape( aPolylineObj->GetShape(), true, false ); aShape->setBorderColor( HYDROData_PolylineXY::DefaultWireColor(), false, false ); - + QString aPrefix = QString("%1_%2_%3").arg( myImage->GetName(), "Contour", QString::number( i ) ); QString aName = HYDROGUI_Tool::GenerateObjectName( module(), aPrefix, QStringList(), true ); myPolylineShapes.insert( aName, aShape); aNamesList << aName; } + aPolylineObj->Remove(); + if ( !aCtx.IsNull() ) { + UpdateZLayersOfHilightPresentationsOfDisplayedObjects( aCtx, Graphic3d_ZLayerId_TopOSD ); aCtx->UpdateCurrentViewer(); }