#include "HYDROGUI_Shape.h"
#include "HYDROGUI_Tool.h"
#include "HYDROGUI_UpdateFlags.h"
+#include "HYDROGUI_OCCSelector.h"
#include <HYDROData_Document.h>
#include <HYDROData_GeomTool.h>
#include <SUIT_Desktop.h>
#include <SUIT_ViewManager.h>
+#include <BRepBuilderAPI_GTransform.hxx>
+#include <gp_GTrsf.hxx>
+
#include <QDialog>
#include <QTemporaryFile>
aPolylineObj->SetName( aName );
aPolylineObj->ImportShape( aShape );
aPolylineObj->SetWireColor( HYDROData_PolylineXY::DefaultWireColor() );
- aPolylineObj->Transform( myImage->Trsf() );
aPolylineObj->Update();
module()->setIsToUpdate( aPolylineObj );
OCCViewer_ViewManager* aViewManager = getPreviewManager();
if ( aViewManager ) {
if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() ) {
+ // aViewer->enablePreselection( true );
+ // aViewer->enableSelection( true );
aCtx = aViewer->getAISContext();
connect( aViewer, SIGNAL( selectionChanged() ), this, SLOT( onViewerSelectionChanged() ) );
}
}
+ QTransform aTrsf = myImage->Trsf();
+ gp_Mat aMat( aTrsf.m11(), aTrsf.m21(), 0,
+ aTrsf.m12(), -aTrsf.m22(), 0,
+ 0, 0, 1 );
+ QImage anImage = myImage->Image();
+ QRectF aRect( QPointF( 0, 0 ), QPointF( anImage.width(), anImage.height() ) );
+ aRect = aTrsf.mapRect( aRect );
+ gp_XYZ aVec( aTrsf.m31() + aRect.width() * 0.5,
+ aTrsf.m32() - aRect.height() * 0.5, 0 );
+
+ BRepBuilderAPI_GTransform aBuilder( gp_GTrsf( aMat, aVec ) );
+
QStringList aNamesList;
for ( int i = 1; i <= aSubShapes.Length(); i++ ) {
- const TopoDS_Shape& aSubShape = aSubShapes.Value( i );
+ TopoDS_Shape aSubShape = aSubShapes.Value( i );
+ // Transform the sub-shape
+ 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->setBorderColor( HYDROData_PolylineXY::DefaultWireColor(), false, false );
*/
void HYDROGUI_RecognizeContoursOp::onSelectionChanged( const QStringList& theSelectedNames )
{
- foreach ( QString aName, myPolylineShapes.keys() ) {
- bool isSelected = theSelectedNames.contains( aName );
- myPolylineShapes[aName]->highlight( isSelected, true );
+ Handle(AIS_InteractiveContext) aCtx = NULL;
+
+ OCCViewer_ViewManager* aViewManager = getPreviewManager();
+ if ( aViewManager ) {
+ if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() ) {
+ aCtx = aViewer->getAISContext();
+ }
+ }
+
+ if ( !aCtx.IsNull() ) {
+ foreach ( QString aName, myPolylineShapes.keys() ) {
+ Handle(AIS_InteractiveObject) anObject =
+ myPolylineShapes.value(aName)->getAISObject();
+
+ bool isSelected = theSelectedNames.contains( aName );
+ if ( ( isSelected && !aCtx->IsSelected( anObject) ) ||
+ ( !isSelected && aCtx->IsSelected( anObject) ) ) {
+ aCtx->AddOrRemoveSelected( anObject, Standard_False );
+ }
+ // myPolylineShapes[aName]->highlight( isSelected, true );
+ }
+ aCtx->UpdateCurrentViewer();
}
}
QStringList aSelectedNames;
foreach ( QString aName, myPolylineShapes.keys() ) {
- bool isSelected = aCtx->IsSelected( myPolylineShapes[aName]->getAISObject() );
+ bool isSelected = aCtx->IsSelected( myPolylineShapes.value(aName)->getAISObject() );
if ( isSelected ) {
aSelectedNames << aName;
}